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