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