-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_tf2_jointeam.sp
74 lines (62 loc) · 1.51 KB
/
test_tf2_jointeam.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
public Action Command_Jointeam(int client, const char[] command, int args)
{
if(!IsValidClient(client) || !gCV_JointeamHook.BoolValue)
{
return Plugin_Continue;
}
char arg1[16];
GetCmdArg(1, arg1, sizeof(arg1));
int iTeam;
if (gEV_Type == Engine_TF2)
{
iTeam = 2; // defaults to Red
if (StrEqual(arg1, "spectate", false) || StrEqual(arg1, "spectatearena", false))
iTeam = 1;
else if (StrEqual(arg1, "red", false))
iTeam = 2;
else if (StrEqual(arg1, "blue", false))
iTeam = 3;
else if (StrEqual(arg1, "auto", false))
iTeam = GetRandomInt(2, 3); // whatever
else if (StrEqual(arg1, "unassigned", false))
return Plugin_Handled;
if (iTeam == GetClientTeam(client))
return Plugin_Handled;
}
else
{
iTeam = StringToInt(arg1);
}
int iHumanTeam = GetHumanTeam();
if (iHumanTeam != 0 && iTeam != 1)
{
iTeam = iHumanTeam;
}
if (iTeam < 1 || iTeam > 3)
{
iTeam = GetRandomInt(2, 3);
}
CleanSwitchTeam(client, iTeam);
if (gEV_Type == Engine_TF2 && -1 == StrContains(command, "nomenus"))
{
BfWrite msg = view_as<BfWrite>(StartMessageOne("VGUIMenu", client));
msg.WriteString(iTeam == 2 ? "class_red" : "class_blue");
msg.WriteByte(1);
msg.WriteByte(0);
EndMessage();
}
if(gCV_RespawnOnTeam.BoolValue && iTeam != 1)
{
if(gEV_Type == Engine_TF2)
{
TF2_RespawnPlayer(client);
}
else
{
RemoveAllWeapons(client); // so weapons are removed and we don't hit the edict limit
CS_RespawnPlayer(client);
}
return Plugin_Stop;
}
return Plugin_Continue;
}