3 * Adds preset spawning to CS:S DM.
4 * This file is part of CS:S DM, Copyright (C) 2005-2007 AlliedModders LLC
5 * by David "BAILOPAN" Anderson, http://www.bailopan.net/cssdm/
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 #define CSSDM_GUNMENU_NO 0
30 #define CSSDM_GUNMENU_YES 1
31 #define CSSDM_GUNMENU_RANDOM 2
34 new Handle:cssdm_enable_equipment; /** cssdm_enable_equipment cvar */
35 new g_ArmorOffset = -1; /* m_ArmorValue offset */
36 new g_NVOffset = -1; /* m_bHasNightVision offset */
37 new g_HealthOffset = -1; /* m_iHealth offset */
38 new Handle:g_SpawnTimers[MAXPLAYERS+1]; /* Post-spawn timers */
39 new Handle:g_hPrimaryMenu = INVALID_HANDLE; /* Priamry menu Handle */
40 new Handle:g_hSecondaryMenu = INVALID_HANDLE; /* Secondary menu Handle */
41 new Handle:g_hEquipMenu = INVALID_HANDLE; /* Main equipment menu */
42 new bool:g_IsEnabled = false; /* Whether the plugin should work */
43 new g_PrimaryChoices[MAXPLAYERS+1]; /* Primary weapon selections */
44 new g_SecondaryChoices[MAXPLAYERS+1]; /* Secondary weapon selections */
45 new bool:g_GunMenuEnabled[MAXPLAYERS+1]; /* Whether the gun menu is enabled */
46 new bool:g_GunMenuAvailable[MAXPLAYERS+1]; /* Whether the gun menu is available */
47 new bool:g_bIsGo = false; /* Are we running on CS:GO? */
50 new g_PrimaryList[CSSDM_MAX_WEAPONS];
51 new g_SecondaryList[CSSDM_MAX_WEAPONS];
52 new g_PrimaryCount = 0;
53 new g_SecondaryCount = 0;
54 new g_PrimaryMenu = CSSDM_GUNMENU_YES;
55 new g_SecondaryMenu = CSSDM_GUNMENU_YES;
56 new bool:g_AllowBuy = false;
57 new g_ArmorAmount = 100;
58 new bool:g_Helmets = true;
60 new bool:g_Smokes = false;
61 new bool:g_HEs = false;
62 new bool:g_NightVision = false;
63 new bool:g_DefuseKits = true;
64 new bool:g_AllowGunCommand = true;
65 new g_HealthAmount = 100;
67 new bool:g_Decoy = false;
68 new bool:g_Taser = true;
71 new g_BotPrimaryList[CSSDM_MAX_WEAPONS];
72 new g_BotSecondaryList[CSSDM_MAX_WEAPONS];
73 new g_BotPrimaryCount = 0;
74 new g_BotSecondaryCount = 0;
76 new bool:g_BotHelmets = false;
78 new bool:g_BotSmokes = false;
79 new bool:g_BotHEs = false;
80 new bool:g_BotDefuseKits = true;
81 new g_BotHealthAmount = 100;
83 new bool:g_BotDecoy = false;
84 new bool:g_BotTaser = true;
87 public Plugin:myinfo =
89 name = "CS:S DM Equipment",
90 author = "AlliedModders LLC",
91 description = "Adds gun menu/equipment to CS:S DM",
92 version = CSSDM_VERSION,
93 url = "http://www.bailopan.net/cssdm/"
100 public OnPluginStart()
103 GetGameFolderName(game, sizeof(game));
104 if (StrEqual(game, "csgo", false))
109 LoadTranslations("cssdm.phrases");
111 RegConsoleCmd("say", Command_Say);
112 RegConsoleCmd("say_team", Command_Say);
114 cssdm_enable_equipment = CreateConVar("cssdm_enable_equipment", "1", "Sets whether the equipment plugin is enabled");
115 HookConVarChange(cssdm_enable_equipment, OnEquipmentEnableChange);
117 g_ArmorOffset = FindSendPropOffs("CCSPlayer", "m_ArmorValue");
118 g_NVOffset = FindSendPropOffs("CCSPlayer", "m_bHasNightVision");
119 g_HealthOffset = FindSendPropOffs("CCSPlayer", "m_iHealth");
121 g_hEquipMenu = CreateMenu(Menu_EquipHandler, MenuAction_DrawItem|MenuAction_DisplayItem);
122 SetMenuTitle(g_hEquipMenu, "Weapon Options:");
123 SetMenuExitButton(g_hEquipMenu, false);
124 AddMenuItem(g_hEquipMenu, "", "New weapons");
125 AddMenuItem(g_hEquipMenu, "", "Same weapons");
126 AddMenuItem(g_hEquipMenu, "", "Same weapons every time");
127 AddMenuItem(g_hEquipMenu, "", "Random weapons");
128 AddMenuItem(g_hEquipMenu, "", "Random weapons every time");
131 public OnEquipmentEnableChange(Handle:convar, const String:oldValue[], const String:newValue[])
133 g_IsEnabled = StringToInt(newValue) ? true : false;
136 public OnConfigsExecuted()
140 if ((g_IsEnabled = LoadConfigFile("cfg/cssdm/cssdm.equip.txt")) == false)
142 LogError("[CSSDM] Could not find equipment file \"%s\"", "cfg/cssdm/cssdm.equip.txt");
146 if (!GetConVarInt(cssdm_enable_equipment))
152 /** See if there is a map version */
154 decl String:path[255];
155 GetCurrentMap(map, sizeof(map));
156 Format(path, sizeof(path), "cfg/cssdm/maps/%s.equip.txt", map);
158 if (FileExists(path))
160 LoadConfigFile(path);
164 public Action:DM_OnClientDeath(client)
166 if (g_SpawnTimers[client] != INVALID_HANDLE)
168 KillTimer(g_SpawnTimers[client]);
169 g_SpawnTimers[client] = INVALID_HANDLE;
171 g_GunMenuAvailable[client] = true;
174 public OnClientPutInServer(client)
176 g_GunMenuEnabled[client] = true;
177 g_GunMenuAvailable[client] = true;
178 g_PrimaryChoices[client] = -1;
179 g_SecondaryChoices[client] = -1;
182 public OnClientDisconnect(client)
184 if (g_SpawnTimers[client] != INVALID_HANDLE)
186 KillTimer(g_SpawnTimers[client]);
187 g_SpawnTimers[client] = INVALID_HANDLE;
191 public DM_OnClientSpawned(client)
198 if (!IsFakeClient(client))
200 if (g_ArmorAmount > 0)
202 GivePlayerItem(client, "item_assaultsuit");
203 GivePlayerItem(client, "item_assaultsuit");
204 SetClientArmor(client, g_ArmorAmount);
206 if (g_HealthAmount > 0)
208 SetClientHealth(client, g_HealthAmount);
212 GivePlayerItem(client, "item_kevlar");
213 GivePlayerItem(client, "item_kevlar");
215 GiveGrenades(client, g_Flashes, g_HEs, g_Smokes, g_Decoy);
218 GiveNightVision(client);
220 if (g_bIsGo && g_Taser)
222 GivePlayerItem(client, "weapon_taser");
227 /* See if we'll need to strip this bot */
228 if (g_BotSecondaryCount || g_BotPrimaryCount)
230 DM_StripBotItems(client);
234 GivePlayerItem(client, "item_assaultsuit");
235 GivePlayerItem(client, "item_assaultsuit");
236 SetClientArmor(client, g_BotArmor);
238 /* Make sure bot didn't buy armor */
239 SetClientArmor(client, 0);
241 if (g_BotHealthAmount > 0)
243 SetClientHealth(client, g_BotHealthAmount);
247 GivePlayerItem(client, "item_kevlar");
248 GivePlayerItem(client, "item_kevlar");
250 if (g_bIsGo && g_BotTaser)
252 GivePlayerItem(client, "weapon_taser");
254 GiveGrenades(client, g_BotFlashes, g_BotHEs, g_BotSmokes, g_BotDecoy);
256 if (!g_AllowBuy && g_SpawnTimers[client] == INVALID_HANDLE)
258 /* Small delay - we want to avoid ResetHUD */
259 g_SpawnTimers[client] = CreateTimer(0.1, PlayerPostSpawn, client);
263 public Action:PlayerPostSpawn(Handle:timer, any:client)
265 g_SpawnTimers[client] = INVALID_HANDLE;
272 if (IsFakeClient(client))
274 if (g_BotSecondaryCount > 0)
277 if (g_BotSecondaryCount == 1)
279 index = g_BotSecondaryList[0];
281 index = GetRandomInt(0, g_BotSecondaryCount-1);
282 index = g_BotSecondaryList[index];
284 decl String:classname[64];
285 DM_GetWeaponClassname(index, classname, sizeof(classname));
286 GivePlayerItem(client, classname);
288 if (g_BotPrimaryCount > 0)
291 if (g_BotPrimaryCount == 1)
293 index = g_BotPrimaryList[0];
295 index = GetRandomInt(0, g_BotPrimaryCount-1);
296 index = g_BotPrimaryList[index];
298 decl String:classname[64];
299 DM_GetWeaponClassname(index, classname, sizeof(classname));
300 GivePlayerItem(client, classname);
302 if (g_BotDefuseKits && GetClientTeam(client) == CSSDM_TEAM_CT)
304 GivePlayerItem(client, "item_defuser");
307 if (g_DefuseKits && GetClientTeam(client) == CSSDM_TEAM_CT)
309 GivePlayerItem(client, "item_defuser");
313 /* First, check if we should only be giving one of something automatically */
314 if ((g_SecondaryMenu == CSSDM_GUNMENU_RANDOM || g_SecondaryMenu == CSSDM_GUNMENU_YES)
315 && g_SecondaryCount == 1)
317 GiveSecondary(client, 0);
319 } else if (g_PrimaryMenu == CSSDM_GUNMENU_RANDOM && g_PrimaryCount > 1) {
320 GivePrimary(client, g_PrimaryCount);
324 if ((g_PrimaryMenu == CSSDM_GUNMENU_RANDOM || g_PrimaryMenu == CSSDM_GUNMENU_YES)
325 && g_PrimaryCount == 1)
327 GivePrimary(client, 0);
329 } else if (g_SecondaryMenu == CSSDM_GUNMENU_RANDOM && g_SecondaryCount > 1) {
330 GiveSecondary(client, g_SecondaryCount);
334 /* If we've already given two weapons, there is no need for a menu. */
340 if (g_GunMenuEnabled[client])
342 DisplayMenu(g_hEquipMenu, client, MENU_TIME_FOREVER);
344 GiveBothFromChoices(client);
351 public Action:Command_Say(client, args)
355 return Plugin_Continue;
358 new String:text[192];
359 GetCmdArg(1, text, sizeof(text));
361 if (strcmp(text, "guns") == 0)
363 if (!g_AllowGunCommand)
365 PrintToChat(client, "[CSSDM] %t", "GunsMenuDisabled");
366 return Plugin_Handled;
369 if (!ChooseFromSecondary() && !ChooseFromPrimary())
371 PrintToChat(client, "[CSSDM] %t", "GunsMenuNotAvailable");
372 return Plugin_Handled;
375 if (g_GunMenuEnabled[client])
377 PrintToChat(client, "[CSSDM] %t", "GunsMenuAlreadyEnabled");
378 return Plugin_Handled;
381 g_GunMenuEnabled[client] = true;
382 if (!g_GunMenuAvailable[client])
384 PrintToChat(client, "[CSSDM] %t", "GunsMenuReactivated");
386 DisplayMenu(g_hEquipMenu, client, MENU_TIME_FOREVER);
389 return Plugin_Handled;
392 return Plugin_Continue;
395 public Action:OnClientCommand(client, args)
397 if (!ShouldRun() || g_AllowBuy)
399 return Plugin_Continue;
403 GetCmdArg(0, cmd, sizeof(cmd));
405 if (StrEqual(cmd, "buy")
406 || StrEqual(cmd, "autobuy")
407 || StrEqual(cmd, "rebuy")
408 || StrEqual(cmd, "buyequip")
409 || StrEqual(cmd, "buymenu"))
411 return Plugin_Handled;
414 return Plugin_Continue;
417 public Menu_EquipHandler(Handle:menu, MenuAction:action, param1, param2)
424 if (action == MenuAction_DrawItem)
426 if (param2 == 1 || param2 == 2)
428 if (g_PrimaryChoices[param1] == -1 && g_SecondaryChoices[param1] == -1)
430 return ITEMDRAW_DISABLED;
433 return ITEMDRAW_DEFAULT;
435 else if (action == MenuAction_Select)
439 if (ChooseFromSecondary())
441 DisplayMenu(g_hSecondaryMenu, param1, MENU_TIME_FOREVER);
442 } else if (ChooseFromPrimary()) {
443 DisplayMenu(g_hPrimaryMenu, param1, MENU_TIME_FOREVER);
445 } else if (param2 == 1) {
446 GiveBothFromChoices(param1);
447 } else if (param2 == 2) {
448 GiveBothFromChoices(param1);
449 g_GunMenuEnabled[param1] = false;
450 PrintToChat(param1, "[CSSDM] %t", "SayGunsNotify");
451 } else if (param2 == 3) {
452 GivePrimary(param1, g_PrimaryCount);
453 GiveSecondary(param1, g_SecondaryCount);
454 } else if (param2 == 4) {
455 GivePrimary(param1, g_PrimaryCount);
456 GiveSecondary(param1, g_SecondaryCount);
457 GiveBothFromChoices(param1);
458 g_GunMenuEnabled[param1] = false;
459 PrintToChat(param1, "[CSSDM] %t", "SayGunsNotify");
461 g_GunMenuAvailable[param1] = false;
463 else if (action == MenuAction_DisplayItem)
466 decl String:info[12], String:lang_phrase[32];
468 if (!GetMenuItem(menu, param2, info, sizeof(info), style, lang_phrase, sizeof(lang_phrase)))
473 decl String:t_phrase[64];
474 Format(t_phrase, sizeof(t_phrase), "%T", lang_phrase, param1);
476 return RedrawMenuItem(t_phrase);
482 public Menu_PrimaryHandler(Handle:menu, MenuAction:action, param1, param2)
489 if (action == MenuAction_DrawItem)
491 return ITEMDRAW_DEFAULT;
493 else if (action == MenuAction_Select)
495 GivePrimary(param1, param2);
497 else if (action == MenuAction_Display)
499 new Handle:hPanel = Handle:param2;
500 decl String:title[128];
502 Format(title, sizeof(title), "%T:", "Primary weapon", param1);
504 SetPanelTitle(hPanel, title);
510 public Menu_SecondaryHandler(Handle:menu, MenuAction:action, param1, param2)
517 if (action == MenuAction_DrawItem)
519 return ITEMDRAW_DEFAULT;
521 else if (action == MenuAction_Select)
523 GiveSecondary(param1, param2);
524 if (ChooseFromPrimary())
526 DisplayMenu(g_hPrimaryMenu, param1, MENU_TIME_FOREVER);
529 else if (action == MenuAction_Cancel
530 && param2 == MenuCancel_Exit)
532 if (ChooseFromPrimary())
534 DisplayMenu(g_hPrimaryMenu, param1, MENU_TIME_FOREVER);
537 else if (action == MenuAction_Display)
539 new Handle:hPanel = Handle:param2;
540 decl String:title[128];
542 Format(title, sizeof(title), "%T:", "Secondary weapon", param1);
544 SetPanelTitle(hPanel, title);
550 bool:ChooseFromPrimary()
552 return (g_PrimaryMenu == CSSDM_GUNMENU_YES
553 && g_PrimaryCount > 1);
556 bool:ChooseFromSecondary()
558 return (g_SecondaryMenu == CSSDM_GUNMENU_YES
559 && g_SecondaryCount > 1);
562 GiveWeapon(client, index)
564 if (!IsPlayerAlive(client))
569 new DmWeaponType:type = DM_GetWeaponType(index);
571 new entity = DM_GetClientWeapon(client, type);
574 DM_DropWeapon(client, entity);
578 DM_GetWeaponClassname(index, cls, sizeof(cls));
580 GivePlayerItem(client, cls);
583 GiveBothFromChoices(client)
585 if (ChooseFromPrimary())
587 GivePrimary(client, g_PrimaryChoices[client]);
590 if (ChooseFromSecondary())
592 GiveSecondary(client, g_SecondaryChoices[client]);
597 * Gives a primary weapon to a client.
598 * If the list_index is > the count, we choose one randomly.
599 * This is a hack so we can append "Random" to the choice list.
601 GivePrimary(client, list_index)
609 if (list_index >= g_PrimaryCount)
611 if (g_PrimaryCount > 1)
613 weapon_index = GetRandomInt(0, g_PrimaryCount-1);
614 weapon_index = g_PrimaryList[weapon_index];
615 } else if (g_PrimaryCount == 1) {
616 weapon_index = g_PrimaryList[0];
621 weapon_index = g_PrimaryList[list_index];
624 g_PrimaryChoices[client] = list_index;
626 GiveWeapon(client, weapon_index);
630 * Gives a secondary weapon to a client.
631 * If the list_index is > the count, we choose one randomly.
632 * This is a hack so we can append "Random" to the choice list.
634 GiveSecondary(client, list_index)
642 if (list_index >= g_SecondaryCount)
644 if (g_SecondaryCount > 1)
646 weapon_index = GetRandomInt(0, g_SecondaryCount-1);
647 weapon_index = g_SecondaryList[weapon_index];
648 } else if (g_SecondaryCount == 1) {
649 weapon_index = g_SecondaryList[0];
654 weapon_index = g_SecondaryList[list_index];
657 g_SecondaryChoices[client] = list_index;
659 GiveWeapon(client, weapon_index);
664 return (DM_IsRunning() && g_IsEnabled);
667 bool:KvGetYesOrNo(Handle:kv, const String:key[], bool:curdefault)
669 decl String:value[12];
670 KvGetString(kv, key, value, sizeof(value), curdefault ? "yes" : "no");
671 return (strcmp(value, "yes") == 0);
674 KvGetGunMenu(Handle:kv, const String:key[], def)
676 decl String:sdef[12];
677 if (def == CSSDM_GUNMENU_YES)
679 strcopy(sdef, sizeof(sdef), "yes");
680 } else if (def == CSSDM_GUNMENU_RANDOM) {
681 strcopy(sdef, sizeof(sdef), "random");
683 strcopy(sdef, sizeof(sdef), "no");
686 decl String:value[12];
687 KvGetString(kv, key, value, sizeof(value), sdef);
689 if (strcmp(value, "yes") == 0)
691 return CSSDM_GUNMENU_YES;
692 } else if (strcmp(value, "random") == 0) {
693 return CSSDM_GUNMENU_RANDOM;
696 return CSSDM_GUNMENU_NO;
701 g_PrimaryMenu = CSSDM_GUNMENU_YES;
702 g_SecondaryMenu = CSSDM_GUNMENU_YES;
709 g_NightVision = false;
711 g_HealthAmount = 100;
712 g_AllowGunCommand = true;
715 bool:LoadConfigFile(const String:path[])
717 new Handle:kv = CreateKeyValues("Equipment");
718 if (!FileToKeyValues(kv, path))
723 decl String:value[255];
726 if (KvJumpToKey(kv, "Settings"))
728 g_AllowGunCommand = KvGetYesOrNo(kv, "guns_command", g_AllowGunCommand);
732 /* Load menu options */
733 if (KvJumpToKey(kv, "Menus"))
735 g_PrimaryMenu = KvGetGunMenu(kv, "primary", g_PrimaryMenu);
736 g_SecondaryMenu = KvGetGunMenu(kv, "secondary", g_SecondaryMenu);
737 g_AllowBuy = KvGetYesOrNo(kv, "buy", g_AllowBuy);
741 /* Load automatic stuff */
742 if (KvJumpToKey(kv, "AutoItems"))
744 g_ArmorAmount = KvGetNum(kv, "armor", g_ArmorAmount);
745 g_Flashes = KvGetNum(kv, "flashbangs", g_Flashes);
746 g_Helmets = KvGetYesOrNo(kv, "helmet", g_Helmets);
747 g_Smokes = KvGetYesOrNo(kv, "smokegrenade", g_Smokes);
748 g_HEs = KvGetYesOrNo(kv, "hegrenade", g_HEs);
749 g_NightVision = KvGetYesOrNo(kv, "nightvision", g_NightVision);
750 g_DefuseKits = KvGetYesOrNo(kv, "defusekits", g_DefuseKits);
751 g_HealthAmount = KvGetNum(kv, "health", g_HealthAmount);
752 g_Decoy = KvGetYesOrNo(kv, "decoy", g_Decoy);
753 g_Taser = KvGetYesOrNo(kv, "taser", g_Taser);
758 if (KvJumpToKey(kv, "BotItems"))
760 /* Clear out old lists first */
761 g_BotPrimaryCount = 0;
762 g_BotSecondaryCount = 0;
764 if (KvGotoFirstSubKey(kv, false))
768 KvGetSectionName(kv, value, sizeof(value));
769 if (strcmp(value, "weapon") == 0)
771 KvGetString(kv, NULL_STRING, value, sizeof(value));
772 new index = DM_GetWeaponID(value);
775 new DmWeaponType:type = DM_GetWeaponType(index);
776 if (type == DmWeapon_Primary && g_BotPrimaryCount < CSSDM_MAX_WEAPONS)
778 g_BotPrimaryList[g_BotPrimaryCount++] = index;
779 } else if (type == DmWeapon_Secondary && g_BotSecondaryCount < CSSDM_MAX_WEAPONS) {
780 g_BotSecondaryList[g_BotSecondaryCount++] = index;
783 } else if (strcmp(value, "armor") == 0) {
784 g_BotArmor = KvGetNum(kv, NULL_STRING, 100);
785 } else if (strcmp(value, "helmet") == 0) {
786 g_BotHelmets = KvGetYesOrNo(kv, NULL_STRING, true);
787 } else if (strcmp(value, "flashbangs") == 0) {
788 g_BotFlashes = KvGetNum(kv, NULL_STRING);
789 } else if (strcmp(value, "smokegrenade") == 0) {
790 g_BotSmokes = KvGetYesOrNo(kv, NULL_STRING, false);
791 } else if (strcmp(value, "hegrenade") == 0) {
792 g_BotHEs = KvGetYesOrNo(kv, NULL_STRING, false);
793 } else if (strcmp(value, "defusekits") == 0) {
794 g_BotDefuseKits = KvGetYesOrNo(kv, NULL_STRING, true);
795 } else if (strcmp(value, "health") == 0) {
796 g_BotHealthAmount = KvGetNum(kv, NULL_STRING, 100);
797 } else if (strcmp(value, "decoy") == 0) {
798 g_BotDecoy = KvGetYesOrNo(kv, NULL_STRING, false);
799 } else if (strcmp(value, "taser") == 0) {
800 g_BotTaser = KvGetYesOrNo(kv, NULL_STRING, true);
802 } while (KvGotoNextKey(kv, false));
808 /* Load secondary weapons */
809 if (KvJumpToKey(kv, "SecondaryMenu"))
811 /* Clear out old list first */
812 g_SecondaryCount = 0;
814 if (KvGotoFirstSubKey(kv, false))
818 KvGetSectionName(kv, value, sizeof(value));
819 if (strcmp(value, "weapon") == 0)
821 KvGetString(kv, NULL_STRING, value, sizeof(value));
822 new index = DM_GetWeaponID(value);
823 if (index != -1 && DM_GetWeaponType(index) == DmWeapon_Secondary)
825 g_SecondaryList[g_SecondaryCount++] = index;
828 } while (KvGotoNextKey(kv, false) && g_SecondaryCount < CSSDM_MAX_WEAPONS);
834 /* Load primary weapons */
835 if (KvJumpToKey(kv, "PrimaryMenu"))
837 /* Clear out old list first */
840 if (KvGotoFirstSubKey(kv, false))
844 KvGetSectionName(kv, value, sizeof(value));
845 if (strcmp(value, "weapon") == 0)
847 KvGetString(kv, NULL_STRING, value, sizeof(value));
848 new index = DM_GetWeaponID(value);
849 if (index != -1 && DM_GetWeaponType(index) == DmWeapon_Primary)
851 g_PrimaryList[g_PrimaryCount++] = index;
854 } while (KvGotoNextKey(kv, false) && g_PrimaryCount < CSSDM_MAX_WEAPONS);
862 /* Build the primary menu */
863 if (g_hPrimaryMenu != INVALID_HANDLE)
865 CloseHandle(g_hPrimaryMenu);
867 g_hPrimaryMenu = CreateMenu(Menu_PrimaryHandler, MenuAction_DrawItem|MenuAction_Display);
868 SetMenuTitle(g_hPrimaryMenu, "Primary weapon:");
869 for (new i=0; i<g_PrimaryCount; i++)
871 new index = g_PrimaryList[i];
872 DM_GetWeaponName(index, value, sizeof(value));
873 AddMenuItem(g_hPrimaryMenu, "", value);
875 AddMenuItem(g_hPrimaryMenu, "", "Random");
877 /* Build the secondary menu */
878 if (g_hSecondaryMenu != INVALID_HANDLE)
880 CloseHandle(g_hSecondaryMenu);
882 g_hSecondaryMenu = CreateMenu(Menu_SecondaryHandler, MenuAction_DrawItem|MenuAction_Display);
883 SetMenuTitle(g_hSecondaryMenu, "Secondary weapon:");
884 for (new i=0; i<g_SecondaryCount; i++)
886 new index = g_SecondaryList[i];
887 DM_GetWeaponName(index, value, sizeof(value));
888 AddMenuItem(g_hSecondaryMenu, "", value);
890 AddMenuItem(g_hSecondaryMenu, "", "Random");
895 SetClientArmor(client, armor)
897 if (g_ArmorOffset == -1)
902 SetEntData(client, g_ArmorOffset, armor, 4, true);
905 SetClientHealth(client, health)
907 if (g_HealthOffset == -1)
912 SetEntData(client, g_HealthOffset, health, 4, true);
915 GiveGrenades(client, flashnum, bool:he, bool:smoke, bool:decoy)
917 if (!IsPlayerAlive(client))
924 GivePlayerItem(client, "weapon_hegrenade");
926 for (new i=0; i<flashnum; i++)
928 GivePlayerItem(client, "weapon_flashbang");
932 GivePlayerItem(client, "weapon_smokegrenade");
934 if (g_bIsGo && decoy)
936 GivePlayerItem(client, "weapon_decoy");
940 GiveNightVision(client)
942 if (g_NVOffset == -1)
947 SetEntData(client, g_NVOffset, true, 1, true);