· 8 years ago · Nov 17, 2017, 09:24 PM
1#include <sourcemod>
2#include <sdktools>
3#include <cstrike>
4
5#pragma semicolon 1
6#pragma newdecls required
7#define MAX_FILE_LEN 1024
8#define MODELS_PER_TEAM 128
9
10#define SM_SKINCHOOSER_VERSION "4.8"
11
12Handle g_version;
13Handle g_enabled;
14Handle g_steamid;
15Handle g_arms_enabled;
16Handle g_autodisplay;
17Handle g_displaytimer;
18Handle g_AdminGroup;
19Handle g_AdminOnly;
20Handle g_SkinBots;
21Handle g_SkinAdmin;
22Handle g_ForcePlayerSkin;
23Handle g_SkinAdminTimer;
24Handle g_ForcePlayerSkinTimer;
25Handle g_CommandCountsEnabled;
26Handle g_CloseMenuTimer;
27Handle g_menustarttime;
28Handle g_CommandCounts;
29Handle g_mapbased;
30Handle g_request_frame;
31
32Handle playermodelskv;
33Handle playermodelskva;
34Handle kv;
35Handle kva;
36Handle mainmenu = INVALID_HANDLE;
37Handle armsmainmenu = INVALID_HANDLE;
38
39
40char g_ModelsAdminTeam2[MODELS_PER_TEAM][MAX_FILE_LEN];
41char g_ModelsAdminTeam3[MODELS_PER_TEAM][MAX_FILE_LEN];
42char g_ModelsAdmin_Count_Team2;
43char g_ModelsAdmin_Count_Team3;
44char g_ModelsPlayerTeam2[MODELS_PER_TEAM][MAX_FILE_LEN];
45char g_ModelsPlayerTeam3[MODELS_PER_TEAM][MAX_FILE_LEN];
46char g_ModelsPlayer_Count_Team2;
47char g_ModelsPlayer_Count_Team3;
48char g_ModelsBotsTeam2[MODELS_PER_TEAM][MAX_FILE_LEN];
49char g_ModelsBotsTeam3[MODELS_PER_TEAM][MAX_FILE_LEN];
50char g_ModelsBots_Count_Team2;
51char g_ModelsBots_Count_Team3;
52
53char authid[MAXPLAYERS+1][64];
54char map[256];
55char mediatype[256];
56int downloadtype;
57
58char g_CmdCount[MAXPLAYERS+1];
59char Game[64];
60
61char anarchistModelsT[][] =
62{
63 "models/player/custom_player/legacy/tm_anarchist.mdl",
64 "models/player/custom_player/legacy/tm_anarchist_variantA.mdl",
65 "models/player/custom_player/legacy/tm_anarchist_variantB.mdl",
66 "models/player/custom_player/legacy/tm_anarchist_variantC.mdl",
67 "models/player/custom_player/legacy/tm_anarchist_variantD.mdl"
68};
69
70char balkanModelsT[][] =
71{
72 "models/player/custom_player/legacy/tm_balkan_variantA.mdl",
73 "models/player/custom_player/legacy/tm_balkan_variantB.mdl",
74 "models/player/custom_player/legacy/tm_balkan_variantC.mdl",
75 "models/player/custom_player/legacy/tm_balkan_variantD.mdl",
76 "models/player/custom_player/legacy/tm_balkan_variantE.mdl"
77};
78
79char leetModelsT[][] =
80{
81 "models/player/custom_player/legacy/tm_leet_variantA.mdl",
82 "models/player/custom_player/legacy/tm_leet_variantB.mdl",
83 "models/player/custom_player/legacy/tm_leet_variantC.mdl",
84 "models/player/custom_player/legacy/tm_leet_variantD.mdl",
85 "models/player/custom_player/legacy/tm_leet_variantE.mdl"
86};
87
88char phoenixModelsT[][] =
89{
90 "models/player/custom_player/legacy/tm_phoenix.mdl",
91 "models/player/custom_player/legacy/tm_phoenix_heavy.mdl",
92 "models/player/custom_player/legacy/tm_phoenix_variantA.mdl",
93 "models/player/custom_player/legacy/tm_phoenix_variantB.mdl",
94 "models/player/custom_player/legacy/tm_phoenix_variantC.mdl",
95 "models/player/custom_player/legacy/tm_phoenix_variantD.mdl"
96};
97
98char pirateModelsT[][] =
99{
100 "models/player/custom_player/legacy/tm_pirate.mdl",
101 "models/player/custom_player/legacy/tm_pirate_variantA.mdl",
102 "models/player/custom_player/legacy/tm_pirate_variantB.mdl",
103 "models/player/custom_player/legacy/tm_pirate_variantC.mdl",
104 "models/player/custom_player/legacy/tm_pirate_variantD.mdl"
105};
106
107char professionalModelsT[][] =
108{
109 "models/player/custom_player/legacy/tm_professional.mdl",
110 "models/player/custom_player/legacy/tm_professional_var1.mdl",
111 "models/player/custom_player/legacy/tm_professional_var2.mdl",
112 "models/player/custom_player/legacy/tm_professional_var3.mdl",
113 "models/player/custom_player/legacy/tm_professional_var4.mdl"
114};
115
116char separatistModelsT[][] =
117{
118 "models/player/custom_player/legacy/tm_separatist.mdl",
119 "models/player/custom_player/legacy/tm_separatist_variantA.mdl",
120 "models/player/custom_player/legacy/tm_separatist_variantB.mdl",
121 "models/player/custom_player/legacy/tm_separatist_variantC.mdl",
122 "models/player/custom_player/legacy/tm_separatist_variantD.mdl"
123};
124
125char fbiModelsCT[][] =
126{
127 "models/player/custom_player/legacy/ctm_fbi.mdl",
128 "models/player/custom_player/legacy/ctm_fbi_variantA.mdl",
129 "models/player/custom_player/legacy/ctm_fbi_variantB.mdl",
130 "models/player/custom_player/legacy/ctm_fbi_variantC.mdl",
131 "models/player/custom_player/legacy/ctm_fbi_variantD.mdl"
132};
133
134char gignModelsCT[][] =
135{
136 "models/player/custom_player/legacy/ctm_gign.mdl",
137 "models/player/custom_player/legacy/ctm_gign_variantA.mdl",
138 "models/player/custom_player/legacy/ctm_gign_variantB.mdl",
139 "models/player/custom_player/legacy/ctm_gign_variantC.mdl",
140 "models/player/custom_player/legacy/ctm_gign_variantD.mdl"
141};
142
143char gsg9ModelsCT[][] =
144{
145 "models/player/custom_player/legacy/ctm_gsg9.mdl",
146 "models/player/custom_player/legacy/ctm_gsg9_variantA.mdl",
147 "models/player/custom_player/legacy/ctm_gsg9_variantB.mdl",
148 "models/player/custom_player/legacy/ctm_gsg9_variantC.mdl",
149 "models/player/custom_player/legacy/ctm_gsg9_variantD.mdl"
150};
151
152char idfModelsCT[][] =
153{
154 "models/player/custom_player/legacy/ctm_idf.mdl",
155 "models/player/custom_player/legacy/ctm_idf_variantA.mdl",
156 "models/player/custom_player/legacy/ctm_idf_variantB.mdl",
157 "models/player/custom_player/legacy/ctm_idf_variantC.mdl",
158 "models/player/custom_player/legacy/ctm_idf_variantD.mdl",
159 "models/player/custom_player/legacy/ctm_idf_variantE.mdl",
160 "models/player/custom_player/legacy/ctm_idf_variantF.mdl"
161};
162
163char sasModelsCT[][] =
164{
165 "models/player/custom_player/legacy/ctm_sas.mdl",
166 "models/player/custom_player/legacy/ctm_sas_variantA.mdl",
167 "models/player/custom_player/legacy/ctm_sas_variantB.mdl",
168 "models/player/custom_player/legacy/ctm_sas_variantC.mdl",
169 "models/player/custom_player/legacy/ctm_sas_variantD.mdl",
170 "models/player/custom_player/legacy/ctm_sas_variantE.mdl"
171};
172
173char st6ModelsCT[][] =
174{
175 "models/player/custom_player/legacy/ctm_st6.mdl",
176 "models/player/custom_player/legacy/ctm_st6_variantA.mdl",
177 "models/player/custom_player/legacy/ctm_st6_variantB.mdl",
178 "models/player/custom_player/legacy/ctm_st6_variantC.mdl",
179 "models/player/custom_player/legacy/ctm_st6_variantD.mdl"
180};
181
182char swatModelsCT[][] =
183{
184 "models/player/custom_player/legacy/ctm_swat.mdl",
185 "models/player/custom_player/legacy/ctm_swat_variantA.mdl",
186 "models/player/custom_player/legacy/ctm_swat_variantB.mdl",
187 "models/player/custom_player/legacy/ctm_swat_variantC.mdl",
188 "models/player/custom_player/legacy/ctm_swat_variantD.mdl"
189};
190
191public Plugin myinfo =
192{
193 name = "SM SKINCHOOSER",
194 author = "Andi67",
195 description = "Skin Menu",
196 version = SM_SKINCHOOSER_VERSION,
197 url = "http://www.andi67-blog.de.vu"
198}
199
200public void OnPluginStart()
201{
202 g_version = CreateConVar("sm_skinchooser_version",SM_SKINCHOOSER_VERSION,"SM SKINCHOOSER VERSION",FCVAR_NOTIFY);
203 SetConVarString(g_version,SM_SKINCHOOSER_VERSION);
204 g_enabled = CreateConVar("sm_skinchooser_enabled", "1", "0 = Disabled , 1 = Enables the Plugin.", _, true, 0.0, true, 1.0);
205 g_arms_enabled = CreateConVar("sm_skinchooser_arms_enabled","0", "0 = disabled , 1 = Enables the usage for Armmodels in CSGO.", _, true, 0.0, true, 1.0);
206 g_steamid = CreateConVar("sm_skinchooser_steamid_format","0", "0 = SteamId 2 , 1 = SteamId 3", _, true, 0.0, true, 1.0);
207 g_mapbased = CreateConVar("sm_skinchooser_mapbased","0", "0 = Disabled , 1 = Enables usage of mapbased inis.", _, true, 0.0, true, 1.0);
208 g_autodisplay = CreateConVar("sm_skinchooser_autodisplay","0", "0 = Disabled , 1 = Enables Menu Auto popup.", _, true, 0.0, true, 1.0);
209 g_displaytimer = CreateConVar("sm_skinchooser_displaytimer","0", "0 = Disabled , 1 = Enables the Delay when Menu should auto popup.", _, true, 0.0, true, 1.0);
210 g_menustarttime = CreateConVar("sm_skinchooser_menustarttime" , "5.0", "Time in seconds when Menu should be started", _, true, 0.0, true, 1000.0);
211 g_AdminGroup = CreateConVar("sm_skinchooser_admingroup","1", "0 = Disabled , 1 = Enables the Groupsystem.", _, true, 0.0, true, 1.0);
212 g_AdminOnly = CreateConVar("sm_skinchooser_adminonly","1", "0 = Disabled , 1 = Enabled for Admins only.", _, true, 0.0, true, 1.0);
213 g_CommandCountsEnabled = CreateConVar("sm_skinchooser_commandcountsenabled", "0", "Enables the CommandCounter.", _, true, 0.0, true, 1.0);
214 g_CommandCounts = CreateConVar("sm_skinchooser_commandcounts", "1", "How many times users should be able to use the !models command.", _, true, 0.0, true, 1000.0);
215 g_CloseMenuTimer = CreateConVar("sm_skinchooser_closemenutimer" , "30", "Seconds when the Menu should be closed", _, true, 0.0, true, 1000.0);
216 g_ForcePlayerSkin = CreateConVar("sm_skinchooser_forceplayerskin" , "1", "0 = Disabled , 1 = Enabled , should Players get automaticly a Model?", _, true, 0.0, true, 1.0);
217 g_ForcePlayerSkinTimer = CreateConVar("sm_skinchooser_forceplayerskintimer" , "2.0", "Time in seconds when Model gets applied if forceplayerskin is set to 1!!!", _, true, 1.0, true, 100.0);
218 g_SkinBots = CreateConVar("sm_skinchooser_skinbots","0", "0 = Disabled , 1 = Enabled , should Bots have a custom Model?", _, true, 0.0, true, 1.0);
219 g_SkinAdmin = CreateConVar("sm_skinchooser_skinadmin","0", "0 = Disabled , 1 = Enabled , should Admins get automaticly a Model?", _, true, 0.0, true, 1.0);
220 g_SkinAdminTimer = CreateConVar("sm_skinchooser_skinadmintimer","2.0", "Time in seconds when Model gets applied if skinadmin is enabled!!!", _, true, 1.0, true, 100.0);
221 g_request_frame = CreateConVar("sm_skinchooser_use_request_frame","0", "0 = Uses RemoveItem Timer(comes with a little delay when setting Armmodel) , 1 = Enabled , uses the RequestFrame function(No delay when setting Armmodel) and respawns the player.", _, true, 0.0, true, 1.0);
222
223 // Create the model menu command
224 RegConsoleCmd("sm_models", Command_Model);
225
226 GetGameFolderName(Game, sizeof(Game));
227
228 // Hook the spawn event
229 HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
230 HookEvent("player_team", Event_PlayerTeam, EventHookMode_Post);
231
232 if (StrEqual(Game, "dod"))
233 {
234 HookEvent("dod_round_start", Event_RoundStart, EventHookMode_Post);
235 }
236 else
237 {
238 HookEvent("round_start", Event_RoundStart, EventHookMode_Post);
239 }
240
241 AutoExecConfig(true, "sm_skinchooser");
242}
243
244public void OnPluginEnd()
245{
246 CloseHandle(g_version);
247 CloseHandle(g_enabled);
248}
249
250//public void OnMapStart()
251public void OnConfigsExecuted()
252{
253 if(GetConVarInt(g_enabled) == 1)
254 {
255 for (int i = 0; i < sizeof(fbiModelsCT); i++)
256 {
257 if(fbiModelsCT[i][0] && !IsModelPrecached(fbiModelsCT[i]))
258 PrecacheModel(fbiModelsCT[i]);
259 }
260
261 for (int i = 0; i < sizeof(gignModelsCT); i++)
262 {
263 if(gignModelsCT[i][0] && !IsModelPrecached(gignModelsCT[i]))
264 PrecacheModel(gignModelsCT[i]);
265 }
266
267 for (int i = 0; i < sizeof(anarchistModelsT); i++)
268 {
269 if(anarchistModelsT[i][0] && !IsModelPrecached(anarchistModelsT[i]))
270 PrecacheModel(anarchistModelsT[i]);
271 }
272
273 for (int i = 0; i < sizeof(phoenixModelsT); i++)
274 {
275 if(phoenixModelsT[i][0] && !IsModelPrecached(phoenixModelsT[i]))
276 PrecacheModel(phoenixModelsT[i]);
277 }
278
279 for (int i = 0; i < sizeof(pirateModelsT); i++)
280 {
281 if(pirateModelsT[i][0] && !IsModelPrecached(pirateModelsT[i]))
282 PrecacheModel(pirateModelsT[i]);
283 }
284 PrecacheModel("models/weapons/t_arms.mdl");
285 PrecacheModel("models/weapons/ct_arms.mdl");
286
287 // Declare string to load skin's config from sourcemod/configs folder
288 char file[PLATFORM_MAX_PATH];
289 char files[PLATFORM_MAX_PATH];
290 char filea[PLATFORM_MAX_PATH];
291 char fileb[PLATFORM_MAX_PATH];
292 char curmap[PLATFORM_MAX_PATH];
293 GetCurrentMap(curmap, sizeof(curmap));
294
295 if(GetConVarInt(g_mapbased) == 1)
296 {
297 // Does current map string contains a "workshop" prefix at a start?
298 if (strncmp(curmap, "workshop", 8) == 0)
299 {
300 // If yes - skip the first 19 characters to avoid comparing the "workshop/12345678" prefix
301 BuildPath(Path_SM, file, sizeof(file), "configs/sm_skinchooser/%s_skins.ini", curmap[19]);
302 BuildPath(Path_SM, files, sizeof(files), "configs/sm_skinchooser/%s_skins_downloads.ini", curmap[19]);
303 }
304 else /* That's not a workshop map */
305 {
306 // Let's check that custom skin configuration file is exists for current map
307 BuildPath(Path_SM, file, sizeof(file), "configs/sm_skinchooser/%s_skins.ini", curmap);
308 BuildPath(Path_SM, files, sizeof(files), "configs/sm_skinchooser/%s_skins_downloads.ini", curmap);
309 }
310
311 // Unfortunately config for current map is not exists
312 if (!FileExists(file))
313 {
314 // Then use default one
315 BuildPath(Path_SM, file, sizeof(file), "configs/sm_skinchooser/default_skins.ini");
316 }
317
318 if (!FileExists(files))
319 {
320 BuildPath(Path_SM, files, sizeof(files), "configs/sm_skinchooser/default_skins_downloads.ini");
321 }
322
323 if (StrEqual(Game, "csgo") && GetConVarInt(g_arms_enabled) == 1)
324 {
325 if (strncmp(curmap, "workshop", 8) == 0)
326 {
327 BuildPath(Path_SM, filea, sizeof(filea), "configs/sm_skinchooser/%s_arms.ini", curmap[19]);
328 BuildPath(Path_SM, fileb, sizeof(fileb), "configs/sm_skinchooser/%s_arms_downloads.ini", curmap[19]);
329 }
330 else /* That's not a workshop map */
331 {
332 BuildPath(Path_SM, filea, sizeof(filea), "configs/sm_skinchooser/%s_arms.ini", curmap);
333 BuildPath(Path_SM, fileb, sizeof(fileb), "configs/sm_skinchooser/%s_arms_downloads.ini", curmap);
334 }
335
336 if (!FileExists(filea))
337 {
338 BuildPath(Path_SM, filea, sizeof(filea), "configs/sm_skinchooser/default_arms.ini");
339 }
340 if (!FileExists(fileb))
341 {
342 BuildPath(Path_SM, fileb, sizeof(fileb), "configs/sm_skinchooser/default_arms_downloads.ini");
343 }
344 }
345 }
346
347 else if(GetConVarInt(g_mapbased) == 0)
348 {
349 BuildPath(Path_SM, file, sizeof(file), "configs/sm_skinchooser/default_skins.ini");
350 BuildPath(Path_SM, files, sizeof(files), "configs/sm_skinchooser/default_skins_downloads.ini");
351
352 if (StrEqual(Game, "csgo") && GetConVarInt(g_arms_enabled) == 1)
353 {
354 BuildPath(Path_SM, filea, sizeof(filea), "configs/sm_skinchooser/default_arms.ini");
355 BuildPath(Path_SM, fileb, sizeof(fileb), "configs/sm_skinchooser/default_arms_downloads.ini");
356 }
357 }
358
359 LoadMapFile(file);
360 ReadDownloads(files);
361
362 if (StrEqual(Game, "csgo") && GetConVarInt(g_arms_enabled) == 1)
363 {
364 LoadArmsMapFile(filea);
365 ReadArmsDownloads(fileb);
366 }
367
368 if(GetConVarInt(g_ForcePlayerSkin) == 1)
369 {
370 g_ModelsPlayer_Count_Team2 = 0;
371 g_ModelsPlayer_Count_Team3 = 0;
372 g_ModelsPlayer_Count_Team2 = LoadModels(g_ModelsPlayerTeam2, "configs/sm_skinchooser/forceskinsplayer_team2.ini");
373 g_ModelsPlayer_Count_Team3 = LoadModels(g_ModelsPlayerTeam3, "configs/sm_skinchooser/forceskinsplayer_team3.ini");
374 }
375 if(GetConVarInt(g_SkinBots) == 1)
376 {
377 g_ModelsBots_Count_Team2 = 0;
378 g_ModelsBots_Count_Team3 = 0;
379 g_ModelsBots_Count_Team2 = LoadModels(g_ModelsBotsTeam2, "configs/sm_skinchooser/forceskinsbots_team2.ini");
380 g_ModelsBots_Count_Team3 = LoadModels(g_ModelsBotsTeam3, "configs/sm_skinchooser/forceskinsbots_team3.ini");
381 }
382 if(GetConVarInt(g_SkinAdmin) == 1)
383 {
384 g_ModelsAdmin_Count_Team2 = 0;
385 g_ModelsAdmin_Count_Team3 = 0;
386 g_ModelsAdmin_Count_Team2 = LoadModels(g_ModelsAdminTeam2, "configs/sm_skinchooser/forceskinsadmin_team2.ini");
387 g_ModelsAdmin_Count_Team3 = LoadModels(g_ModelsAdminTeam3, "configs/sm_skinchooser/forceskinsadmin_team3.ini");
388 }
389 }
390 // Load Player last choosen Models
391 char filex[PLATFORM_MAX_PATH];
392 char filey[PLATFORM_MAX_PATH];
393 char curmapa[PLATFORM_MAX_PATH];
394 GetCurrentMap(curmapa, sizeof(curmapa));
395
396 if(GetConVarInt(g_mapbased) == 1)
397 {
398 if (strncmp(curmapa, "workshop", 8) == 0)
399 {
400 BuildPath(Path_SM, filex, sizeof(filex), "data/%s_skinchooser_playermodels.ini", curmapa[19]);
401 playermodelskv = CreateKeyValues("Models");
402 FileToKeyValues(playermodelskv, filex);
403 }
404 else
405 {
406 BuildPath(Path_SM, filex, sizeof(filex), "data/%s_skinchooser_playermodels.ini", curmapa);
407 playermodelskv = CreateKeyValues("Models");
408 FileToKeyValues(playermodelskv, filex);
409 }
410
411 // If Game is CSGO load the last choosen Armmodel
412 if (StrEqual(Game, "csgo") && GetConVarInt(g_arms_enabled) == 1)
413 {
414 if (strncmp(curmapa, "workshop", 8) == 0)
415 {
416 BuildPath(Path_SM, filey, sizeof(filey), "data/%s_skinchooser_armsmodels.ini", curmapa[19]);
417 playermodelskva = CreateKeyValues("Arms");
418 FileToKeyValues(playermodelskva, filey);
419 }
420 else
421 {
422 BuildPath(Path_SM, filey, sizeof(filey), "data/%s_skinchooser_armsmodels.ini", curmapa);
423 playermodelskva = CreateKeyValues("Arms");
424 FileToKeyValues(playermodelskva, filey);
425 }
426 }
427 }
428 else if(GetConVarInt(g_mapbased) == 0)
429 {
430 BuildPath(Path_SM, filex, sizeof(filex), "data/skinchooser_playermodels.ini");
431 playermodelskv = CreateKeyValues("Models");
432 FileToKeyValues(playermodelskv, filex);
433
434 if (StrEqual(Game, "csgo") && GetConVarInt(g_arms_enabled) == 1)
435 {
436 BuildPath(Path_SM, filey, sizeof(filey), "data/skinchooser_armsmodels.ini");
437 playermodelskva = CreateKeyValues("Arms");
438 FileToKeyValues(playermodelskva, filey);
439 }
440 }
441}
442
443public void OnMapEnd()
444{
445 // Write the last choosen Model
446 char filea[PLATFORM_MAX_PATH];
447 char fileb[PLATFORM_MAX_PATH];
448 char curmap[PLATFORM_MAX_PATH];
449 GetCurrentMap(curmap, sizeof(curmap));
450
451 if(GetConVarInt(g_mapbased) == 1)
452 {
453 if (strncmp(curmap, "workshop", 8) == 0)
454 {
455 BuildPath(Path_SM, fileb, sizeof(fileb), "data/%s_skinchooser_playermodels.ini", curmap[19]);
456 KeyValuesToFile(playermodelskv, fileb);
457 CloseHandle(playermodelskv);
458 }
459 else
460 {
461 BuildPath(Path_SM, fileb, sizeof(fileb), "data/%s_skinchooser_playermodels.ini", curmap);
462 KeyValuesToFile(playermodelskv, fileb);
463 CloseHandle(playermodelskv);
464 }
465 // Write the last choosen Arms if Game is CSGO
466 if (StrEqual(Game, "csgo") && GetConVarInt(g_arms_enabled) == 1)
467 {
468 if (strncmp(curmap, "workshop", 8) == 0)
469 {
470 BuildPath(Path_SM, filea, sizeof(filea), "data/%s_skinchooser_armsmodels.ini", curmap[19]);
471 KeyValuesToFile(playermodelskva, filea);
472 CloseHandle(playermodelskva);
473 }
474 else
475 {
476 BuildPath(Path_SM, filea, sizeof(filea), "data/%s_skinchooser_armsmodels.ini", curmap);
477 KeyValuesToFile(playermodelskva, filea);
478 CloseHandle(playermodelskva);
479 }
480 }
481 CloseHandle(kv);
482 CloseHandle(kva);
483 }
484 if(GetConVarInt(g_mapbased) == 0)
485 {
486 BuildPath(Path_SM, fileb, sizeof(fileb), "data/skinchooser_playermodels.ini");
487 KeyValuesToFile(playermodelskv, fileb);
488 CloseHandle(playermodelskv);
489
490 if (StrEqual(Game, "csgo") && GetConVarInt(g_arms_enabled) == 1)
491 {
492 BuildPath(Path_SM, filea, sizeof(filea), "data/skinchooser_armsmodels.ini");
493 KeyValuesToFile(playermodelskva, filea);
494 CloseHandle(playermodelskva);
495 }
496 CloseHandle(kv);
497 CloseHandle(kva);
498 }
499}
500
501public int LoadModels(const char[][] models, char[] ini_file)
502{
503 char buffer[MAX_FILE_LEN];
504 char file[MAX_FILE_LEN];
505 int models_count;
506
507 BuildPath(Path_SM, file, MAX_FILE_LEN, ini_file);
508
509 //open precache file and add everything to download table
510 Handle fileh = OpenFile(file, "r");
511 while (ReadFileLine(fileh, buffer, MAX_FILE_LEN))
512 {
513 // Strip leading and trailing whitespace
514 TrimString(buffer);
515
516 // Skip comments
517 if (buffer[0] != '/')
518 {
519 // Skip non existing files (and Comments)
520 if (FileExists(buffer))
521 {
522 // Tell Clients to download files
523 AddFileToDownloadsTable(buffer);
524 // Tell Clients to cache model
525 if (StrEqual(buffer[strlen(buffer)-4], ".mdl", false) && (models_count<MODELS_PER_TEAM))
526 {
527 strcopy(models[models_count++], strlen(buffer)+1, buffer);
528 PrecacheModel(buffer, true);
529 }
530 }
531 }
532 }
533 return models_count;
534}
535
536void LoadMapFile(const char[] file)
537{
538 char path[100];
539
540 kv = CreateKeyValues("Commands");
541
542 FileToKeyValues(kv, file);
543
544 if (!KvGotoFirstSubKey(kv))
545 {
546 return;
547 }
548 do
549 {
550 KvJumpToKey(kv, "Team1");
551 KvGotoFirstSubKey(kv);
552 do
553 {
554 KvGetString(kv, "path", path, sizeof(path),"");
555 if (FileExists(path , true))
556 PrecacheModel(path,true);
557 }
558 while (KvGotoNextKey(kv));
559
560 KvGoBack(kv);
561 KvGoBack(kv);
562 KvJumpToKey(kv, "Team2");
563 KvGotoFirstSubKey(kv);
564 do
565 {
566 KvGetString(kv, "path", path, sizeof(path),"");
567 if (FileExists(path , true))
568 PrecacheModel(path,true);
569 }
570 while (KvGotoNextKey(kv));
571
572 KvGoBack(kv);
573 KvGoBack(kv);
574 }
575 while (KvGotoNextKey(kv));
576
577 KvRewind(kv);
578}
579
580void LoadArmsMapFile(const char[] filea)
581{
582 char arms[100];
583
584 kva = CreateKeyValues("Commands");
585
586 FileToKeyValues(kva, filea);
587
588 if (!KvGotoFirstSubKey(kva))
589 {
590 return;
591 }
592 do
593 {
594 KvJumpToKey(kva, "Team1");
595 KvGotoFirstSubKey(kva);
596 do
597 {
598 KvGetString(kva, "arms", arms, sizeof(arms),"");
599 if (FileExists(arms , true))
600 PrecacheModel(arms,true);
601 }
602 while (KvGotoNextKey(kva));
603
604 KvGoBack(kva);
605 KvGoBack(kva);
606 KvJumpToKey(kva, "Team2");
607 KvGotoFirstSubKey(kva);
608 do
609 {
610 KvGetString(kva, "arms", arms, sizeof(arms),"");
611 if (FileExists(arms , true))
612 PrecacheModel(arms,true);
613 }
614 while (KvGotoNextKey(kva));
615
616 KvGoBack(kva);
617 KvGoBack(kva);
618
619 }
620 while (KvGotoNextKey(kva));
621
622 KvRewind(kva);
623}
624
625Handle BuildMainMenu(int client)
626{
627 /* Create the menu Handle */
628 Handle menu = CreateMenu(Menu_Group);
629
630 if (!KvGotoFirstSubKey(kv))
631 {
632 return INVALID_HANDLE;
633 }
634
635 char buffer[30];
636 char accessFlag[5];
637 AdminId admin = GetUserAdmin(client);
638
639 {
640 do
641 {
642 if(GetConVarInt(g_AdminGroup) == 1)
643 {
644 // check if they have access
645 char group[30];
646 char temp[2];
647 KvGetString(kv,"Admin",group,sizeof(group));
648 AdminId AdmId = GetUserAdmin(client);
649 int count = GetAdminGroupCount(AdmId);
650 for (int i =0; i<count; i++)
651 {
652 if (FindAdmGroup(group) == GetAdminGroup(AdmId, i, temp, sizeof(temp)))
653 {
654 // Get the model group name and add it to the menu
655 KvGetSectionName(kv, buffer, sizeof(buffer));
656 AddMenuItem(menu,buffer,buffer);
657 }
658 }
659 }
660
661 //Get accesFlag and see if the Admin is in it
662 KvGetString(kv, "admin", accessFlag, sizeof(accessFlag));
663
664 if(StrEqual(accessFlag,""))
665 {
666 KvGetSectionName(kv, buffer, sizeof(buffer));
667 AddMenuItem(menu,buffer,buffer);
668 }
669
670 if(StrEqual(accessFlag,"a") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Reservation, Access_Effective))
671 {
672 KvGetSectionName(kv, buffer, sizeof(buffer));
673 AddMenuItem(menu,buffer,buffer);
674 }
675
676 if(StrEqual(accessFlag,"b") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Generic, Access_Effective))
677 {
678 KvGetSectionName(kv, buffer, sizeof(buffer));
679 AddMenuItem(menu,buffer,buffer);
680 }
681
682 if(StrEqual(accessFlag,"c") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Kick, Access_Effective))
683 {
684 KvGetSectionName(kv, buffer, sizeof(buffer));
685 AddMenuItem(menu,buffer,buffer);
686 }
687
688 if(StrEqual(accessFlag,"d") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Ban, Access_Effective))
689 {
690 KvGetSectionName(kv, buffer, sizeof(buffer));
691 AddMenuItem(menu,buffer,buffer);
692 }
693
694 if(StrEqual(accessFlag,"e") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Unban, Access_Effective))
695 {
696 KvGetSectionName(kv, buffer, sizeof(buffer));
697 AddMenuItem(menu,buffer,buffer);
698 }
699
700 if(StrEqual(accessFlag,"f") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Slay, Access_Effective))
701 {
702 KvGetSectionName(kv, buffer, sizeof(buffer));
703 AddMenuItem(menu,buffer,buffer);
704 }
705
706 if(StrEqual(accessFlag,"g") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Changemap, Access_Effective))
707 {
708 KvGetSectionName(kv, buffer, sizeof(buffer));
709 AddMenuItem(menu,buffer,buffer);
710 }
711
712 if(StrEqual(accessFlag,"h") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Convars, Access_Effective))
713 {
714 KvGetSectionName(kv, buffer, sizeof(buffer));
715 AddMenuItem(menu,buffer,buffer);
716 }
717
718 if(StrEqual(accessFlag,"i") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Config, Access_Effective))
719 {
720 KvGetSectionName(kv, buffer, sizeof(buffer));
721 AddMenuItem(menu,buffer,buffer);
722 }
723
724 if(StrEqual(accessFlag,"j") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Chat, Access_Effective))
725 {
726 KvGetSectionName(kv, buffer, sizeof(buffer));
727 AddMenuItem(menu,buffer,buffer);
728 }
729
730 if(StrEqual(accessFlag,"k") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Vote, Access_Effective))
731 {
732 KvGetSectionName(kv, buffer, sizeof(buffer));
733 AddMenuItem(menu,buffer,buffer);
734 }
735
736 if(StrEqual(accessFlag,"l") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Password, Access_Effective))
737 {
738 KvGetSectionName(kv, buffer, sizeof(buffer));
739 AddMenuItem(menu,buffer,buffer);
740 }
741
742 if(StrEqual(accessFlag,"m") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_RCON, Access_Effective))
743 {
744 KvGetSectionName(kv, buffer, sizeof(buffer));
745 AddMenuItem(menu,buffer,buffer);
746 }
747
748 if(StrEqual(accessFlag,"n") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Cheats, Access_Effective))
749 {
750 KvGetSectionName(kv, buffer, sizeof(buffer));
751 AddMenuItem(menu,buffer,buffer);
752 }
753
754 if(StrEqual(accessFlag,"o") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Custom1, Access_Effective))
755 {
756 KvGetSectionName(kv, buffer, sizeof(buffer));
757 AddMenuItem(menu,buffer,buffer);
758 }
759
760 if(StrEqual(accessFlag,"p") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Custom2, Access_Effective))
761 {
762 KvGetSectionName(kv, buffer, sizeof(buffer));
763 AddMenuItem(menu,buffer,buffer);
764 }
765
766 if(StrEqual(accessFlag,"q") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Custom3, Access_Effective))
767 {
768 KvGetSectionName(kv, buffer, sizeof(buffer));
769 AddMenuItem(menu,buffer,buffer);
770 }
771
772 if(StrEqual(accessFlag,"r") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Custom4, Access_Effective))
773 {
774 KvGetSectionName(kv, buffer, sizeof(buffer));
775 AddMenuItem(menu,buffer,buffer);
776 }
777
778 if(StrEqual(accessFlag,"s") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Custom5, Access_Effective))
779 {
780 KvGetSectionName(kv, buffer, sizeof(buffer));
781 AddMenuItem(menu,buffer,buffer);
782 }
783
784 if(StrEqual(accessFlag,"t") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Custom6, Access_Effective))
785 {
786 KvGetSectionName(kv, buffer, sizeof(buffer));
787 AddMenuItem(menu,buffer,buffer);
788 }
789
790 if(StrEqual(accessFlag,"z") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Root, Access_Effective))
791 {
792 KvGetSectionName(kv, buffer, sizeof(buffer));
793 AddMenuItem(menu,buffer,buffer);
794 }
795
796 } while (KvGotoNextKey(kv));
797 }
798 KvRewind(kv);
799
800 AddMenuItem(menu,"none","Alap Kinézet");
801 SetMenuTitle(menu, "Kinézetek");
802
803 return menu;
804}
805
806public void ReadFileFolder(char[] path )
807{
808 Handle dirh = INVALID_HANDLE;
809 char buffer[256];
810 char tmp_path[256];
811 FileType type = FileType_Unknown;
812 int len;
813
814 len = strlen(path);
815 if (path[len-1] == '\n')
816 path[--len] = '\0';
817
818 TrimString(path);
819
820 if(DirExists(path))
821 {
822 dirh = OpenDirectory(path);
823 while(ReadDirEntry(dirh,buffer,sizeof(buffer),type))
824 {
825 len = strlen(buffer);
826 if (buffer[len-1] == '\n')
827 buffer[--len] = '\0';
828
829 TrimString(buffer);
830
831 if (!StrEqual(buffer,"",false) && !StrEqual(buffer,".",false) && !StrEqual(buffer,"..",false))
832 {
833 strcopy(tmp_path,255,path);
834 StrCat(tmp_path,255,"/");
835 StrCat(tmp_path,255,buffer);
836 if(type == FileType_File)
837 {
838 if(downloadtype == 1)
839 {
840 ReadItem(tmp_path);
841 }
842
843
844 }
845 }
846 }
847 }
848 else{
849 if(downloadtype == 1)
850 {
851 ReadItem(path);
852 }
853
854 }
855 if(dirh != INVALID_HANDLE)
856 {
857 CloseHandle(dirh);
858 }
859}
860
861void ReadDownloads(const char[] files)
862{
863 Handle fileh = OpenFile(files, "r");
864 char buffer[256];
865 downloadtype = 1;
866 int len;
867
868 GetCurrentMap(map,255);
869
870 if(fileh == INVALID_HANDLE) return;
871 while (ReadFileLine(fileh, buffer, sizeof(buffer)))
872 {
873 len = strlen(buffer);
874 if (buffer[len-1] == '\n')
875 buffer[--len] = '\0';
876
877 TrimString(buffer);
878
879 if(!StrEqual(buffer,"",false))
880 {
881 ReadFileFolder(buffer);
882 }
883
884 if (IsEndOfFile(fileh))
885 break;
886 }
887 if(fileh != INVALID_HANDLE)
888 {
889 CloseHandle(fileh);
890 }
891}
892
893void ReadArmsDownloads(const char[] fileb)
894{
895 Handle fileh = OpenFile(fileb, "r");
896 char buffer[256];
897 downloadtype = 1;
898 int len;
899
900 GetCurrentMap(map,255);
901
902 if(fileh == INVALID_HANDLE) return;
903 while (ReadFileLine(fileh, buffer, sizeof(buffer)))
904 {
905 len = strlen(buffer);
906 if (buffer[len-1] == '\n')
907 buffer[--len] = '\0';
908
909 TrimString(buffer);
910
911 if(!StrEqual(buffer,"",false))
912 {
913 ReadFileFolder(buffer);
914 }
915
916 if (IsEndOfFile(fileh))
917 break;
918 }
919 if(fileh != INVALID_HANDLE)
920 {
921 CloseHandle(fileh);
922 }
923}
924
925public void ReadItem(char[] buffer)
926{
927 int len = strlen(buffer);
928 if (buffer[len-1] == '\n')
929 buffer[--len] = '\0';
930
931 TrimString(buffer);
932
933 if(len >= 2 && buffer[0] == '/' && buffer[1] == '/')
934 {
935 if(StrContains(buffer,"//") >= 0)
936 {
937 ReplaceString(buffer,255,"//","");
938 }
939 }
940 else if (!StrEqual(buffer,"",false) && FileExists(buffer))
941 {
942 if(StrContains(mediatype,"Model",true) >= 0)
943 {
944 PrecacheModel(buffer,true);
945 }
946 AddFileToDownloadsTable(buffer);
947 }
948 }
949
950public int Menu_Group(Menu menu, MenuAction action, int param1, int param2)
951{
952 // User has selected a model group
953 if (action == MenuAction_Select)
954 {
955 char info[30];
956
957 // Get the group they selected
958 bool found = GetMenuItem(menu, param2, info, sizeof(info));
959
960 if (!found)
961 return;
962
963 //tigeox
964 // Check to see if the user has decided they don't want a model
965 // (e.g. go to a stock model)%%
966 if(StrEqual(info,"none"))
967 {
968 // Get the player's authid
969 KvJumpToKey(playermodelskv,authid[param1],true);
970
971 // Clear their saved model so that the next time
972 // they spawn, they are able to use a stock model
973 if (GetClientTeam(param1) == 2)
974 {
975 KvSetString(playermodelskv, "Team1", "");
976 KvSetString(playermodelskv, "Team1Group", "");
977 }
978 else if (GetClientTeam(param1) == 3)
979 {
980 KvSetString(playermodelskv, "Team2", "");
981 KvSetString(playermodelskv, "Team2Group", "");
982 }
983
984 // Rewind the KVs
985 KvRewind(playermodelskv);
986
987 // We don't need to go any further, return
988 return;
989 }
990
991 // User selected a group
992 // advance kv to this group
993 KvJumpToKey(kv, info);
994
995
996 // Check users team
997 if (GetClientTeam(param1) == 2)
998 {
999 // Show team 1 models
1000 KvJumpToKey(kv, "Team1");
1001 }
1002 else if (GetClientTeam(param1) == 3)
1003 {
1004 // Show team 2 models
1005 KvJumpToKey(kv, "Team2");
1006 }
1007 else
1008
1009 // They must be spectator, return
1010 return;
1011
1012
1013 // Get the first model
1014 KvGotoFirstSubKey(kv);
1015
1016 // Create the menu
1017 Handle tempmenu = CreateMenu(Menu_Model);
1018
1019 // Add the models to the menu
1020 char buffer[30];
1021 char path[256];
1022 do
1023 {
1024 // Add the model to the menu
1025 KvGetSectionName(kv, buffer, sizeof(buffer));
1026 KvGetString(kv, "path", path, sizeof(path),"");
1027 AddMenuItem(tempmenu,path,buffer);
1028
1029 }
1030 while (KvGotoNextKey(kv));
1031
1032
1033 // Set the menu title to the model group name
1034 SetMenuTitle(tempmenu, info);
1035
1036 // Rewind the KVs
1037 KvRewind(kv);
1038
1039 // Display the menu
1040 DisplayMenu(tempmenu, param1, MENU_TIME_FOREVER);
1041 }
1042 else if (action == MenuAction_End)
1043 {
1044 CloseHandle(menu);
1045 }
1046}
1047
1048public int Menu_Model(Handle menu, MenuAction action, int param1, int param2)
1049{
1050 // User choose a model
1051 if (action == MenuAction_Select)
1052 {
1053 char info[256];
1054 char group[30];
1055
1056 // Get the model's menu item
1057 bool found = GetMenuItem(menu, param2, info, sizeof(info));
1058
1059
1060 if (!found)
1061 return;
1062
1063 // Set the user's model
1064 if (!StrEqual(info,"") && IsModelPrecached(info) && IsClientConnected(param1))
1065 {
1066 // Set the model
1067 SetEntityModel(param1, info);
1068 }
1069
1070 KvJumpToKey(playermodelskv,authid[param1],true);
1071
1072 // Save the user's choice so it is automatically applied
1073 // each time they spawn
1074 if (GetClientTeam(param1) == 2)
1075 {
1076 KvSetString(playermodelskv, "Team1", info);
1077 KvSetString(playermodelskv, "Team1Group", group);
1078 }
1079 else if (GetClientTeam(param1) == 3)
1080 {
1081 KvSetString(playermodelskv, "Team2", info);
1082 KvSetString(playermodelskv, "Team2Group", group);
1083 }
1084
1085 // Rewind the KVs
1086 KvRewind(playermodelskv);
1087 }
1088
1089 // If Game is not CSGO, close the menu handle else display Armsmenu
1090 if(action == MenuAction_Select)
1091 {
1092 if (StrEqual(Game, "csgo") && GetConVarInt(g_arms_enabled) == 1)
1093 {
1094 CreateTimer(0.1 , CommandSecMenu , param1);
1095 }
1096
1097 else
1098 {
1099 CloseHandle(menu);
1100 }
1101 }
1102}
1103
1104public Action CommandSecMenu(Handle timer, any param1)
1105{
1106 armsmainmenu = BuildArmsMainMenu(param1);
1107
1108 if (armsmainmenu == INVALID_HANDLE)
1109 {
1110 // We don't, send an error message and return
1111 PrintToConsole(param1, "There was an error generating the menu. Check your skins.ini file.");
1112 return Plugin_Handled;
1113 }
1114
1115 DisplayMenu(armsmainmenu, param1, GetConVarInt(g_CloseMenuTimer));
1116 return Plugin_Handled;
1117}
1118
1119Handle BuildArmsMainMenu(int param1)
1120{
1121 /* Create the menu Handle */
1122 Handle secmenu = CreateMenu(Menu_Arms_Group);
1123
1124 if (!KvGotoFirstSubKey(kva))
1125 {
1126 return INVALID_HANDLE;
1127 }
1128
1129 char buffer[30];
1130 char accessFlag[5];
1131 AdminId admin = GetUserAdmin(param1);
1132
1133 {
1134 do
1135 {
1136 if(GetConVarInt(g_AdminGroup) == 1)
1137 {
1138 // check if they have access
1139 char group[30];
1140 char temp[2];
1141 KvGetString(kva,"Admin",group,sizeof(group));
1142 AdminId AdmId = GetUserAdmin(param1);
1143 int count = GetAdminGroupCount(AdmId);
1144 for (int i =0; i<count; i++)
1145 {
1146 if (FindAdmGroup(group) == GetAdminGroup(AdmId, i, temp, sizeof(temp)))
1147 {
1148 // Get the model group name and add it to the menu
1149 KvGetSectionName(kva, buffer, sizeof(buffer));
1150 AddMenuItem(secmenu,buffer,buffer);
1151 }
1152 }
1153 }
1154
1155 //Get accesFlag and see if the Admin is in it
1156 KvGetString(kva, "admin", accessFlag, sizeof(accessFlag));
1157
1158 if(StrEqual(accessFlag,""))
1159 {
1160 KvGetSectionName(kva, buffer, sizeof(buffer));
1161 AddMenuItem(secmenu,buffer,buffer);
1162 }
1163
1164 if(StrEqual(accessFlag,"a") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Reservation, Access_Effective))
1165 {
1166 KvGetSectionName(kva, buffer, sizeof(buffer));
1167 AddMenuItem(secmenu,buffer,buffer);
1168 }
1169
1170 if(StrEqual(accessFlag,"b") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Generic, Access_Effective))
1171 {
1172 KvGetSectionName(kva, buffer, sizeof(buffer));
1173 AddMenuItem(secmenu,buffer,buffer);
1174 }
1175
1176 if(StrEqual(accessFlag,"c") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Kick, Access_Effective))
1177 {
1178 KvGetSectionName(kva, buffer, sizeof(buffer));
1179 AddMenuItem(secmenu,buffer,buffer);
1180 }
1181
1182 if(StrEqual(accessFlag,"d") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Ban, Access_Effective))
1183 {
1184 KvGetSectionName(kva, buffer, sizeof(buffer));
1185 AddMenuItem(secmenu,buffer,buffer);
1186 }
1187
1188 if(StrEqual(accessFlag,"e") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Unban, Access_Effective))
1189 {
1190 KvGetSectionName(kva, buffer, sizeof(buffer));
1191 AddMenuItem(secmenu,buffer,buffer);
1192 }
1193
1194 if(StrEqual(accessFlag,"f") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Slay, Access_Effective))
1195 {
1196 KvGetSectionName(kva, buffer, sizeof(buffer));
1197 AddMenuItem(secmenu,buffer,buffer);
1198 }
1199
1200 if(StrEqual(accessFlag,"g") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Changemap, Access_Effective))
1201 {
1202 KvGetSectionName(kva, buffer, sizeof(buffer));
1203 AddMenuItem(secmenu,buffer,buffer);
1204 }
1205
1206 if(StrEqual(accessFlag,"h") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Convars, Access_Effective))
1207 {
1208 KvGetSectionName(kva, buffer, sizeof(buffer));
1209 AddMenuItem(secmenu,buffer,buffer);
1210 }
1211
1212 if(StrEqual(accessFlag,"i") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Config, Access_Effective))
1213 {
1214 KvGetSectionName(kva, buffer, sizeof(buffer));
1215 AddMenuItem(secmenu,buffer,buffer);
1216 }
1217
1218 if(StrEqual(accessFlag,"j") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Chat, Access_Effective))
1219 {
1220 KvGetSectionName(kva, buffer, sizeof(buffer));
1221 AddMenuItem(secmenu,buffer,buffer);
1222 }
1223
1224 if(StrEqual(accessFlag,"k") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Vote, Access_Effective))
1225 {
1226 KvGetSectionName(kva, buffer, sizeof(buffer));
1227 AddMenuItem(secmenu,buffer,buffer);
1228 }
1229
1230 if(StrEqual(accessFlag,"l") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Password, Access_Effective))
1231 {
1232 KvGetSectionName(kva, buffer, sizeof(buffer));
1233 AddMenuItem(secmenu,buffer,buffer);
1234 }
1235
1236 if(StrEqual(accessFlag,"m") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_RCON, Access_Effective))
1237 {
1238 KvGetSectionName(kva, buffer, sizeof(buffer));
1239 AddMenuItem(secmenu,buffer,buffer);
1240 }
1241
1242 if(StrEqual(accessFlag,"n") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Cheats, Access_Effective))
1243 {
1244 KvGetSectionName(kva, buffer, sizeof(buffer));
1245 AddMenuItem(secmenu,buffer,buffer);
1246 }
1247
1248 if(StrEqual(accessFlag,"o") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Custom1, Access_Effective))
1249 {
1250 KvGetSectionName(kva, buffer, sizeof(buffer));
1251 AddMenuItem(secmenu,buffer,buffer);
1252 }
1253
1254 if(StrEqual(accessFlag,"p") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Custom2, Access_Effective))
1255 {
1256 KvGetSectionName(kva, buffer, sizeof(buffer));
1257 AddMenuItem(secmenu,buffer,buffer);
1258 }
1259
1260 if(StrEqual(accessFlag,"q") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Custom3, Access_Effective))
1261 {
1262 KvGetSectionName(kva, buffer, sizeof(buffer));
1263 AddMenuItem(secmenu,buffer,buffer);
1264 }
1265
1266 if(StrEqual(accessFlag,"r") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Custom4, Access_Effective))
1267 {
1268 KvGetSectionName(kva, buffer, sizeof(buffer));
1269 AddMenuItem(secmenu,buffer,buffer);
1270 }
1271
1272 if(StrEqual(accessFlag,"s") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Custom5, Access_Effective))
1273 {
1274 KvGetSectionName(kva, buffer, sizeof(buffer));
1275 AddMenuItem(secmenu,buffer,buffer);
1276 }
1277
1278 if(StrEqual(accessFlag,"t") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Custom6, Access_Effective))
1279 {
1280 KvGetSectionName(kva, buffer, sizeof(buffer));
1281 AddMenuItem(secmenu,buffer,buffer);
1282 }
1283
1284 if(StrEqual(accessFlag,"z") && admin != INVALID_ADMIN_ID && GetAdminFlag(admin, Admin_Root, Access_Effective))
1285 {
1286 KvGetSectionName(kva, buffer, sizeof(buffer));
1287 AddMenuItem(secmenu,buffer,buffer);
1288 }
1289
1290 } while (KvGotoNextKey(kva));
1291 }
1292 KvRewind(kva);
1293
1294 AddMenuItem(secmenu,"none","None");
1295 SetMenuTitle(secmenu, "Arms");
1296
1297 return secmenu;
1298}
1299
1300public int Menu_Arms_Group(Menu secmenu, MenuAction action,int param1, int param2)
1301{
1302 // User has selected a model group
1303 if (action == MenuAction_Select)
1304 {
1305 char info[30];
1306
1307 // Get the group they selected
1308 bool found = GetMenuItem(secmenu, param2, info, sizeof(info));
1309
1310 if (!found)
1311 return;
1312
1313 //tigeox
1314 // Check to see if the user has decided they don't want a model
1315 // (e.g. go to a stock model)%%
1316 if(StrEqual(info,"none"))
1317 {
1318 // Get the player's authid
1319 KvJumpToKey(playermodelskva,authid[param1],true);
1320
1321 // Clear their saved model so that the next time
1322 // they spawn, they are able to use a stock model
1323 if (GetClientTeam(param1) == 2)
1324 {
1325 KvSetString(playermodelskva, "Team1", "");
1326 KvSetString(playermodelskva, "Team1Group", "");
1327 }
1328 else if (GetClientTeam(param1) == 3)
1329 {
1330 KvSetString(playermodelskva, "Team2", "");
1331 KvSetString(playermodelskva, "Team2Group", "");
1332 }
1333
1334 // Rewind the KVs
1335 KvRewind(playermodelskva);
1336
1337 // We don't need to go any further, return
1338 return;
1339 }
1340
1341 // User selected a group
1342 // advance kv to this group
1343 KvJumpToKey(kva, info);
1344
1345
1346 // Check users team
1347 if (GetClientTeam(param1) == 2)
1348 {
1349 // Show team 1 models
1350 KvJumpToKey(kva, "Team1");
1351 }
1352 else if (GetClientTeam(param1) == 3)
1353 {
1354 // Show team 2 models
1355 KvJumpToKey(kva, "Team2");
1356 }
1357 else
1358
1359 // They must be spectator, return
1360 return;
1361
1362
1363 // Get the first model
1364 KvGotoFirstSubKey(kva);
1365
1366 // Create the menu
1367 Menu atempmenu = CreateMenu(Menu_Arms);
1368
1369 // Add the models to the menu
1370 char buffer[30];
1371 char arms[256];
1372 do
1373 {
1374 // Add the model to the menu
1375 KvGetSectionName(kva, buffer, sizeof(buffer));
1376 KvGetString(kva, "arms", arms, sizeof(arms),"");
1377 AddMenuItem(atempmenu,arms,buffer);
1378
1379 }
1380 while (KvGotoNextKey(kva));
1381
1382
1383 // Set the menu title to the model group name
1384 SetMenuTitle(atempmenu, info);
1385
1386 // Rewind the KVs
1387 KvRewind(kva);
1388
1389 // Display the menu
1390 DisplayMenu(atempmenu, param1, MENU_TIME_FOREVER);
1391 }
1392 else if (action == MenuAction_End)
1393 {
1394 CloseHandle(secmenu);
1395 }
1396}
1397
1398public int Menu_Arms(Menu amenu, MenuAction action, int param1,int param2)
1399{
1400 // User choose a model
1401 if (action == MenuAction_Select)
1402 {
1403 char info[256];
1404 char group[30];
1405
1406 // Get the model's menu item
1407 bool found = GetMenuItem(amenu, param2, info, sizeof(info));
1408
1409
1410 if (!found)
1411 return;
1412
1413 // Set the user's model
1414 if (!StrEqual(info,"") && IsModelPrecached(info) && IsClientConnected(param1))
1415 {
1416 if(IsPlayerAlive(param1))
1417 {
1418 // Set the model
1419 SetEntPropString(param1, Prop_Send, "m_szArmsModel", info);
1420 if(GetConVarInt(g_request_frame) == 1)
1421 {
1422 RequestFrame(Respawn, param1);
1423 }
1424 if(GetConVarInt(g_request_frame) == 0)
1425 {
1426 CreateTimer(0.15, RemoveItemTimer, EntIndexToEntRef(param1), TIMER_FLAG_NO_MAPCHANGE);
1427 }
1428 }
1429 }
1430
1431 // Get the player's steam
1432 KvJumpToKey(playermodelskva,authid[param1], true);
1433
1434 // Save the user's choice so it is automatically applied
1435 // each time they spawn
1436 if (GetClientTeam(param1) == 2)
1437 {
1438 KvSetString(playermodelskva, "Team1", info);
1439 KvSetString(playermodelskva, "Team1Group", group);
1440 }
1441 else if (GetClientTeam(param1) == 3)
1442 {
1443 KvSetString(playermodelskva, "Team2", info);
1444 KvSetString(playermodelskva, "Team2Group", group);
1445 }
1446
1447 // Rewind the KVs
1448 KvRewind(playermodelskva);
1449 }
1450
1451 // If they picked exit, close the menu handle
1452 if (action == MenuAction_End)
1453 {
1454 CloseHandle(amenu);
1455 }
1456}
1457
1458public void OnClientPostAdminCheck(int client)
1459{
1460 if(GetConVarInt(g_steamid) == 0)
1461 {
1462 GetClientAuthId(client,AuthId_Steam2, authid[client], sizeof(authid[]));
1463 }
1464 else if(GetConVarInt(g_steamid) == 1)
1465 {
1466 GetClientAuthId(client,AuthId_Steam3, authid[client], sizeof(authid[]));
1467 }
1468
1469 if(GetConVarInt(g_CommandCountsEnabled) == 1)
1470 {
1471 g_CmdCount[client] = 0;
1472 }
1473}
1474
1475public Action Timer_Menu(Handle timer, any client)
1476{
1477 if(GetClientTeam(client) == 2 || GetClientTeam(client) == 3 && IsValidClient(client))
1478 {
1479 Command_Model(client, 0);
1480 }
1481
1482 mainmenu = BuildMainMenu(client);
1483
1484 if (mainmenu == INVALID_HANDLE)
1485 {
1486 // We don't, send an error message and return
1487 PrintToConsole(client, "There was an error generating the menu. Check your skins.ini file.");
1488 return Plugin_Handled;
1489 }
1490
1491 DisplayMenu(mainmenu, client, GetConVarInt(g_CloseMenuTimer));
1492 PrintToChat(client, "Skinmenu is open , choose your Model!!!");
1493 return Plugin_Handled;
1494}
1495
1496public Action Command_Model(int client,int args)
1497{
1498 if(GetConVarInt(g_enabled) == 1)
1499 {
1500 if(GetConVarInt(g_CommandCountsEnabled) == 1)
1501 {
1502 g_CmdCount[client]++;
1503 int curCount = g_CmdCount[client];
1504
1505 if(curCount <= GetConVarInt(g_CommandCounts))
1506 {
1507 //Create the main menu
1508 mainmenu = BuildMainMenu(client);
1509
1510 // Do we have a valid model menu
1511 if (mainmenu == INVALID_HANDLE)
1512 {
1513 // We don't, send an error message and return
1514 PrintToConsole(client, "There was an error generating the menu. Check your skins.ini file.");
1515 return Plugin_Handled;
1516 }
1517
1518 AdminId admin = GetUserAdmin(client);
1519
1520 if (GetConVarInt(g_AdminOnly) == 1 && admin != INVALID_ADMIN_ID)
1521 {
1522 // We have a valid menu, display it and return
1523 DisplayMenu(mainmenu, client, GetConVarInt(g_CloseMenuTimer));
1524 }
1525 else if(GetConVarInt(g_AdminOnly) == 0)
1526 {
1527 DisplayMenu(mainmenu, client, GetConVarInt(g_CloseMenuTimer));
1528 }
1529 }
1530 }
1531 else if(GetConVarInt(g_CommandCountsEnabled) == 0)
1532 {
1533 //Create the main menu
1534 mainmenu = BuildMainMenu(client);
1535
1536 // Do we have a valid model menu
1537 if (mainmenu == INVALID_HANDLE)
1538 {
1539 // We don't, send an error message and return
1540 PrintToConsole(client, "There was an error generating the menu. Check your skins.ini file.");
1541 return Plugin_Handled;
1542 }
1543
1544 AdminId admin = GetUserAdmin(client);
1545
1546 if (GetConVarInt(g_AdminOnly) == 1 && admin != INVALID_ADMIN_ID)
1547 {
1548 // We have a valid menu, display it and return
1549 DisplayMenu(mainmenu, client, GetConVarInt(g_CloseMenuTimer));
1550 }
1551 else if(GetConVarInt(g_AdminOnly) == 0)
1552 {
1553 DisplayMenu(mainmenu, client, GetConVarInt(g_CloseMenuTimer));
1554 }
1555 }
1556 }
1557 return Plugin_Handled;
1558}
1559
1560public Action Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
1561{
1562 for(int i = 1; i <= MaxClients; i++)
1563 {
1564 g_CmdCount[i] = 0;
1565 }
1566}
1567
1568public Action Event_PlayerTeam(Handle event, const char[] name, bool dontBroadcast)
1569{
1570 if(GetConVarInt(g_enabled) == 1)
1571 {
1572 if( GetConVarBool(g_autodisplay) )
1573 {
1574 int client = GetClientOfUserId(GetEventInt(event, "userid"));
1575 int team = GetEventInt(event, "team");
1576 if( GetConVarBool(g_displaytimer))
1577 {
1578 if((team == 2 || team == 3) && IsValidClient(client) && !IsFakeClient(client))
1579 {
1580 CreateTimer(GetConVarFloat(g_menustarttime), Timer_Menu, client);
1581 }
1582 }
1583
1584 else if((team == 2 || team == 3) && IsValidClient(client) && !IsFakeClient(client))
1585 {
1586 Command_Model(client, 0);
1587 }
1588 return;
1589 }
1590 }
1591}
1592
1593public Action Event_PlayerSpawn(Handle event, const char[] name, bool dontBroadcast)
1594{
1595 if(GetConVarInt(g_enabled) == 1)
1596 {
1597 // Get the userid and client
1598 int client = GetClientOfUserId(GetEventInt(event, "userid"));
1599
1600 if (StrEqual(Game, "csgo") && GetConVarInt(g_arms_enabled) == 1)
1601 {
1602
1603 SetDefaultModels(client);
1604 // Get the user's authid
1605 KvJumpToKey(playermodelskva,authid[client],true);
1606
1607 char arms[256];
1608 char groups[30];
1609
1610 // Get the user's model pref
1611 if (!IsFakeClient(client) && IsValidClient(client) && GetClientTeam(client) == 2)
1612 {
1613 KvGetString(playermodelskva, "Team1", arms, sizeof(arms), "");
1614 KvGetString(playermodelskva, "Team1Group", groups, sizeof(groups), "");
1615 }
1616 else if (!IsFakeClient(client) && IsValidClient(client) && GetClientTeam(client) == 3)
1617 {
1618 KvGetString(playermodelskva, "Team2", arms, sizeof(arms), "");
1619 KvGetString(playermodelskva, "Team2Group", groups, sizeof(groups), "");
1620 }
1621
1622 // Make sure that they have a valid model pref
1623 if (!StrEqual(arms,"", false) && IsModelPrecached(arms))
1624 {
1625 // Set the Armsmodel
1626 SetEntPropString(client, Prop_Send, "m_szArmsModel", arms);
1627 }
1628 if (!StrEqual(arms,"") && IsModelPrecached(arms))
1629 {
1630 SetEntPropString(client, Prop_Send, "m_szArmsModel", arms);
1631 }
1632
1633 // Rewind the KVs
1634 KvRewind(playermodelskva);
1635 }
1636
1637 if (StrEqual(Game, "csgo") && GetConVarInt(g_arms_enabled) == 1)
1638 {
1639 if (!IsFakeClient(client) && IsValidClient(client))
1640 {
1641 CreateTimer(1.5, PlayerModel, client);
1642 }
1643 }
1644 else
1645 {
1646 if (!IsFakeClient(client) && IsValidClient(client))
1647 {
1648 CreateTimer(0.5, Timer_Spawn, client);
1649 }
1650 }
1651
1652 if(IsFakeClient(client) && GetConVarInt(g_SkinBots) == 1)
1653 {
1654 skin_bots(client);
1655 }
1656
1657 if (!IsFakeClient(client) && IsValidClient(client) && GetConVarInt(g_SkinAdmin) == 1)
1658 {
1659 AdminId admin = GetUserAdmin(client);
1660 if(admin != INVALID_ADMIN_ID )
1661 {
1662 CreateTimer(GetConVarFloat(g_SkinAdminTimer), skin_admin, client);
1663 }
1664 }
1665
1666 if (!IsFakeClient(client) && IsValidClient(client) && GetConVarInt(g_ForcePlayerSkin) == 1)
1667 {
1668 AdminId admin = GetUserAdmin(client);
1669 if(admin == INVALID_ADMIN_ID)
1670 {
1671 CreateTimer(GetConVarFloat(g_ForcePlayerSkinTimer), skin_players, client);
1672 }
1673 }
1674 }
1675}
1676
1677public Action PlayerModel(Handle timer ,any client)
1678{
1679 // Get the user's authid
1680 KvJumpToKey(playermodelskv,authid[client],true);
1681
1682 char model[256];
1683 char group[30];
1684
1685 // Get the user's model pref
1686 if (!IsFakeClient(client) && IsValidClient(client) && GetClientTeam(client) == 2)
1687 {
1688 KvGetString(playermodelskv, "Team1", model, sizeof(model), "");
1689 KvGetString(playermodelskv, "Team1Group", group, sizeof(group), "");
1690 }
1691 else if (!IsFakeClient(client) && IsValidClient(client) && GetClientTeam(client) == 3)
1692 {
1693 KvGetString(playermodelskv, "Team2", model, sizeof(model), "");
1694 KvGetString(playermodelskv, "Team2Group", group, sizeof(group), "");
1695 }
1696
1697 // Make sure that they have a valid model pref
1698 if (!StrEqual(model,"", false) && IsModelPrecached(model))
1699 {
1700 // Set the model
1701 SetEntityModel(client, model);
1702 }
1703 if (!StrEqual(model,"") && IsModelPrecached(model))
1704 {
1705 SetEntityModel(client, model);
1706 }
1707
1708 // Rewind the KVs
1709 KvRewind(playermodelskv);
1710}
1711
1712public Action Timer_Spawn(Handle timer, any client)
1713{
1714 // Get the user's authid
1715 KvJumpToKey(playermodelskv,authid[client],true);
1716 if (client == 0)
1717 return Plugin_Stop;
1718
1719 char model[256];
1720 char group[30];
1721
1722 // Get the user's model pref
1723 if (!IsFakeClient(client) && IsValidClient(client) && GetClientTeam(client) == 2)
1724 {
1725 KvGetString(playermodelskv, "Team1", model, sizeof(model), "");
1726 KvGetString(playermodelskv, "Team1Group", group, sizeof(group), "");
1727 }
1728 else if (!IsFakeClient(client) && IsValidClient(client) && GetClientTeam(client) == 3)
1729 {
1730 KvGetString(playermodelskv, "Team2", model, sizeof(model), "");
1731 KvGetString(playermodelskv, "Team2Group", group, sizeof(group), "");
1732 }
1733
1734 // Make sure that they have a valid model pref
1735 if (!StrEqual(model,"", false) && IsModelPrecached(model))
1736 {
1737 // Set the model
1738 SetEntityModel(client, model);
1739 }
1740 if (!StrEqual(model,"") && IsModelPrecached(model))
1741 {
1742 SetEntityModel(client, model);
1743 }
1744
1745 // Rewind the KVs
1746 KvRewind(playermodelskv);
1747}
1748
1749stock bool IsValidClient(int client)
1750{
1751 if (client <= 0) return false;
1752 if (client > MaxClients) return false;
1753 if (!IsClientConnected(client)) return false;
1754 return IsClientInGame(client);
1755}
1756
1757void skin_bots(int client)
1758{
1759 int team = GetClientTeam(client);
1760 if (team==2)
1761 {
1762 SetEntityModel(client,g_ModelsBotsTeam2[GetRandomInt(0, g_ModelsBots_Count_Team2-1)]);
1763 }
1764 else if (team==3)
1765 {
1766 SetEntityModel(client,g_ModelsBotsTeam3[GetRandomInt(0, g_ModelsBots_Count_Team3-1)]);
1767 }
1768}
1769
1770public Action skin_players(Handle timer, any client)
1771{
1772 if (client == 0)
1773 return Plugin_Stop;
1774 if ( !IsClientInGame(client))
1775 {
1776 return Plugin_Stop;
1777 }
1778 int team = GetClientTeam(client);
1779 if (team==2)
1780 {
1781 SetEntityModel(client,g_ModelsPlayerTeam2[GetRandomInt(0, g_ModelsPlayer_Count_Team2-1)]);
1782 }
1783 else if (team==3)
1784 {
1785 SetEntityModel(client,g_ModelsPlayerTeam3[GetRandomInt(0, g_ModelsPlayer_Count_Team3-1)]);
1786 }
1787}
1788
1789public Action skin_admin(Handle timer, any client)
1790{
1791 if ( !IsClientInGame(client))
1792 {
1793 return Plugin_Stop;
1794 }
1795 int team = GetClientTeam(client);
1796 if (team==2)
1797 {
1798 SetEntityModel(client,g_ModelsAdminTeam2[GetRandomInt(0, g_ModelsAdmin_Count_Team2-1)]);
1799 }
1800 else if (team==3)
1801 {
1802 SetEntityModel(client,g_ModelsAdminTeam3[GetRandomInt(0, g_ModelsAdmin_Count_Team3-1)]);
1803 }
1804}
1805
1806stock void SetDefaultModels(int client)
1807{
1808 if (IsValidClient(client) && IsPlayerAlive(client) && !IsFakeClient(client))
1809 {
1810 int team = GetClientTeam(client);
1811
1812 if (team == 2)
1813 {
1814 char sModelT[128];
1815 GetEntPropString(client, Prop_Data, "m_ModelName", sModelT, sizeof(sModelT));
1816
1817 for (int a = 0; a < sizeof(anarchistModelsT); a++)
1818 {
1819 if (StrEqual(anarchistModelsT[a], sModelT))
1820 {
1821 SetEntityModel(client,pirateModelsT[GetRandomInt(0 , -1)]);
1822 }
1823 }
1824 for (int b = 0; b < sizeof(phoenixModelsT); b++)
1825 {
1826 if (StrEqual(phoenixModelsT[b], sModelT))
1827 {
1828 SetEntityModel(client,pirateModelsT[GetRandomInt(0 , -1)]);
1829 }
1830 }
1831 for (int c = 0; c < sizeof(balkanModelsT); c++)
1832 {
1833 if (StrEqual(balkanModelsT[c], sModelT))
1834 {
1835 SetEntityModel(client,anarchistModelsT[GetRandomInt(0 , -1)]);
1836 }
1837 }
1838 for (int d = 0; d < sizeof(leetModelsT); d++)
1839 {
1840 if (StrEqual(leetModelsT[d], sModelT))
1841 {
1842 SetEntityModel(client,anarchistModelsT[GetRandomInt(0 , -1)]);
1843 }
1844 }
1845 for (int e = 0; e < sizeof(pirateModelsT); e++)
1846 {
1847 if (StrEqual(pirateModelsT[e], sModelT))
1848 {
1849 SetEntityModel(client,anarchistModelsT[GetRandomInt(0 , -1)]);
1850 }
1851 }
1852 for (int f = 0; f < sizeof(professionalModelsT); f++)
1853 {
1854 if (StrEqual(professionalModelsT[f], sModelT))
1855 {
1856 SetEntityModel(client,anarchistModelsT[GetRandomInt(0 , -1)]);
1857 }
1858 }
1859 for (int h = 0; h < sizeof(separatistModelsT); h++)
1860 {
1861 if (StrEqual(separatistModelsT[h], sModelT))
1862 {
1863 SetEntityModel(client,anarchistModelsT[GetRandomInt(0 , -1)]);
1864 }
1865 }
1866 SetEntPropString(client, Prop_Send, "m_szArmsModel","models/weapons/t_arms.mdl");
1867 }
1868 else if (team == 3)
1869 {
1870 char sModelCT[128];
1871 GetEntPropString(client, Prop_Data, "m_ModelName", sModelCT, sizeof(sModelCT));
1872
1873 for (int i = 0; i < sizeof(fbiModelsCT); i++)
1874 {
1875 if (StrEqual(fbiModelsCT[i], sModelCT))
1876 {
1877 SetEntityModel(client,gignModelsCT[GetRandomInt(0 , -1)]);
1878 }
1879 }
1880 for (int j = 0; j < sizeof(gsg9ModelsCT); j++)
1881 {
1882 if (StrEqual(gsg9ModelsCT[j], sModelCT))
1883 {
1884 SetEntityModel(client,fbiModelsCT[GetRandomInt(0 , -1)]);
1885 }
1886 }
1887 for (int k = 0; k < sizeof(gignModelsCT); k++)
1888 {
1889 if (StrEqual(gignModelsCT[k], sModelCT))
1890 {
1891 SetEntityModel(client,fbiModelsCT[GetRandomInt(0 , -1)]);
1892 }
1893 }
1894 for (int l = 0; l < sizeof(idfModelsCT); l++)
1895 {
1896 if (StrEqual(idfModelsCT[l], sModelCT))
1897 {
1898 SetEntityModel(client,fbiModelsCT[GetRandomInt(0 , -1)]);
1899 }
1900 }
1901 for (int m = 0; m < sizeof(sasModelsCT); m++)
1902 {
1903 if (StrEqual(sasModelsCT[m], sModelCT))
1904 {
1905 SetEntityModel(client,gignModelsCT[GetRandomInt(0 , -1)]);
1906 }
1907 }
1908 for (int n = 0; n < sizeof(st6ModelsCT); n++)
1909 {
1910 if (StrEqual(st6ModelsCT[n], sModelCT))
1911 {
1912 SetEntityModel(client,fbiModelsCT[GetRandomInt(0 , -1)]);
1913 }
1914 }
1915 for (int o = 0; o < sizeof(swatModelsCT); o++)
1916 {
1917 if (StrEqual(swatModelsCT[o], sModelCT))
1918 {
1919 SetEntityModel(client,gignModelsCT[GetRandomInt(0 , -1)]);
1920 }
1921 }
1922 SetEntPropString(client, Prop_Send, "m_szArmsModel","models/weapons/ct_arms.mdl");
1923 }
1924 }
1925}
1926
1927public void Respawn(any param1)
1928{
1929 CS_RespawnPlayer(param1);
1930}
1931
1932// Timers for updating the viewmodel arms
1933public Action RemoveItemTimer(Handle timer ,any ref)
1934{
1935 int client = EntRefToEntIndex(ref);
1936
1937 if (client != INVALID_ENT_REFERENCE)
1938 {
1939 int item = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
1940
1941 if (item > 0)
1942 {
1943 RemovePlayerItem(client, item);
1944
1945 Handle ph=CreateDataPack();
1946 WritePackCell(ph, EntIndexToEntRef(client));
1947 WritePackCell(ph, EntIndexToEntRef(item));
1948 CreateTimer(0.15 , AddItemTimer, ph, TIMER_FLAG_NO_MAPCHANGE);
1949 }
1950 }
1951}
1952
1953public Action AddItemTimer(Handle timer ,any ph)
1954{
1955 int client, item;
1956
1957 ResetPack(ph);
1958
1959 client = EntRefToEntIndex(ReadPackCell(ph));
1960 item = EntRefToEntIndex(ReadPackCell(ph));
1961
1962 if (client != INVALID_ENT_REFERENCE && item != INVALID_ENT_REFERENCE)
1963 {
1964 EquipPlayerWeapon(client, item);
1965 }
1966}