|
1 | | -/* CS:GO Weapons&Knives SourceMod Plugin |
| 1 | +/* CS:GO Weapons&Knives SourceMod Plugin |
2 | 2 | * |
3 | | - * Copyright (C) 2017 Kağan 'kgns' Üstüngel |
| 3 | + * Copyright (C) 2017 Kağan 'kgns' Üstüngel |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify it |
6 | 6 | * under the terms of the GNU General Public License as published by the Free |
@@ -63,6 +63,76 @@ public int WeaponsMenuHandler(Menu menu, MenuAction action, int client, int sele |
63 | 63 | Format(display, sizeof(display), "%T", "RandomSkin", client); |
64 | 64 | return RedrawMenuItem(display); |
65 | 65 | } |
| 66 | + else if (StrEqual(info, "-2")) |
| 67 | + { |
| 68 | + Format(display, sizeof(display), "%T", "RandomAllSkin", client); |
| 69 | + return RedrawMenuItem(display); |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | + case MenuAction_Cancel: |
| 74 | + { |
| 75 | + if (IsClientInGame(client) && selection == MenuCancel_ExitBack) |
| 76 | + { |
| 77 | + int menuTime; |
| 78 | + if((menuTime = GetRemainingGracePeriodSeconds(client)) >= 0) |
| 79 | + { |
| 80 | + CreateWeaponMenu(client).Display(client, menuTime); |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | + return 0; |
| 86 | +} |
| 87 | + |
| 88 | +public int WeaponsMenuAllHandler(Menu menu, MenuAction action, int client, int selection) |
| 89 | +{ |
| 90 | + switch(action) |
| 91 | + { |
| 92 | + case MenuAction_Select: |
| 93 | + { |
| 94 | + if(IsClientInGame(client)) |
| 95 | + { |
| 96 | + int index = g_iIndex[client]; |
| 97 | + |
| 98 | + char skinIdStr[32]; |
| 99 | + menu.GetItem(selection, skinIdStr, sizeof(skinIdStr)); |
| 100 | + int skinId = StringToInt(skinIdStr); |
| 101 | + |
| 102 | + g_iSkins[client][index] = skinId; |
| 103 | + char updateFields[256]; |
| 104 | + char weaponName[32]; |
| 105 | + RemoveWeaponPrefix(g_WeaponClasses[index], weaponName, sizeof(weaponName)); |
| 106 | + Format(updateFields, sizeof(updateFields), "%s = %d", weaponName, skinId); |
| 107 | + UpdatePlayerData(client, updateFields); |
| 108 | + |
| 109 | + RefreshWeapon(client, index); |
| 110 | + |
| 111 | + DataPack pack; |
| 112 | + CreateDataTimer(0.5, WeaponsMenuTimer, pack); |
| 113 | + pack.WriteCell(menu); |
| 114 | + pack.WriteCell(GetClientUserId(client)); |
| 115 | + pack.WriteCell(GetMenuSelectionPosition()); |
| 116 | + } |
| 117 | + } |
| 118 | + case MenuAction_DisplayItem: |
| 119 | + { |
| 120 | + if(IsClientInGame(client)) |
| 121 | + { |
| 122 | + char info[32]; |
| 123 | + char display[64]; |
| 124 | + menu.GetItem(selection, info, sizeof(info)); |
| 125 | + |
| 126 | + if (StrEqual(info, "0")) |
| 127 | + { |
| 128 | + Format(display, sizeof(display), "%T", "DefaultSkin", client); |
| 129 | + return RedrawMenuItem(display); |
| 130 | + } |
| 131 | + else if (StrEqual(info, "-2")) |
| 132 | + { |
| 133 | + Format(display, sizeof(display), "%T", "RandomSkin", client); |
| 134 | + return RedrawMenuItem(display); |
| 135 | + } |
66 | 136 | } |
67 | 137 | } |
68 | 138 | case MenuAction_Cancel: |
@@ -115,6 +185,14 @@ public int WeaponMenuHandler(Menu menu, MenuAction action, int client, int selec |
115 | 185 | menuWeapons[g_iClientLanguage[client]][g_iIndex[client]].Display(client, menuTime); |
116 | 186 | } |
117 | 187 | } |
| 188 | + if(StrEqual(buffer, "skinall")) |
| 189 | + { |
| 190 | + int menuTime; |
| 191 | + if((menuTime = GetRemainingGracePeriodSeconds(client)) >= 0) |
| 192 | + { |
| 193 | + menuWeaponsAll[g_iClientLanguage[client]][g_iIndex[client]].Display(client, menuTime); |
| 194 | + } |
| 195 | + } |
118 | 196 | else if(StrEqual(buffer, "float")) |
119 | 197 | { |
120 | 198 | int menuTime; |
@@ -291,7 +369,6 @@ public int FloatMenuHandler(Menu menu, MenuAction action, int client, int select |
291 | 369 |
|
292 | 370 | public Action FloatTimer(Handle timer, DataPack pack) |
293 | 371 | { |
294 | | - |
295 | 372 | ResetPack(pack); |
296 | 373 | int clientIndex = GetClientOfUserId(pack.ReadCell()); |
297 | 374 | int index = pack.ReadCell(); |
@@ -632,6 +709,7 @@ Menu CreateAllWeaponsMenu(int client) |
632 | 709 | char name[32]; |
633 | 710 | for (int i = 0; i < sizeof(g_WeaponClasses); i++) |
634 | 711 | { |
| 712 | + if (!g_bEnableC4 && StrEqual(g_WeaponClasses[i], "weapon_c4")) continue; |
635 | 713 | Format(name, sizeof(name), "%T", g_WeaponClasses[i], client); |
636 | 714 | menu.AddItem(g_WeaponClasses[i], name); |
637 | 715 | } |
@@ -689,6 +767,14 @@ Menu CreateWeaponMenu(int client) |
689 | 767 |
|
690 | 768 | Format(buffer, sizeof(buffer), "%T", "SetSkin", client); |
691 | 769 | menu.AddItem("skin", buffer); |
| 770 | + |
| 771 | + // VIP Access - Thanks to Kento(https://github.com/rogeraabbccdd) |
| 772 | + if(g_bAllSkins){ |
| 773 | + if(CheckCommandAccess (client, "sm_weapons_all_vip", ADMFLAG_RESERVATION, true)){ |
| 774 | + Format(buffer, sizeof(buffer), "%T (%T)", "SetSkin", client, "AllSkins", client); |
| 775 | + menu.AddItem("skinall", buffer); |
| 776 | + } |
| 777 | + } |
692 | 778 |
|
693 | 779 | bool weaponHasSkin = (g_iSkins[client][index] != 0); |
694 | 780 |
|
@@ -797,6 +883,7 @@ Menu CreateMainMenu(int client) |
797 | 883 | int weaponEntity = GetEntPropEnt(client, Prop_Send, "m_hMyWeapons", i); |
798 | 884 | if(weaponEntity != -1 && GetWeaponClass(weaponEntity, weaponClass, sizeof(weaponClass))) |
799 | 885 | { |
| 886 | + if (!g_bEnableC4 && StrEqual(weaponClass, "weapon_c4")) continue; |
800 | 887 | Format(weaponName, sizeof(weaponName), "%T", weaponClass, client); |
801 | 888 | menu.AddItem(weaponClass, weaponName, (IsKnifeClass(weaponClass) && g_iKnife[client] == 0) ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT); |
802 | 889 | } |
|
0 commit comments