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