-
Notifications
You must be signed in to change notification settings - Fork 3
/
PLAYERS.sp
173 lines (144 loc) · 4.5 KB
/
PLAYERS.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#include "CAP.inc"
const CLIENT_MAX = 33; //32 + Console
const PLAYER_CLASS_MAX = 9; //Scout, Soldier, Pyro, etc..
const STEAMID_MAX = 30;
new CLIENT_LAST = CLIENT_MAX;
static bool:isEnabled_class[PLAYER_CLASS_MAX];
static bool:player_class[CLIENT_MAX][PLAYER_CLASS_MAX];
static player_Statis[CLIENT_MAX]; //0:Not Ready, 1:Ready, 2:Captain, 3:Picked
//0 - BLU, 1 - RED
static captains[2];
static String:captains_SteamID[2][STEAMID_MAX];
static captains_turn;
static playerspicked_count;
const PLAYERS_ON_TEAM_MAX = 6;
/*--------------------------------------------------------------------------------
/ Getters
/-------------------------------------------------------------------------------*/
PLAYERS_GetCaptainClient(id)
{
return captains[id];
}
String:PLAYERS_GetCaptainSteamID(id)
{
return captains_SteamID[id];
}
bool:PLAYERS_isHumanNotCap(client)
{
return client != 0 && IsClientInGame(client) && !IsFakeClient(client) && (player_Statis[client] < 2); //DEBUG if(IsClientInGame(client))
}
bool:PLAYERS_isClass(client, class)
{
return player_class[client][class];
}
bool:PLAYER_isClassEnabled(class)
{
return isEnabled_class[class];
}
PLAYERS_GetClassStrings(String:playerstrings_out[PLAYER_CLASS_MAX][MENUITEM_NAME_MAXLEN])
{
static String:PlayerStrings[PLAYER_CLASS_MAX][MENUITEM_NAME_MAXLEN] = {"Scout", "Soldier", "Pyro", "Demo", "Heavy", "Engineer", "Medic", "Sniper", "Spy"};
for(new i = 0; i < PLAYER_CLASS_MAX; i++){
playerstrings_out[i] = PlayerStrings[i];
}
}
/*--------------------------------------------------------------------------------
/ Setters
/-------------------------------------------------------------------------------*/
PLAYERS_Reset()
{
captains[0] = 0;
captains[1] = 0;
captains_SteamID[0] = "";
captains_SteamID[1] = "";
captains_turn = 0;
playerspicked_count = 0;
//TODO Get Cvar of enabled classes, then set them
}
PLAYERS_SetCaptainClient(cap_id, client)
{
player_Statis[client] = 2;
captains[cap_id] = client;
if(cap_id == 0)
ChangeClientTeam(client, 3);
else
ChangeClientTeam(client, 2);
}
PLAYERS_SetCaptainSteamID(id, const String:steamid[])
{
strcopy(captains_SteamID[id], STEAMID_MAX, steamid);
}
PLAYERS_ToggleClass(client, class)
{
if(player_class[client][class])
player_class[client][class] = false;
else
player_class[client][class] = true;
}
/*--------------------------------------------------------------------------------
/ Utilities
/-------------------------------------------------------------------------------*/
//Test for client 0
PLAYERS_GetClientEnd()
{
for(new i = MaxClients; i > 0;i--){
if(IsClientInGame(i) && !IsFakeClient(i)){
CLIENT_LAST = i;
return;
}
}
}
PLAYERS_GetClass(client)
{
PLAYERS_ClearPlayer(client);
LoadChooseClassMenu(client);
}
//TODO: Make more efficient, add static list of players and remove one each time a class is picked
PLAYERS_ClassPicked(client)
{
player_Statis[client] = 1;
new players_choosing_count = 0;
new String:players_choosing[CLIENT_MAX][PLAYER_NAME_MAXLEN];
for(new i = 1; i <= CLIENT_LAST ;i++){
if(PLAYERS_isHumanNotCap(i) && player_Statis[i] == 0)
GetClientName(i, players_choosing[players_choosing_count++], PLAYER_NAME_MAXLEN);
}
if(players_choosing_count != 0){
new String:players_choosing_string[CLIENT_MAX*PLAYER_NAME_MAXLEN];
ImplodeStrings(players_choosing, players_choosing_count, ", ", players_choosing_string, CLIENT_MAX*PLAYER_NAME_MAXLEN);
PrintHintTextToAll("Waiting for Players: \n %s", players_choosing_string);
}
else
CaptainMode();
}
bool:PLAYERS_CaptainPicksPlayer(captain_id,player_client)
{
if(captain_id != captains_turn)
return false;
player_Statis[player_client] = 3;
if(captain_id == 0){
ChangeClientTeam(player_client, 3);
captains_turn = 1;
LoadCaptainPickMenu(captains[captains_turn]);
}
else{
ChangeClientTeam(player_client, 2);
captains_turn = 0;
playerspicked_count++;
if(playerspicked_count >= (PLAYERS_ON_TEAM_MAX - 1))
StopPlugin("Teams Full");
else
LoadCaptainPickMenu(captains[captains_turn]);
}
return true;
}
PLAYERS_ClearPlayer(client)
{
for(new i = 0; i < PLAYER_CLASS_MAX; i++){
player_class[client][i] = false;
}
player_Statis[client] = 0;
}
/*--------------------------------------------------------------------------------
/ Private Helper Functions
/-------------------------------------------------------------------------------*/