· 8 years ago · May 25, 2018, 09:58 PM
1/*
2 * MyJailShop Plugin.
3 * by: shanapu
4 * https://github.com/shanapu/MyJailShop
5 * Based on: https://forums.alliedmods.net/showthread.php?t=247917
6 * Credits to original author: Dkmuniz
7 * Include code by bacardi https:// forums.alliedmods.net/showthread.php?t=269846
8 *
9 * Copyright (C) 2016-2017 Thomas Schmidt (shanapu)
10 *
11 * This program is free software; you can redistribute it and/or modify it under
12 * the terms of the GNU General Public License, version 3.0, as published by the
13 * Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * details.
19 *
20 * You should have received a copy of the GNU General Public License along with
21 * this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24
25/******************************************************************************
26 STARTUP
27******************************************************************************/
28
29
30// Includes
31#include <sourcemod>
32#include <sdktools>
33#include <sdkhooks>
34#include <cstrike>
35#include <clientprefs>
36#include <colors>
37#include <autoexecconfig>
38#include <myjailshop>
39#include <mystocks>
40
41// Optional Plugins
42#undef REQUIRE_PLUGIN
43#include <smartjaildoors>
44#include <myjailbreak>
45#include <CustomPlayerSkins>
46#include <myjbwarden>
47#include <myicons>
48#define REQUIRE_PLUGIN
49
50
51// Compiler Options
52#pragma semicolon 1
53#pragma newdecls required
54
55
56// Defines
57#define VERSION "1.4.1.dev-<COMMIT>"
58#define URL "https://github.com/shanapu/MyJailShop"
59
60
61// Console Variables
62// Shop Settings
63ConVar gc_bEnable;
64ConVar gc_bCreditSystem;
65ConVar gc_iCreditsMax;
66ConVar gc_iCreditsKillCT;
67ConVar gc_iCreditsKillT;
68ConVar gc_bCreditsWinAlive;
69ConVar gc_iCreditsWinCT;
70ConVar gc_iCreditsWinT;
71ConVar gc_iCreditsVIPWinCT;
72ConVar gc_iCreditsVIPWinT;
73ConVar gc_iCreditsLR;
74ConVar gc_iCreditsVIPKillCT;
75ConVar gc_iCreditsVIPKillT;
76ConVar gc_iCreditsVIPLR;
77ConVar gc_bCreditsSave;
78ConVar gc_bOnlyT;
79ConVar gc_bWelcome;
80ConVar gc_bMySQL;
81ConVar gc_bCreditsWarmup;
82ConVar gc_iMinPlayersToGetCredits;
83ConVar gc_fCreditsTimeInterval;
84ConVar gc_iCreditsTime;
85ConVar gc_iCreditsVIPPerTime;
86ConVar gc_fBuyTime;
87ConVar gc_bBuyTimeCells;
88ConVar gc_bEventdays;
89ConVar gc_bNotification;
90ConVar gc_bRemoveWeapon;
91ConVar gc_bClose;
92ConVar gc_bTag;
93ConVar gc_bLogging;
94ConVar gc_bRemoveOnLR;
95ConVar gc_bBuyOnLR;
96ConVar gc_fSale;
97
98// Shop Items
99ConVar gc_iFroggyJumpOnlyTeam;
100ConVar gc_iWallhackOnlyTeam;
101ConVar gc_iGravOnlyTeam;
102ConVar gc_iBhopOnlyTeam;
103ConVar gc_iReviveOnlyTeam;
104ConVar gc_iHealOnlyTeam;
105ConVar gc_iNoDamageOnlyTeam;
106ConVar gc_iHealthExtraOnlyTeam;
107ConVar gc_iInvisible;
108ConVar gc_fInvisibleTime;
109ConVar gc_iAWP;
110ConVar gc_iNoDamage;
111ConVar gc_fNoDamageTime;
112ConVar gc_iOpenCells;
113ConVar gc_iVampire;
114ConVar gc_fVampireSpeed;
115ConVar gc_fVampireDamageMultiplier;
116ConVar gc_iHealth;
117ConVar gc_iHealthExtra;
118ConVar gc_iDeagle;
119ConVar gc_iKnife;
120ConVar gc_iThrowKnifeCount;
121ConVar gc_iHeal;
122ConVar gc_iMolotov;
123ConVar gc_iFakeModel;
124ConVar gc_sModelPathFakeGuard;
125ConVar gc_iPoisonSmoke;
126ConVar gc_iBird;
127ConVar gc_iBirdMode;
128ConVar gc_iTeleportSmoke;
129ConVar gc_iRevive;
130ConVar gc_iFireHE;
131ConVar gc_iBhop;
132ConVar gc_iGravity;
133ConVar gc_fGravValue;
134ConVar gc_iTaser;
135ConVar gc_iNoClip;
136ConVar gc_bNoClipKill;
137ConVar gc_fNoClipTime;
138ConVar gc_iThrowKnife;
139ConVar gc_iWallhack;
140ConVar gc_fWallhackTime;
141ConVar gc_iFroggyJump;
142ConVar gc_iPaperClip;
143ConVar gc_iPaperClipAmount;
144ConVar gc_iRandomTP;
145
146ConVar gc_sInvisibleFlag;
147ConVar gc_sAWPFlag;
148ConVar gc_sNoDamageFlag;
149ConVar gc_sOpenCellsFlag;
150ConVar gc_sVampireFlag;
151ConVar gc_sHealthFlag;
152ConVar gc_sDeagleFlag;
153ConVar gc_sKnifeFlag;
154ConVar gc_sHealFlag;
155ConVar gc_sMolotovFlag;
156ConVar gc_sFakeModelFlag;
157ConVar gc_sPoisonSmokeFlag;
158ConVar gc_sBirdFlag;
159ConVar gc_sTeleportSmokeFlag;
160ConVar gc_sReviveFlag;
161ConVar gc_sFireHEFlag;
162ConVar gc_sBhopFlag;
163ConVar gc_sGravityFlag;
164ConVar gc_sTaserFlag;
165ConVar gc_sNoClipFlag;
166ConVar gc_sThrowKnifeFlag;
167ConVar gc_sWallhackFlag;
168ConVar gc_sFroggyJumpFlag;
169ConVar gc_sPaperClipFlag;
170ConVar gc_sRandomTPFlag;
171
172// Custom Commands
173ConVar gc_sCustomCommandShop;
174ConVar gc_sCustomCommandGift;
175ConVar gc_sCustomCommandRevive;
176ConVar gc_sCustomCommandCredits;
177ConVar gc_sCustomCommandMassCredits;
178
179// Extern Plugins
180ConVar g_bHandcuff;
181
182
183// Booleans
184bool g_bInvisible[MAXPLAYERS+1] = false;
185bool g_bFly[MAXPLAYERS+1] = false;
186bool g_bFakeGuard[MAXPLAYERS+1] = false;
187bool g_bNoDamage[MAXPLAYERS+1] = false;
188bool g_bPoison[MAXPLAYERS+1] = false;
189bool g_bVampire[MAXPLAYERS+1] = false;
190bool g_bSuperKnife[MAXPLAYERS+1] = false;
191bool g_bTeleportSmoke[MAXPLAYERS+1] = false;
192bool g_bFireHE[MAXPLAYERS+1] = false;
193bool g_bOneBulletAWP[MAXPLAYERS+1] = false;
194bool g_bOneMagDeagle[MAXPLAYERS+1] = false;
195bool g_bBhop[MAXPLAYERS+1] = false;
196bool g_bMolotov[MAXPLAYERS+1] = false;
197bool g_bHealth[MAXPLAYERS+1] = false;
198bool g_bWallhack[MAXPLAYERS+1] = false;
199bool g_bFroggyJump[MAXPLAYERS+1] = false;
200bool g_bNoClip[MAXPLAYERS+1] = true;
201bool g_bThrowingKnife[MAXPLAYERS+1] = true;
202bool g_bGravity[MAXPLAYERS+1] = false;
203bool g_bRandomTP[MAXPLAYERS+1] = false;
204bool g_bLadder[MAXPLAYERS+1] = false;
205bool g_bDBConnected = false;
206bool g_bAllowBuy = true;
207bool g_bCellsOpen = true;
208bool g_bIsLR = true;
209bool g_bSale = false;
210
211bool gp_bSmartJailDoors = false;
212bool gp_bMyJailBreak = false;
213bool gp_bCustomPlayerSkins = false;
214bool gp_bMyJBWarden = false;
215bool gp_bMyIcons = false;
216
217
218// Intergers
219int g_iBeamSprite = -1;
220int g_iHaloSprite = -1;
221int g_iCredits[MAXPLAYERS+1];
222int g_iFroggyJumped[MAXPLAYERS + 1];
223int g_iKnifesThrown[MAXPLAYERS + 1] = 0;
224
225
226// Handles
227Handle g_hTimerCredits;
228Handle g_hCookieCredits = INVALID_HANDLE;
229Handle g_hDB = INVALID_HANDLE;
230Handle gF_hOnPlayerGetCredits;
231Handle gF_hOnPlayerBuyItem;
232Handle g_hTimerDelay[MAXPLAYERS+1];
233Handle g_hThrownKnives;
234
235Handle gF_hOnGetCredits;
236Handle gF_hOnSetCredits;
237
238Handle gF_hOnShopMenu;
239Handle gF_hOnShopMenuHandler;
240
241Handle gF_hOnResetPlayer;
242
243
244// Strings
245char g_sSQLBuffer[1024];
246char g_sModelPathPrevious[MAXPLAYERS+1][256];
247char g_sModelPathFakeGuard[256];
248char g_sPurchaseLogFile[PLATFORM_MAX_PATH];
249char g_sGiftLogFile[PLATFORM_MAX_PATH];
250char g_sInvisibleFlag[64];
251char g_sAWPFlag[64];
252char g_sNoDamageFlag[64];
253char g_sOpenCellsFlag[64];
254char g_sVampireFlag[64];
255char g_sHealthFlag[64];
256char g_sDeagleFlag[64];
257char g_sKnifeFlag[64];
258char g_sHealFlag[64];
259char g_sMolotovFlag[64];
260char g_sFakeModelFlag[64];
261char g_sPoisonSmokeFlag[64];
262char g_sBirdFlag[64];
263char g_sTeleportSmokeFlag[64];
264char g_sReviveFlag[64];
265char g_sFireHEFlag[64];
266char g_sBhopFlag[64];
267char g_sGravityFlag[64];
268char g_sTaserFlag[64];
269char g_sNoClipFlag[64];
270char g_sThrowKnifeFlag[64];
271char g_sWallhackFlag[64];
272char g_sFroggyJumpFlag[64];
273char g_sPaperClipFlag[64];
274char g_sRandomTPFlag[64];
275
276
277// Info
278public Plugin myinfo = {
279 name = "MyJailShop",
280 author = "shanapu",
281 description = "MyJailShop provide you a high customizable shop with credits system intended for jailbreak server",
282 version = VERSION,
283 url = URL
284};
285
286
287// Start
288public void OnPluginStart()
289{
290 // Translation
291 LoadTranslations("common.phrases");
292 LoadTranslations("MyJailShop.phrases");
293 g_hCookieCredits = RegClientCookie("Credits", "Credits", CookieAccess_Private);
294
295
296 // Client Commands
297 RegConsoleCmd("sm_jailshop", Command_Menu_OpenShop, "Open the jail shop menu");
298 RegConsoleCmd("sm_jailcredits", Commands_Credits, "Show your jail shop credits");
299 RegConsoleCmd("sm_jailgift", Command_SendCredits, "Gift jail credits to a player - Use: sm_jailgift <#userid|name> [amount]");
300 RegConsoleCmd("sm_revive", Command_Revive, "Use shop item revive");
301 RegConsoleCmd("sm_showjailcredits", Command_ShowCredits, "Show jail credits of all online player");
302 RegConsoleCmd("drop", Command_ToggleFly, "Change the flymode 'be a bird'-item");
303
304
305 // Admin Commands
306 RegAdminCmd("sm_sale", AdminCommand_Sale, ADMFLAG_ROOT, "Happy Hour");
307 RegAdminCmd("sm_jailgive", AdminCommand_GiveCredits, ADMFLAG_ROOT, "Give jail shop credits to a player - Use: sm_jailgive <#userid|name> [amount]");
308 RegAdminCmd("sm_jailset", AdminCommand_SetCredits, ADMFLAG_ROOT, "Set jail shop credits of a player - Use: sm_jailset <#userid|name> [amount]");
309
310
311 // AutoExecConfig
312 DirExistsEx("cfg/MyJailShop");
313
314 AutoExecConfig_SetFile("Settings", "MyJailShop");
315 AutoExecConfig_SetCreateFile(true);
316
317 AutoExecConfig_CreateConVar("sm_jailshop_version", VERSION, "The version of this MyJailShop SourceMod plugin", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
318 gc_bEnable = AutoExecConfig_CreateConVar("sm_jailshop_enable", "1", "0 - disabled, 1 - enable the MyJailShop SourceMod plugin", _, true, 0.0, true, 1.0);
319
320 gc_bCreditSystem = AutoExecConfig_CreateConVar("sm_jailshop_credits_system", "1", "1 - MyJailShop Credits, 0 - Zephrus store or 'SM Store' or FrozDark shop (need extra support plugin)", _, true, 0.0, true, 1.0);
321 gc_bCreditsSave = AutoExecConfig_CreateConVar("sm_jailshop_credits_save", "1", "0 - disabled, 1 - Save credits on player disconnect", _, true, 0.0, true, 1.0);
322 gc_bMySQL = AutoExecConfig_CreateConVar("sm_jailshop_mysql", "0", "0 - disabled, 1 - Should we use a mysql database to store credits", _, true, 0.0, true, 1.0);
323 gc_iCreditsMax = AutoExecConfig_CreateConVar("sm_jailshop_credits_max", "50000", "Maximum of credits to earn for a player");
324 gc_iMinPlayersToGetCredits = AutoExecConfig_CreateConVar("sm_jailshop_minplayers", "4", "Minimum players to earn credits", _, true, 0.0);
325 gc_bCreditsWarmup = AutoExecConfig_CreateConVar("sm_jailshop_warmupcredits", "1", "0 - disabled, 1 - enable players get credits on warmup", _, true, 0.0, true, 1.0);
326
327 gc_iCreditsKillT = AutoExecConfig_CreateConVar("sm_jailshop_credits_kill_t", "150", "0 - disabled, amount of credits a prisoner earns when kill a Guard", _, true, 0.0);
328 gc_iCreditsVIPKillT = AutoExecConfig_CreateConVar("sm_jailshop_credits_kill_t_vip", "200", "0 - disabled, amount of credits a VIP prisoner earns when kill a Guard", _, true, 0.0);
329 gc_iCreditsKillCT = AutoExecConfig_CreateConVar("sm_jailshop_credits_kill_ct", "15", "0 - disabled, amount of credits a guard earns when kill a prisoner", _, true, 0.0);
330 gc_iCreditsVIPKillCT = AutoExecConfig_CreateConVar("sm_jailshop_credits_kill_ct_vip", "20", "0 - disabled, amount of credits a VIP guard earns when kill a prisoner", _, true, 0.0);
331
332 gc_iCreditsWinT = AutoExecConfig_CreateConVar("sm_jailshop_credits_win_t", "50", "0 - disabled, amount of credits a prisoner earns when win round", _, true, 0.0);
333 gc_iCreditsVIPWinT = AutoExecConfig_CreateConVar("sm_jailshop_credits_win_t_vip", "100", "0 - disabled, amount of credits a VIP prisoner earns when win round", _, true, 0.0);
334 gc_iCreditsWinCT = AutoExecConfig_CreateConVar("sm_jailshop_credits_win_ct", "50", "0 - disabled, amount of credits a guard earns when win round", _, true, 0.0);
335 gc_iCreditsVIPWinCT = AutoExecConfig_CreateConVar("sm_jailshop_credits_win_ct_vip", "100", "0 - disabled, amount of credits a VIP guard earns when win round", _, true, 0.0);
336 gc_bCreditsWinAlive = AutoExecConfig_CreateConVar("sm_jailshop_credits_win_alive", "1", "0 - disabled, 1 - only alive player get credits when team win the round", _, true, 0.0, true, 1.0);
337
338 gc_iCreditsLR = AutoExecConfig_CreateConVar("sm_jailshop_credits_lr", "300", "0 - disabled, amount of credits for reach last request as prisoner (only if hosties is available)", _, true, 0.0);
339 gc_iCreditsVIPLR = AutoExecConfig_CreateConVar("sm_jailshop_credits_lr_vip", "400", "0 - disabled, amount of credits for reach last request as prisoner (only if hosties is available)", _, true, 0.0);
340
341 gc_iCreditsTime = AutoExecConfig_CreateConVar("sm_jailshop_credits_per_time", "5", "0 - disabled, how many credits players receive every x seconds 'sm_jailshop_credits_time_interval'", _, true, 0.0);
342 gc_fCreditsTimeInterval = AutoExecConfig_CreateConVar("sm_jailshop_credits_per_time_interval", "120", "Time in seconds a player recieved credits per time", _, true, 0.0);
343 gc_iCreditsVIPPerTime = AutoExecConfig_CreateConVar("sm_jailshop_credits_per_time_vip", "10", "0 - disabled, how many credits VIP players receive for 'sm_jailshop_credits_time_interval", _, true, 0.0);
344
345 gc_bWelcome = AutoExecConfig_CreateConVar("sm_jailshop_welcome", "1", "0 - disabled, 1 - welcome messages on spawn", _, true, 0.0, true, 1.0);
346 gc_bNotification = AutoExecConfig_CreateConVar("sm_jailshop_notification", "1", "0 - disabled, 1 - enable chat notification everytime player get credits", _, true, 0.0, true, 1.0);
347 gc_fBuyTime = AutoExecConfig_CreateConVar("sm_jailshop_buytime", "180", "0 - disabled, Time in seconds after roundstart shopping is allowed", _, true, 0.0);
348 gc_bBuyTimeCells = AutoExecConfig_CreateConVar("sm_jailshop_buytime_cells", "0", "0 - disabled, 1 - only shopping until cell doors opened (only if smartjaildoors is available)", _, true, 0.0, true, 1.0);
349 gc_bBuyOnLR = AutoExecConfig_CreateConVar("sm_jailshop_buy_lr", "1", "0 - disabled, 1 - restrict shopping on Last lequest", _, true, 0.0, true, 1.0);
350 gc_bRemoveOnLR = AutoExecConfig_CreateConVar("sm_jailshop_remove_lr", "1", "Remove the bought perks on a last request. (bought weapons will stay)", _, true, 0.0, true, 1.0);
351 gc_bOnlyT = AutoExecConfig_CreateConVar("sm_jailshop_access", "0", "0 - shop available for guards & prisoner, 1 - only prisoner", _, true, 0.0, true, 1.0);
352 gc_bEventdays = AutoExecConfig_CreateConVar("sm_jailshop_myjb", "1", "0 - disable shopping on MyJailbreak Event Days, 1 - enable shopping on MyJailbreak Event Days (only if myjb is available)(show/gift/... credits is still enabled)", _, true, 0.0, true, 1.0);
353 gc_bRemoveWeapon = AutoExecConfig_CreateConVar("sm_jailshop_removeweapon", "1", "0 - disabled, 1 - When a player already got a prim/sec weapon and buy deagle or awp the current weapon disappear", _, true, 0.0, true, 1.0);
354 gc_bClose = AutoExecConfig_CreateConVar("sm_jailshop_close", "1", "0 - disabled, 1 - enable close menu after action", _, true, 0.0, true, 1.0);
355 gc_bTag = AutoExecConfig_CreateConVar("sm_jailshop_tag", "1", "Allow \"MyJailShop\" to be added to the server tags? So player will find servers with MyJailShop faster. it dont touch you sv_tags", _, true, 0.0, true, 1.0);
356 gc_bLogging = AutoExecConfig_CreateConVar("sm_jailshop_log", "1", "Allow MyJailShop to log purchases and gifts in logs/MyJailShop", _, true, 0.0, true, 1.0);
357
358 gc_sCustomCommandShop = AutoExecConfig_CreateConVar("sm_jailshop_cmds_shop", "jbshop,jbstore,jailstore", "Set your custom chat commands for shop menu(!jailshop (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands)");
359 gc_sCustomCommandGift = AutoExecConfig_CreateConVar("sm_jailshop_cmds_gift", "jbgift,send", "Set your custom chat commands for gifting credits(!jailgift (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands)");
360 gc_sCustomCommandRevive = AutoExecConfig_CreateConVar("sm_jailshop_cmds_revive", "revive,jbrevive,alive", "Set your custom chat commands for revive(!jailrevive (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands)");
361 gc_sCustomCommandCredits = AutoExecConfig_CreateConVar("sm_jailshop_cmds_credits", "points,credits", "Set your custom chat commands to see you credits (!jailcredits (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands)");
362 gc_sCustomCommandMassCredits = AutoExecConfig_CreateConVar("sm_jailshop_cmds_showcredits", "showpoints,allcredits,showcredits", "Set your custom chat commands for see all online players credits(!showjailcredits (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands)");
363
364 gc_fSale = AutoExecConfig_CreateConVar("sm_jailshop_sale_multi", "40", "How many percent discount on a sale!", _, true, 1.0, true, 100.0);
365
366 AutoExecConfig_ExecuteFile();
367 AutoExecConfig_CleanFile();
368
369 AutoExecConfig_SetFile("Items", "MyJailShop");
370 AutoExecConfig_SetCreateFile(true);
371
372 // Items
373 gc_iOpenCells = AutoExecConfig_CreateConVar("sm_jailshop_openjails_price", "800", "0 - disabled, price of the 'Open jails' shop item", _, true, 0.0);
374 gc_sOpenCellsFlag = AutoExecConfig_CreateConVar("sm_jailshop_openjails_flag", "", "Set flag for admin/vip must have to get access to open cells. No flag = is available for all players!");
375 gc_iHeal = AutoExecConfig_CreateConVar("sm_jailshop_heal_price", "250", "0 - disabled, price of the 'Heal' shop item", _, true, 0.0);
376 gc_iHealOnlyTeam = AutoExecConfig_CreateConVar("sm_jailshop_heal_access", "1", "0 - guards only, 1 - guards & prisoner, 2 - prisoner only ", _, true, 0.0, true, 2.0);
377 gc_sHealFlag = AutoExecConfig_CreateConVar("sm_jailshop_heal_flag", "", "Set flag for admin/vip must have to get access to heal. No flag = is available for all players!");
378 gc_iHealth = AutoExecConfig_CreateConVar("sm_jailshop_armor_hp_price", "1500", "0 - disabled, price of the 'Armor & HP' shop item", _, true, 0.0);
379 gc_iHealthExtra = AutoExecConfig_CreateConVar("sm_jailshop_health_extra", "150", "How many HP get extra with the armor", _, true, 0.0);
380 gc_iHealthExtraOnlyTeam = AutoExecConfig_CreateConVar("sm_jailshop_health_extra_access", "1", "0 - guards only, 1 - guards & prisoner, 2 - prisoner only", _, true, 0.0, true, 2.0);
381 gc_sHealthFlag = AutoExecConfig_CreateConVar("sm_jailshop_health_flag", "", "Set flag for admin/vip must have to get access to health. No flag = is available for all players!");
382 gc_iRevive = AutoExecConfig_CreateConVar("sm_jailshop_revive_price", "8000", "0 - disabled, price of the 'Revive' shop item", _, true, 0.0);
383 gc_iReviveOnlyTeam = AutoExecConfig_CreateConVar("sm_jailshop_revive_access", "1", "0 - guards only, 1 - guards & prisoner, 2 - prisoner only ", _, true, 0.0, true, 2.0);
384 gc_sReviveFlag = AutoExecConfig_CreateConVar("sm_jailshop_revive_flag", "", "Set flag for admin/vip must have to get access to revive. No flag = is available for all players!");
385 gc_iVampire = AutoExecConfig_CreateConVar("sm_jailshop_vampire_price", "4000", "0 - disabled, price of the 'Vampire' shop item", _, true, 0.0);
386 gc_fVampireSpeed = AutoExecConfig_CreateConVar("sm_jailshop_vampire_speed", "1.5", "Ratio for how fast the player will walk (1 - normal)", _, true, 0.5);
387 gc_fVampireDamageMultiplier = AutoExecConfig_CreateConVar("sm_jailshop_vampire_multiplier", "0.5", "Multiplier how many heatlh per damage (e.g. 100damage * 0.5 = 50HP extra)", _, true, 1.0);
388 gc_sVampireFlag = AutoExecConfig_CreateConVar("sm_jailshop_vampire_flag", "", "Set flag for admin/vip must have to get access to vampire. No flag = is available for all players!");
389 gc_iBhop = AutoExecConfig_CreateConVar("sm_jailshop_bhop_price", "5000", "0 - disabled, price of the 'Bunny Hop' shop item", _, true, 0.0);
390 gc_iBhopOnlyTeam = AutoExecConfig_CreateConVar("sm_jailshop_bhop_access", "1", "0 - guards only, 1 - guards & prisoner, 2 - prisoner only ", _, true, 0.0, true, 2.0);
391 gc_sBhopFlag = AutoExecConfig_CreateConVar("sm_jailshop_bhop_flag", "", "Set flag for admin/vip must have to get access to bhop. No flag = is available for all players!");
392 gc_iFroggyJump = AutoExecConfig_CreateConVar("sm_jailshop_froggyjump_price", "4000", "0 - disabled, price of the 'Froggy Jump' shop item", _, true, 0.0);
393 gc_iFroggyJumpOnlyTeam = AutoExecConfig_CreateConVar("sm_jailshop_froggyjump_access", "1", "0 - guards only, 1 - guards & prisoner, 2 - prisoner only ", _, true, 0.0, true, 2.0);
394 gc_sFroggyJumpFlag = AutoExecConfig_CreateConVar("sm_jailshop_froggyjump_flag", "", "Set flag for admin/vip must have to get access to froggyjump. No flag = is available for all players!");
395 gc_iGravity = AutoExecConfig_CreateConVar("sm_jailshop_gravity_price", "2500", "0 - disabled, price of the 'Low Gravity' shop item", _, true, 0.0);
396 gc_fGravValue = AutoExecConfig_CreateConVar("sm_jailshop_gravity_value", "0.6", "Ratio for Gravity (1.0 earth, 0.5 moon)", _, true, 0.1, true, 1.0);
397 gc_iGravOnlyTeam = AutoExecConfig_CreateConVar("sm_jailshop_gravity_access", "1", "0 - guards only, 1 - guards & prisoner, 2 - prisoner only ", _, true, 0.0, true, 2.0);
398 gc_sGravityFlag = AutoExecConfig_CreateConVar("sm_jailshop_gravity_flag", "", "Set flag for admin/vip must have to get access to gravity. No flag = is available for all players!");
399 gc_iInvisible = AutoExecConfig_CreateConVar("sm_jailshop_invisible_price", "8000", "0 - disabled, price of the 'Invisible' shop item", _, true, 0.0);
400 gc_fInvisibleTime = AutoExecConfig_CreateConVar("sm_jailshop_invisible_time", "10.0", "Time in seconds how long the player is invisible", _, true, 1.0);
401 gc_sInvisibleFlag = AutoExecConfig_CreateConVar("sm_jailshop_invisible_flag", "", "Set flag for admin/vip must have to get access to invisible. No flag = is available for all players!");
402 gc_iPaperClip = AutoExecConfig_CreateConVar("sm_jailshop_paperclip_price", "500", "0 - disabled, price of the 'PaperClips' shop item (only if myjb is available)", _, true, 0.0);
403 gc_iPaperClipAmount = AutoExecConfig_CreateConVar("sm_jailshop_paperclip_amount", "2", "Amount of paperclips a player get (only if myjb is available)", _, true, 1.0);
404 gc_sPaperClipFlag = AutoExecConfig_CreateConVar("sm_jailshop_paperclip_flag", "", "Set flag for admin/vip must have to get access to paperclip. No flag = is available for all players!");
405 gc_iNoDamage = AutoExecConfig_CreateConVar("sm_jailshop_nodamage_price", "1500", "0 - disabled, price of the 'NoDamage' shop item", _, true, 0.0);
406 gc_fNoDamageTime = AutoExecConfig_CreateConVar("sm_jailshop_nodamage_time", "20.0", "Time in seconds how long the player got nodamage", _, true, 1.0);
407 gc_iNoDamageOnlyTeam = AutoExecConfig_CreateConVar("sm_jailshop_nodamage_access", "1", "0 - guards only, 1 - guards & prisoner, 2 - prisoner only", _, true, 0.0, true, 2.0);
408 gc_sNoDamageFlag = AutoExecConfig_CreateConVar("sm_jailshop_nodamage_flag", "", "Set flag for admin/vip must have to get access to damage. No flag = is available for all players!");
409 gc_iNoClip = AutoExecConfig_CreateConVar("sm_jailshop_noclip_price", "9000", "0 - disabled, price of the 'No Clip' shop item", _, true, 0.0);
410 gc_fNoClipTime = AutoExecConfig_CreateConVar("sm_jailshop_noclip_time", "5.0", "Time in seconds how long the player has noclip", _, true, 1.0);
411 gc_sNoClipFlag = AutoExecConfig_CreateConVar("sm_jailshop_noclip_flag", "", "Set flag for admin/vip must have to get access to noclip. No flag = is available for all players!");
412 gc_bNoClipKill = AutoExecConfig_CreateConVar("sm_jailshop_noclip_stuck", "1", "0 - disabled / 1 - kill player when stuck after noclip", _, true, 0.0, true, 1.0);
413 gc_iWallhack = AutoExecConfig_CreateConVar("sm_jailshop_wallhack_price", "25000", "0 - disabled, price of the 'Wallhack' shop item (only if CustomPlayerSkins is available)", _, true, 0.0);
414 gc_fWallhackTime = AutoExecConfig_CreateConVar("sm_jailshop_wallhack_time", "10.0", "Time in seconds how long the player has wallhack", _, true, 1.0);
415 gc_iWallhackOnlyTeam = AutoExecConfig_CreateConVar("sm_jailshop_wallhack_access", "1", "0 - guards only, 1 - guards & prisoner, 2 - prisoner only", _, true, 0.0, true, 2.0);
416 gc_sWallhackFlag = AutoExecConfig_CreateConVar("sm_jailshop_wallhack_flag", "", "Set flag for admin/vip must have to get access to wallhack. No flag = is available for all players!");
417 gc_iBird = AutoExecConfig_CreateConVar("sm_jailshop_bird_price", "1500", "0 - disabled, price of the 'Be a Bird' shop item", _, true, 0.0);
418 gc_iBirdMode = AutoExecConfig_CreateConVar("sm_jailshop_bird_mode", "1", "1 - Chicken / 2 - Pigeon / 3 - Crow", _, true, 1.0, true, 3.0);
419 gc_sBirdFlag = AutoExecConfig_CreateConVar("sm_jailshop_bird_flag", "", "Set flag for admin/vip must have to get access to bird. No flag = is available for all players!");
420 gc_iFakeModel = AutoExecConfig_CreateConVar("sm_jailshop_fakeguard_price", "9000", "0 - disabled, price of the 'Fake guard model' shop item", _, true, 0.0);
421 gc_sModelPathFakeGuard = AutoExecConfig_CreateConVar("sm_jailshop_fakeguard_model", "models/player/ctm_gign_variantc.mdl", "Path to the model for fake guard.");
422 gc_sFakeModelFlag = AutoExecConfig_CreateConVar("sm_jailshop_fakeguard_flag", "", "Set flag for admin/vip must have to get access to fake model. No flag = is available for all players!");
423 gc_iTeleportSmoke = AutoExecConfig_CreateConVar("sm_jailshop_teleportsmoke_price", "7000", "0 - disabled, price of the 'Teleport smoke' shop item", _, true, 0.0);
424 gc_sTeleportSmokeFlag = AutoExecConfig_CreateConVar("sm_jailshop_teleportsmoke_flag", "", "Set flag for admin/vip must have to get access to teleport smoke. No flag = is available for all players!");
425 gc_iPoisonSmoke = AutoExecConfig_CreateConVar("sm_jailshop_poisonsmoke_price", "2500", "0 - disabled, price of the 'Poison smoke' shop item", _, true, 0.0);
426 gc_sPoisonSmokeFlag = AutoExecConfig_CreateConVar("sm_jailshop_poisonsmoke_flag", "", "Set flag for admin/vip must have to get access to Poison Smoke. No flag = is available for all players!");
427 gc_iFireHE = AutoExecConfig_CreateConVar("sm_jailshop_firehe_price", "3000", "0 - disabled, price of the 'Fire Grenade' shop item", _, true, 0.0);
428 gc_sFireHEFlag = AutoExecConfig_CreateConVar("sm_jailshop_firehe_flag", "", "Set flag for admin/vip must have to get access to firehe. No flag = is available for all players!");
429 gc_iAWP = AutoExecConfig_CreateConVar("sm_jailshop_awp_price", "8000", "0 - disabled, price of the 'One bullet AWP' shop item", _, true, 0.0);
430 gc_sAWPFlag = AutoExecConfig_CreateConVar("sm_jailshop_awp_flag", "", "Set flag for admin/vip must have to get access to awp. No flag = is available for all players!");
431 gc_iDeagle = AutoExecConfig_CreateConVar("sm_jailshop_deagle_price", "10000", "0 - disabled, price of the '7 bullets Deagle' shop item", _, true, 0.0);
432 gc_sDeagleFlag = AutoExecConfig_CreateConVar("sm_jailshop_deagle_flag", "", "Set flag for admin/vip must have to get access to deagle. No flag = is available for all players!");
433 gc_iKnife = AutoExecConfig_CreateConVar("sm_jailshop_knife_price", "4000", "0 - disabled, price of the 'One hit knife' shop item", _, true, 0.0);
434 gc_sKnifeFlag = AutoExecConfig_CreateConVar("sm_jailshop_knife_flag", "", "Set flag for admin/vip must have to get access to knife. No flag = is available for all players!");
435 gc_iThrowKnife = AutoExecConfig_CreateConVar("sm_jailshop_throw_knife_price", "12000", "0 - disabled, price of the 'Throwing one hit knife' shop item", _, true, 0.0);
436 gc_iThrowKnifeCount = AutoExecConfig_CreateConVar("sm_jailshop_throw_knife_count", "2", "how many knifes a prisoner can throw", _, true, 1.0);
437 gc_sThrowKnifeFlag = AutoExecConfig_CreateConVar("sm_jailshop_throw_knife_flag", "", "Set flag for admin/vip must have to get access to throw knife. No flag = is available for all players!");
438 gc_iTaser = AutoExecConfig_CreateConVar("sm_jailshop_taser_price", "6000", "0 - disabled, price of the '3 bullets Taser' shop item", _, true, 0.0);
439 gc_sTaserFlag = AutoExecConfig_CreateConVar("sm_jailshop_taser_flag", "", "Set flag for admin/vip must have to get access to taser. No flag = is available for all players!");
440 gc_iMolotov = AutoExecConfig_CreateConVar("sm_jailshop_molotov_price", "2500", "0 - disabled, price of the 'Molotov & flashs' shop item", _, true, 0.0);
441 gc_sMolotovFlag = AutoExecConfig_CreateConVar("sm_jailshop_molotov_flag", "", "Set flag for admin/vip must have to get access to molotov. No flag = is available for all players!");
442 gc_iRandomTP = AutoExecConfig_CreateConVar("sm_jailshop_randomtp", "6500", "0 - disable, price of the 'Random teleport' shop item", _, true, 0.0);
443 gc_sRandomTPFlag = AutoExecConfig_CreateConVar("sm_jailshop_randomtp_flag", "", "Set flag for admin/vip must have to get accesso to RandomTP. No flag = is avaible for all players!");
444
445
446 AutoExecConfig_ExecuteFile();
447 AutoExecConfig_CleanFile();
448
449
450 // Hooks
451 HookEvent("player_death", Event_PlayerDeath);
452 HookEvent("smokegrenade_detonate", Event_SmokeGrenadeDetonate, EventHookMode_Post);
453 HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Pre);
454 HookEvent("round_end", Event_RoundEnd);
455 HookEvent("round_start", Event_RoundStart);
456 HookEvent("player_disconnect", Event_PlayerDisconnect, EventHookMode_Pre);
457 HookEvent("weapon_fire", Event_WeaponFire);
458 HookConVarChange(gc_sModelPathFakeGuard, OnSettingChanged);
459 HookConVarChange(gc_sInvisibleFlag, OnSettingChanged);
460 HookConVarChange(gc_sAWPFlag, OnSettingChanged);
461 HookConVarChange(gc_sNoDamageFlag, OnSettingChanged);
462 HookConVarChange(gc_sOpenCellsFlag, OnSettingChanged);
463 HookConVarChange(gc_sVampireFlag, OnSettingChanged);
464 HookConVarChange(gc_sHealthFlag, OnSettingChanged);
465 HookConVarChange(gc_sDeagleFlag, OnSettingChanged);
466 HookConVarChange(gc_sKnifeFlag, OnSettingChanged);
467 HookConVarChange(gc_sHealFlag, OnSettingChanged);
468 HookConVarChange(gc_sMolotovFlag, OnSettingChanged);
469 HookConVarChange(gc_sFakeModelFlag, OnSettingChanged);
470 HookConVarChange(gc_sPoisonSmokeFlag, OnSettingChanged);
471 HookConVarChange(gc_sBirdFlag, OnSettingChanged);
472 HookConVarChange(gc_sTeleportSmokeFlag, OnSettingChanged);
473 HookConVarChange(gc_sReviveFlag, OnSettingChanged);
474 HookConVarChange(gc_sFireHEFlag, OnSettingChanged);
475 HookConVarChange(gc_sBhopFlag, OnSettingChanged);
476 HookConVarChange(gc_sGravityFlag, OnSettingChanged);
477 HookConVarChange(gc_sTaserFlag, OnSettingChanged);
478 HookConVarChange(gc_sNoClipFlag, OnSettingChanged);
479 HookConVarChange(gc_sThrowKnifeFlag, OnSettingChanged);
480 HookConVarChange(gc_sWallhackFlag, OnSettingChanged);
481 HookConVarChange(gc_sFroggyJumpFlag, OnSettingChanged);
482 HookConVarChange(gc_sPaperClipFlag, OnSettingChanged);
483 HookConVarChange(gc_sRandomTPFlag, OnSettingChanged);
484
485
486 // FindConVar
487 gc_sModelPathFakeGuard.GetString(g_sModelPathFakeGuard, sizeof(g_sModelPathFakeGuard));
488 gc_sInvisibleFlag.GetString(g_sInvisibleFlag, sizeof(g_sInvisibleFlag));
489 gc_sAWPFlag.GetString(g_sAWPFlag, sizeof(g_sAWPFlag));
490 gc_sNoDamageFlag.GetString(g_sNoDamageFlag, sizeof(g_sNoDamageFlag));
491 gc_sOpenCellsFlag.GetString(g_sOpenCellsFlag, sizeof(g_sOpenCellsFlag));
492 gc_sVampireFlag.GetString(g_sVampireFlag, sizeof(g_sVampireFlag));
493 gc_sHealthFlag.GetString(g_sHealthFlag, sizeof(g_sHealthFlag));
494 gc_sDeagleFlag.GetString(g_sDeagleFlag, sizeof(g_sDeagleFlag));
495 gc_sKnifeFlag.GetString(g_sKnifeFlag, sizeof(g_sKnifeFlag));
496 gc_sHealFlag.GetString(g_sHealFlag, sizeof(g_sHealFlag));
497 gc_sMolotovFlag.GetString(g_sMolotovFlag, sizeof(g_sMolotovFlag));
498 gc_sFakeModelFlag.GetString(g_sFakeModelFlag, sizeof(g_sFakeModelFlag));
499 gc_sPoisonSmokeFlag.GetString(g_sPoisonSmokeFlag, sizeof(g_sPoisonSmokeFlag));
500 gc_sBirdFlag.GetString(g_sBirdFlag, sizeof(g_sBirdFlag));
501 gc_sTeleportSmokeFlag.GetString(g_sTeleportSmokeFlag, sizeof(g_sTeleportSmokeFlag));
502 gc_sReviveFlag.GetString(g_sReviveFlag, sizeof(g_sReviveFlag));
503 gc_sFireHEFlag.GetString(g_sFireHEFlag, sizeof(g_sFireHEFlag));
504 gc_sBhopFlag.GetString(g_sBhopFlag, sizeof(g_sBhopFlag));
505 gc_sGravityFlag.GetString(g_sGravityFlag, sizeof(g_sGravityFlag));
506 gc_sTaserFlag.GetString(g_sTaserFlag, sizeof(g_sTaserFlag));
507 gc_sNoClipFlag.GetString(g_sNoClipFlag, sizeof(g_sNoClipFlag));
508 gc_sThrowKnifeFlag.GetString(g_sThrowKnifeFlag, sizeof(g_sThrowKnifeFlag));
509 gc_sWallhackFlag.GetString(g_sWallhackFlag, sizeof(g_sWallhackFlag));
510 gc_sFroggyJumpFlag.GetString(g_sFroggyJumpFlag, sizeof(g_sFroggyJumpFlag));
511 gc_sPaperClipFlag.GetString(g_sPaperClipFlag, sizeof(g_sPaperClipFlag));
512 gc_sRandomTPFlag.GetString(g_sRandomTPFlag, sizeof(g_sRandomTPFlag));
513
514 if (!g_bDBConnected && gc_bMySQL.BoolValue)
515 DB_Connect();
516
517 if (gc_bCreditsSave.BoolValue)
518 {
519 for (int i = 1; i <= MaxClients; i++) if (IsValidClient(i, false, true))
520 {
521 if (gc_bMySQL.BoolValue)
522 {
523 DB_AddPlayer(i);
524 DB_FetchCredits(i);
525 }
526 else if (AreClientCookiesCached(i))
527 {
528 OnClientCookiesCached(i);
529 }
530 }
531 }
532
533 g_hThrownKnives = CreateArray();
534
535 char sBuffer[256];
536 BuildPath(Path_SM, sBuffer, sizeof(sBuffer), "logs/MyJailShop");
537 DirExistsEx(sBuffer);
538
539 SetLogFile(g_sPurchaseLogFile, "purchase", "MyJailShop");
540 SetLogFile(g_sGiftLogFile, "gift", "MyJailShop");
541}
542
543
544// ConVarChange for Strings
545public int OnSettingChanged(Handle convar, const char[] oldValue, const char[] newValue)
546{
547 if (convar == gc_sModelPathFakeGuard)
548 {
549 strcopy(g_sModelPathFakeGuard, sizeof(g_sModelPathFakeGuard), newValue);
550 PrecacheModel(g_sModelPathFakeGuard);
551 }
552 else if (convar == gc_sInvisibleFlag)
553 {
554 strcopy(g_sInvisibleFlag, sizeof(g_sInvisibleFlag), newValue);
555 }
556 else if (convar == gc_sAWPFlag)
557 {
558 strcopy(g_sAWPFlag, sizeof(g_sAWPFlag), newValue);
559 }
560 else if (convar == gc_sNoDamageFlag)
561 {
562 strcopy(g_sNoDamageFlag, sizeof(g_sNoDamageFlag), newValue);
563 }
564 else if (convar == gc_sOpenCellsFlag)
565 {
566 strcopy(g_sOpenCellsFlag, sizeof(g_sOpenCellsFlag), newValue);
567 }
568 else if (convar == gc_sVampireFlag)
569 {
570 strcopy(g_sVampireFlag, sizeof(g_sVampireFlag), newValue);
571 }
572 else if (convar == gc_sHealthFlag)
573 {
574 strcopy(g_sHealthFlag, sizeof(g_sHealthFlag), newValue);
575 }
576 else if (convar == gc_sMolotovFlag)
577 {
578 strcopy(g_sMolotovFlag, sizeof(g_sMolotovFlag), newValue);
579 }
580 else if (convar == gc_sFakeModelFlag)
581 {
582 strcopy(g_sFakeModelFlag, sizeof(g_sFakeModelFlag), newValue);
583 }
584 else if (convar == gc_sPoisonSmokeFlag)
585 {
586 strcopy(g_sPoisonSmokeFlag, sizeof(g_sPoisonSmokeFlag), newValue);
587 }
588 else if (convar == gc_sBirdFlag)
589 {
590 strcopy(g_sBirdFlag, sizeof(g_sBirdFlag), newValue);
591 }
592 else if (convar == gc_sTeleportSmokeFlag)
593 {
594 strcopy(g_sTeleportSmokeFlag, sizeof(g_sTeleportSmokeFlag), newValue);
595 }
596 else if (convar == gc_sReviveFlag)
597 {
598 strcopy(g_sReviveFlag, sizeof(g_sReviveFlag), newValue);
599 }
600 else if (convar == gc_sFireHEFlag)
601 {
602 strcopy(g_sFireHEFlag, sizeof(g_sFireHEFlag), newValue);
603 }
604 else if (convar == gc_sBhopFlag)
605 {
606 strcopy(g_sBhopFlag, sizeof(g_sBhopFlag), newValue);
607 }
608 else if (convar == gc_sGravityFlag)
609 {
610 strcopy(g_sGravityFlag, sizeof(g_sGravityFlag), newValue);
611 }
612 else if (convar == gc_sTaserFlag)
613 {
614 strcopy(g_sTaserFlag, sizeof(g_sTaserFlag), newValue);
615 }
616 else if (convar == gc_sNoClipFlag)
617 {
618 strcopy(g_sNoClipFlag, sizeof(g_sNoClipFlag), newValue);
619 }
620 else if (convar == gc_sThrowKnifeFlag)
621 {
622 strcopy(g_sThrowKnifeFlag, sizeof(g_sThrowKnifeFlag), newValue);
623 }
624 else if (convar == gc_sWallhackFlag)
625 {
626 strcopy(g_sWallhackFlag, sizeof(g_sWallhackFlag), newValue);
627 }
628 else if (convar == gc_sFroggyJumpFlag)
629 {
630 strcopy(g_sFroggyJumpFlag, sizeof(g_sFroggyJumpFlag), newValue);
631 }
632 else if (convar == gc_sPaperClipFlag)
633 {
634 strcopy(g_sPaperClipFlag, sizeof(g_sPaperClipFlag), newValue);
635 }
636 else if (convar == gc_sRandomTPFlag)
637 {
638 strcopy(g_sRandomTPFlag, sizeof(g_sRandomTPFlag), newValue);
639 }
640}
641
642
643public void OnConfigsExecuted()
644{
645 if (gc_bTag.BoolValue)
646 {
647 ConVar hTags = FindConVar("sv_tags");
648 char sTags[128];
649 hTags.GetString(sTags, sizeof(sTags));
650 if (StrContains(sTags, "MyJailShop", false) == -1)
651 {
652 StrCat(sTags, sizeof(sTags), ", MyJailShop");
653 hTags.SetString(sTags);
654 }
655 }
656
657 // Set custom Commands
658 int iCount = 0;
659 char sCommands[128], sCommandsL[12][32], sCommand[32];
660
661 // Shop menu
662 gc_sCustomCommandShop.GetString(sCommands, sizeof(sCommands)); // Get new commands
663 ReplaceString(sCommands, sizeof(sCommands), " ",""); // Remove the spaces " "
664 iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[])); // Split commands to single command and count
665
666 for (int i = 0; i < iCount; i++) // Loop the counted single commands
667 {
668 Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]); // Add sm_ for console command
669 if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS) // if command not already exist
670 RegConsoleCmd(sCommand, Command_Menu_OpenShop, "Open the jail shop menu"); // set new command
671 }
672
673 // Shop show credits
674 gc_sCustomCommandCredits.GetString(sCommands, sizeof(sCommands));
675 ReplaceString(sCommands, sizeof(sCommands), " ","");
676 iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
677
678 for (int i = 0; i < iCount; i++)
679 {
680 Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
681 if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS) // if command not already exist
682 RegConsoleCmd(sCommand, Commands_Credits,"Show your jail shop credits");
683 }
684
685 // Shop revive
686 gc_sCustomCommandRevive.GetString(sCommands, sizeof(sCommands));
687 ReplaceString(sCommands, sizeof(sCommands), " ","");
688 iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
689
690 for (int i = 0; i < iCount; i++)
691 {
692 Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
693 if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS) // if command not already exist
694 RegConsoleCmd(sCommand, Command_Revive, "Use jail shop item revive");
695 }
696
697 // Shop show all credits menu
698 gc_sCustomCommandMassCredits.GetString(sCommands, sizeof(sCommands));
699 ReplaceString(sCommands, sizeof(sCommands), " ","");
700 iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
701
702 for (int i = 0; i < iCount; i++)
703 {
704 Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
705 if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS) // if command not already exist
706 RegConsoleCmd(sCommand, Command_ShowCredits, "Show jail shop credits of all online player");
707 }
708
709 // Shop send gift credits
710 gc_sCustomCommandGift.GetString(sCommands, sizeof(sCommands));
711 ReplaceString(sCommands, sizeof(sCommands), " ","");
712 iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
713
714 for (int i = 0; i < iCount; i++)
715 {
716 Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
717 if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS) // if command not already exist
718 RegConsoleCmd(sCommand, Command_SendCredits, "Gift jail shop credits to a player - Use: sm_jailgift <#userid|name> [amount]");
719 }
720}
721
722
723/******************************************************************************
724 COMMANDS
725******************************************************************************/
726
727
728// sm_jailcredits
729public Action Commands_Credits(int client, int args)
730{
731 if (client == 0) // if client is server/serverconsole
732 {
733 CReplyToCommand(client, "%t", "Command is in-game only");
734 return Plugin_Handled;
735 }
736 if (!gc_bEnable.BoolValue) // if plugin is disbaled
737 {
738 CReplyToCommand(client, "%t %t", "shop_tag", "shop_disabled");
739 return Plugin_Handled;
740 }
741 // Show credits in chat
742 CReplyToCommand(client, "%t %t", "shop_tag", "shop_credits", Forward_OnGetCredits(client));
743 return Plugin_Handled;
744}
745
746
747// sm_jailcredits
748public Action AdminCommand_Sale(int client, int args)
749{
750 if (!gc_bEnable.BoolValue) // if plugin is disbaled
751 {
752 CReplyToCommand(client, "%t %t", "shop_tag", "shop_disabled");
753 return Plugin_Handled;
754 }
755 if (args > 0)
756 {
757 char arg[4];
758 GetCmdArg(1, arg, sizeof(arg));
759 int bOpenSale = StringToInt(arg);
760
761 if (bOpenSale == 1 && !g_bSale)
762 {
763 SaleOn();
764 }
765 else if (bOpenSale == 0 && g_bSale)
766 {
767 SaleOff();
768 }
769 else
770 {
771 CReplyToCommand(client, "%t Use: sm_sale <1|0>", "shop_tag");
772 }
773 }
774 else if (!g_bSale)
775 {
776 SaleOn();
777 }
778 else
779 {
780 SaleOff();
781 }
782
783 return Plugin_Handled;
784}
785
786
787void SaleOff()
788{
789 ServerCommand("exec MyJailShop/Items.cfg");
790 g_bSale = false;
791 CPrintToChatAll("%t %t", "shop_tag", "shop_saleend");
792}
793
794
795void SaleOn()
796{
797 gc_iInvisible.IntValue = (gc_iInvisible.IntValue - ((gc_iInvisible.IntValue / 100) * gc_fSale.IntValue));
798 gc_iAWP.IntValue = (gc_iAWP.IntValue - ((gc_iAWP.IntValue / 100) * gc_fSale.IntValue));
799 gc_iNoDamage.IntValue = (gc_iNoDamage.IntValue - ((gc_iNoDamage.IntValue / 100) * gc_fSale.IntValue));
800 gc_iOpenCells.IntValue = (gc_iOpenCells.IntValue - ((gc_iOpenCells.IntValue / 100) * gc_fSale.IntValue));
801 gc_iVampire.IntValue = (gc_iVampire.IntValue - ((gc_iVampire.IntValue / 100) * gc_fSale.IntValue));
802 gc_iHealth.IntValue = (gc_iHealth.IntValue - ((gc_iHealth.IntValue / 100) * gc_fSale.IntValue));
803 gc_iDeagle.IntValue = (gc_iDeagle.IntValue - ((gc_iDeagle.IntValue / 100) * gc_fSale.IntValue));
804 gc_iKnife.IntValue = (gc_iKnife.IntValue - ((gc_iKnife.IntValue / 100) * gc_fSale.IntValue));
805 gc_iHeal.IntValue = (gc_iHeal.IntValue - ((gc_iHeal.IntValue / 100) * gc_fSale.IntValue));
806 gc_iMolotov.IntValue = (gc_iMolotov.IntValue - ((gc_iMolotov.IntValue / 100) * gc_fSale.IntValue));
807 gc_iFakeModel.IntValue = (gc_iFakeModel.IntValue - ((gc_iFakeModel.IntValue / 100) * gc_fSale.IntValue));
808 gc_iPoisonSmoke.IntValue = (gc_iPoisonSmoke.IntValue - ((gc_iPoisonSmoke.IntValue / 100) * gc_fSale.IntValue));
809 gc_iBird.IntValue = (gc_iBird.IntValue - ((gc_iBird.IntValue / 100) * gc_fSale.IntValue));
810 gc_iTeleportSmoke.IntValue = (gc_iTeleportSmoke.IntValue - ((gc_iTeleportSmoke.IntValue / 100) * gc_fSale.IntValue));
811 gc_iRevive.IntValue = (gc_iRevive.IntValue - ((gc_iRevive.IntValue / 100) * gc_fSale.IntValue));
812 gc_iFireHE.IntValue = (gc_iFireHE.IntValue - ((gc_iFireHE.IntValue / 100) * gc_fSale.IntValue));
813 gc_iBhop.IntValue = (gc_iBhop.IntValue - ((gc_iBhop.IntValue / 100) * gc_fSale.IntValue));
814 gc_iGravity.IntValue = (gc_iGravity.IntValue - ((gc_iGravity.IntValue / 100) * gc_fSale.IntValue));
815 gc_iTaser.IntValue = (gc_iTaser.IntValue - ((gc_iTaser.IntValue / 100) * gc_fSale.IntValue));
816 gc_iNoClip.IntValue = (gc_iNoClip.IntValue - ((gc_iNoClip.IntValue / 100) * gc_fSale.IntValue));
817 gc_iThrowKnife.IntValue = (gc_iThrowKnife.IntValue - ((gc_iThrowKnife.IntValue / 100) * gc_fSale.IntValue));
818 gc_iWallhack.IntValue = (gc_iWallhack.IntValue - ((gc_iWallhack.IntValue / 100) * gc_fSale.IntValue));
819 gc_iFroggyJump.IntValue = (gc_iFroggyJump.IntValue - ((gc_iFroggyJump.IntValue / 100) * gc_fSale.IntValue));
820 gc_iPaperClip.IntValue = (gc_iPaperClip.IntValue - ((gc_iPaperClip.IntValue / 100) * gc_fSale.IntValue));
821 gc_iRandomTP.IntValue = (gc_iRandomTP.IntValue - ((gc_iRandomTP.IntValue / 100) * gc_fSale.IntValue));
822
823 g_bSale = true;
824 CPrintToChatAll("%t %t", "shop_tag", "shop_saleon", gc_fSale.IntValue);
825}
826
827public void TG_OnGamePrepare()
828{
829 for (int i = 1; i <= MaxClients; i++) if (IsValidClient(i, false, true))
830 {
831 ResetPlayer(i);
832 }
833}
834
835// sm_jailshop
836public Action Command_Menu_OpenShop(int client, int args)
837{
838 if (client == 0) // if client is server/serverconsole
839 {
840 CReplyToCommand(client, "%t", "Command is in-game only");
841 return Plugin_Handled;
842 }
843 if (!gc_bEnable.BoolValue) // if plugin is disbaled
844 {
845 CReplyToCommand(client, "%t %t", "shop_tag", "shop_disabled");
846 return Plugin_Handled;
847 }
848 if (gp_bMyJailBreak && !gc_bEventdays.BoolValue) // Check if myjailbreak is available and if shop is allowed on eventdays
849 {
850 if (MyJailbreak_IsEventDayRunning())
851 {
852 CReplyToCommand(client, "%t %t", "shop_tag", "shop_disabled");
853 return Plugin_Handled;
854 }
855 }
856
857 if (gc_bOnlyT.BoolValue) // shop only for terror?
858 {
859 if (GetClientTeam(client) != 2)
860 {
861 CReplyToCommand(client, "%t %t", "shop_tag", "shop_tonly");
862 return Plugin_Handled;
863 }
864 else Menu_OpenShop(client);
865 }
866 else Menu_OpenShop(client);
867 return Plugin_Handled;
868}
869
870
871// sm_revive
872public Action Command_Revive(int client, int args)
873{
874 if (gc_iRevive.IntValue == 0)
875 {
876 return Plugin_Handled;
877 }
878 if (client == 0) // if client is server/serverconsole
879 {
880 CReplyToCommand(client, "%t", "Command is in-game only");
881 return Plugin_Handled;
882 }
883 if (!gc_bEnable.BoolValue) // if plugin is disbaled
884 {
885 CReplyToCommand(client, "%t %t", "shop_tag", "shop_disabled");
886 return Plugin_Handled;
887 }
888 if (gc_iReviveOnlyTeam.IntValue == 2 && GetClientTeam(client) == CS_TEAM_CT) // shopitem only for terror?
889 {
890 CReplyToCommand(client, "%t %t", "shop_tag", "shop_onlyt");
891 return Plugin_Handled;
892 }
893 if (gc_iReviveOnlyTeam.IntValue == 0 && GetClientTeam(client) == CS_TEAM_T) // shopitem only for counter-terror?
894 {
895 CReplyToCommand(client, "%t %t", "shop_tag", "shop_onlyct");
896 return Plugin_Handled;
897 }
898 Item_Revive(client, "Revive");
899 return Plugin_Handled;
900}
901
902
903// drop weapon button
904public Action Command_ToggleFly(int client, int args)
905{
906 if (g_bFly[client]) // if player is a bird
907 {
908 MoveType movetype = GetEntityMoveType(client);
909
910 if (movetype != MOVETYPE_FLY)
911 {
912 SetEntityMoveType(client, MOVETYPE_FLY);
913 }
914 else SetEntityMoveType(client, MOVETYPE_WALK);
915 }
916 return Plugin_Continue;
917}
918
919
920// sm_jailgift
921public Action Command_SendCredits(int client, int args)
922{
923 if (client == 0) // if client is server/serverconsole
924 {
925 CReplyToCommand(client, "%t", "Command is in-game only");
926 return Plugin_Handled;
927 }
928
929 if (!gc_bEnable.BoolValue) // if plugin is disbaled
930 {
931 CReplyToCommand(client, "%t %t", "shop_tag", "shop_disabled");
932 return Plugin_Handled;
933 }
934
935 if (args < 2) // Not enough parameters
936 {
937 CReplyToCommand(client, "%t Use: sm_jailgift <#userid|name> [amount]", "shop_tag");
938 return Plugin_Handled;
939 }
940
941 char arg2[10];
942 GetCmdArg(2, arg2, sizeof(arg2));
943
944 int amount = StringToInt(arg2);
945
946 char strTarget[32];
947 GetCmdArg(1, strTarget, sizeof(strTarget));
948
949 char strTargetName[MAX_TARGET_LENGTH];
950 int TargetList[MAXPLAYERS], TargetCount;
951 bool TargetTranslate;
952
953 if ((TargetCount = ProcessTargetString(strTarget, client, TargetList, MAXPLAYERS, COMMAND_FILTER_CONNECTED|COMMAND_FILTER_NO_IMMUNITY,
954 strTargetName, sizeof(strTargetName), TargetTranslate)) <= 0)
955 {
956 ReplyToTargetError(client, TargetCount);
957 return Plugin_Handled;
958 }
959
960 for (int i = 0; i < TargetCount; i++)
961 {
962 int iClient = TargetList[i];
963 if (IsClientInGame(iClient) && amount > 0)
964 {
965 if (client != iClient)
966 {
967 if (Forward_OnGetCredits(client) < amount)
968 ReplyToCommand(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), amount);
969 else
970 {
971 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-amount));
972 Forward_OnSetCredits(iClient,(Forward_OnGetCredits(iClient)+amount));
973 Forward_OnPlayerGetCredits(iClient, amount);
974
975 CPrintToChat(client, "%t %t", "shop_tag", "shop_give", amount, iClient);
976 CPrintToChat(iClient, "%t %t", "shop_tag", "shop_get", amount, client);
977 if (gc_bLogging.BoolValue) LogToFileEx(g_sGiftLogFile, "Player %L has gift %i credits to %L ", client, amount, iClient);
978 }
979 }
980 CPrintToChat(client, "%t %t", "shop_tag", "shop_giftyourself");
981 }
982 }
983 return Plugin_Handled;
984}
985
986
987// sm_jailcredits
988public Action Command_ShowCredits(int client, int args)
989{
990 if (client == 0) // if client is server/serverconsole
991 {
992 CReplyToCommand(client, "%t", "Command is in-game only");
993 return Plugin_Handled;
994 }
995 if (!gc_bEnable.BoolValue) // if plugin is disbaled
996 {
997 CReplyToCommand(client, "%t %t", "shop_tag", "shop_disabled");
998 return Plugin_Handled;
999 }
1000
1001 char sName[MAX_NAME_LENGTH], sUserId[10];
1002
1003 Menu menu = CreateMenu(Handler_ShowCredits);
1004 SetMenuTitle(menu, "%t","shop_menu_playercredits");
1005
1006 for (int i = 1; i <= MaxClients; i++) if (IsValidClient(i, false, true))
1007 {
1008 GetClientName(i, sName, sizeof(sName));
1009 IntToString(GetClientUserId(i), sUserId, sizeof(sUserId));
1010 char buffer[255];
1011 Format(buffer, sizeof(buffer), "%s: %d", sName, Forward_OnGetCredits(i));
1012 AddMenuItem(menu, sUserId, buffer, ITEMDRAW_DISABLED);
1013 }
1014
1015 menu.ExitButton = true;
1016 menu.Display(client, 20);
1017
1018 return Plugin_Handled;
1019}
1020
1021
1022public int Handler_ShowCredits(Menu menu, MenuAction action, int param1, int param2){}
1023
1024
1025// sm_jailset
1026public Action AdminCommand_SetCredits(int client, int args)
1027{
1028 if (!gc_bEnable.BoolValue) // if plugin is disbaled
1029 {
1030 CReplyToCommand(client, "%t %t", "shop_tag", "shop_disabled");
1031 return Plugin_Handled;
1032 }
1033 if (args < 2)
1034 {
1035 CReplyToCommand(client, "%t Use: sm_jailset <#userid|name> [amount]", "shop_tag");
1036 return Plugin_Handled;
1037 }
1038
1039 char arg2[10];
1040 GetCmdArg(2, arg2, sizeof(arg2));
1041
1042 int amount = StringToInt(arg2);
1043
1044 char strTarget[32];
1045 GetCmdArg(1, strTarget, sizeof(strTarget));
1046
1047 char strTargetName[MAX_TARGET_LENGTH];
1048 int TargetList[MAXPLAYERS], TargetCount;
1049 bool TargetTranslate;
1050
1051 if ((TargetCount = ProcessTargetString(strTarget, client, TargetList, MAXPLAYERS, COMMAND_FILTER_CONNECTED, strTargetName, sizeof(strTargetName), TargetTranslate)) <= 0)
1052 {
1053 ReplyToTargetError(client, TargetCount);
1054 return Plugin_Handled;
1055 }
1056
1057 for(int i = 0; i < TargetCount; i++)
1058 {
1059 int iClient = TargetList[i];
1060 if (IsClientInGame(iClient))
1061 {
1062 Forward_OnSetCredits(iClient, amount);
1063 Forward_OnPlayerGetCredits(iClient, amount);
1064
1065 CReplyToCommand(client, "%t %t", "shop_tag", "shop_set", amount, iClient);
1066 CPrintToChat(iClient, "%t %t", "shop_tag", "shop_getset", amount, client);
1067 if (gc_bLogging.BoolValue) LogToFileEx(g_sGiftLogFile, "Admin %L set %L credits to %i ", client, iClient, amount);
1068 }
1069 }
1070 return Plugin_Handled;
1071}
1072
1073
1074// sm_jailgive
1075public Action AdminCommand_GiveCredits(int client, int args)
1076{
1077 if (!gc_bEnable.BoolValue) // if plugin is disbaled
1078 {
1079 CReplyToCommand(client, "%t %t", "shop_tag", "shop_disabled");
1080 return Plugin_Handled;
1081 }
1082 if (args < 2)
1083 {
1084 CReplyToCommand(client, "%t Use: sm_jailgive <#userid|name> [amount]", "shop_tag");
1085 return Plugin_Handled;
1086 }
1087
1088 char arg2[10];
1089 GetCmdArg(2, arg2, sizeof(arg2));
1090
1091 int amount = StringToInt(arg2);
1092
1093 char strTarget[32];
1094 GetCmdArg(1, strTarget, sizeof(strTarget));
1095 char strTargetName[MAX_TARGET_LENGTH];
1096
1097 int TargetList[MAXPLAYERS], TargetCount;
1098 bool TargetTranslate;
1099 if ((TargetCount = ProcessTargetString(strTarget, client, TargetList, MAXPLAYERS, COMMAND_FILTER_CONNECTED, strTargetName, sizeof(strTargetName), TargetTranslate)) <= 0)
1100 {
1101 ReplyToTargetError(client, TargetCount);
1102 return Plugin_Handled;
1103 }
1104 for(int i = 0; i < TargetCount; i++)
1105 {
1106 int iClient = TargetList[i];
1107 if (IsClientInGame(iClient))
1108 {
1109 Forward_OnSetCredits(iClient,(Forward_OnGetCredits(iClient)+amount));
1110 Forward_OnPlayerGetCredits(iClient, amount);
1111
1112 CPrintToChat(client, "%t %t", "shop_tag", "shop_give", amount, iClient);
1113 CPrintToChat(iClient, "%t %t", "shop_tag", "shop_get", amount, client);
1114 if (gc_bLogging.BoolValue) LogToFileEx(g_sGiftLogFile, "Admin %L gifted %i credits to %L ", client, amount, iClient);
1115 }
1116 }
1117 return Plugin_Handled;
1118}
1119
1120
1121/******************************************************************************
1122 EVENTS
1123******************************************************************************/
1124
1125
1126public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
1127{
1128 int attacker = GetClientOfUserId(event.GetInt("attacker")); // get victim & attacker
1129 int client = GetClientOfUserId(event.GetInt("userid"));
1130
1131 if (!gc_bEnable.BoolValue) // if plugin is disbaled
1132 return;
1133
1134 // Start timer: show !revive chat hint if enought credits & enabled
1135 if ((Forward_OnGetCredits(client) >= gc_iRevive.IntValue) && gc_iRevive.IntValue != 0)
1136 {
1137 CreateTimer(2.0, Timer_DeathMessage, GetClientUserId(client));
1138 }
1139
1140 if (g_bFly[client]) // if player was a bird reset model, thirdperson and flymode
1141 {
1142 g_bFly[client] = false;
1143 ClientCommand(client, "firstperson");
1144 SetEntityModel(client, g_sModelPathPrevious[client]);
1145 SetEntityMoveType(client, MOVETYPE_WALK);
1146 }
1147
1148 if (!attacker)
1149 return;
1150
1151 if (attacker == client)
1152 return;
1153
1154 if (GetClientTeam(attacker) == CS_TEAM_CT && gc_iCreditsKillCT.IntValue == 0 && gc_iCreditsVIPKillCT.IntValue == 0)
1155 return;
1156
1157 if (GetClientTeam(attacker) == CS_TEAM_T && gc_iCreditsKillT.IntValue == 0 && gc_iCreditsVIPKillT.IntValue == 0)
1158 return;
1159
1160 if (GetAllPlayersCount() >= gc_iMinPlayersToGetCredits.IntValue && (gc_bCreditsWarmup.BoolValue || GameRules_GetProp("m_bWarmupPeriod") != 1))
1161 {
1162 if (GetClientTeam(attacker) == CS_TEAM_CT)
1163 {
1164 if (IsPlayerReservationAdmin(attacker))
1165 {
1166 Forward_OnSetCredits(attacker,(Forward_OnGetCredits(attacker) + gc_iCreditsVIPKillCT.IntValue));
1167 Forward_OnPlayerGetCredits(attacker, gc_iCreditsVIPKillCT.IntValue);
1168 }
1169 else
1170 {
1171 Forward_OnSetCredits(attacker,(Forward_OnGetCredits(attacker) + gc_iCreditsKillCT.IntValue));
1172 Forward_OnPlayerGetCredits(attacker, gc_iCreditsKillCT.IntValue);
1173 }
1174 }
1175
1176 if (GetClientTeam(attacker) == CS_TEAM_T)
1177 {
1178 if (IsPlayerReservationAdmin(attacker))
1179 {
1180 Forward_OnSetCredits(attacker,(Forward_OnGetCredits(attacker) + gc_iCreditsVIPKillT.IntValue));
1181 Forward_OnPlayerGetCredits(attacker, gc_iCreditsVIPKillT.IntValue);
1182 }
1183 else
1184 {
1185 Forward_OnSetCredits(attacker,(Forward_OnGetCredits(attacker) + gc_iCreditsKillT.IntValue));
1186 Forward_OnPlayerGetCredits(attacker, gc_iCreditsKillT.IntValue);
1187 }
1188 }
1189 }
1190
1191 if (Forward_OnGetCredits(attacker) > gc_iCreditsMax.IntValue)
1192 {
1193 Forward_OnSetCredits(attacker, gc_iCreditsMax.IntValue);
1194 CPrintToChat(attacker, "%t %t", "shop_tag", "shop_maxcredits", Forward_OnGetCredits(attacker));
1195 }
1196
1197 if (!gc_bNotification.BoolValue)
1198 return;
1199
1200 if (GetAllPlayersCount() >= gc_iMinPlayersToGetCredits.IntValue && (gc_bCreditsWarmup.IntValue != 0 || GameRules_GetProp("m_bWarmupPeriod") != 1))
1201 {
1202 if (GetClientTeam(attacker) == CS_TEAM_CT)
1203 {
1204 if (IsPlayerReservationAdmin(attacker))
1205 {
1206 CPrintToChat(attacker, "%t %t", "shop_tag", "shop_killedt", Forward_OnGetCredits(attacker), gc_iCreditsVIPKillCT.IntValue, client);
1207 }
1208 else
1209 {
1210 CPrintToChat(attacker, "%t %t", "shop_tag", "shop_killedt", Forward_OnGetCredits(attacker), gc_iCreditsKillCT.IntValue, client);
1211 }
1212 }
1213 else if (GetClientTeam(attacker) == CS_TEAM_T)
1214 {
1215 if (IsPlayerReservationAdmin(attacker))
1216 {
1217 CPrintToChat(attacker, "%t %t", "shop_tag", "shop_killedct", Forward_OnGetCredits(attacker), gc_iCreditsVIPKillT.IntValue, client);
1218 }
1219 else
1220 {
1221 CPrintToChat(attacker, "%t %t", "shop_tag", "shop_killedct", Forward_OnGetCredits(attacker), gc_iCreditsKillT.IntValue, client);
1222 }
1223 }
1224 }
1225}
1226
1227
1228public Action Event_PlayerHurt(Event event, const char[] name, bool dontBroadcast)
1229{
1230 int victim = GetClientOfUserId(GetEventInt(event,"userid")); // get victim & attacker
1231 int attacker = GetClientOfUserId(event.GetInt("attacker"));
1232
1233 if (attacker == 0 || !g_bFireHE[attacker] || g_bIsLR)
1234 return;
1235
1236 if (victim != attacker && attacker !=0 && attacker <MAXPLAYERS)
1237 {
1238 char sWeaponUsed[50];
1239 GetEventString(event,"weapon",sWeaponUsed,sizeof(sWeaponUsed));
1240
1241 if (StrEqual(sWeaponUsed,"hegrenade"))
1242 {
1243 IgniteEntity(victim, 5.0);
1244 }
1245 }
1246
1247 g_bFireHE[attacker] = false;
1248}
1249
1250
1251public Action Event_SmokeGrenadeDetonate(Event event, const char[] name, bool dontBroadcast)
1252{
1253 float DetonateOrigin[3];
1254 DetonateOrigin[0] = event.GetFloat("x");
1255 DetonateOrigin[1] = event.GetFloat("y");
1256 DetonateOrigin[2] = event.GetFloat("z");
1257
1258 int client = GetClientOfUserId(event.GetInt("userid"));
1259
1260 if (g_bTeleportSmoke[client])
1261 {
1262 g_bTeleportSmoke[client] = false;
1263 if (IsClientInGame(client))
1264 {
1265 SetClientViewEntity(client, client);
1266 }
1267
1268 TeleportEntity(client, DetonateOrigin, NULL_VECTOR, NULL_VECTOR);
1269 }
1270
1271 if (!g_bPoison[client])
1272 return;
1273
1274 int iEntity = CreateEntityByName("light_dynamic");
1275
1276 if (iEntity == -1)
1277 return;
1278
1279 DispatchKeyValue(iEntity, "inner_cone", "0");
1280 DispatchKeyValue(iEntity, "cone", "80");
1281 DispatchKeyValue(iEntity, "brightness", "5");
1282 DispatchKeyValueFloat(iEntity, "spotlight_radius", 96.0);
1283 DispatchKeyValue(iEntity, "pitch", "90");
1284 DispatchKeyValue(iEntity, "style", "6");
1285 DispatchKeyValue(iEntity, "_light", "0 255 0");
1286 DispatchKeyValueFloat(iEntity, "distance", 256.0);
1287 SetEntPropEnt(iEntity, Prop_Send, "m_hOwnerEntity", client);
1288 CreateTimer(17.0, Timer_Delete, iEntity, TIMER_FLAG_NO_MAPCHANGE);
1289
1290 TE_SetupBeamRingPoint(DetonateOrigin, 99.0, 100.0, g_iBeamSprite, g_iHaloSprite, 0, 15, 20.0, 10.0, 220.0, {50, 255, 50, 255}, 10, 0);
1291 TE_SendToAll();
1292
1293 TE_SetupBeamRingPoint(DetonateOrigin, 99.0, 100.0, g_iBeamSprite, g_iHaloSprite, 0, 15, 20.0, 10.0, 220.0, {50, 50, 255, 255}, 10, 0);
1294 TE_SendToAll();
1295
1296 DispatchSpawn(iEntity);
1297 TeleportEntity(iEntity, DetonateOrigin, NULL_VECTOR, NULL_VECTOR);
1298 AcceptEntityInput(iEntity, "TurnOn");
1299
1300 CreateTimer(1.0, Timer_CheckDamage, iEntity, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
1301
1302 g_bPoison[client] = false;
1303}
1304
1305
1306public Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
1307{
1308 int winner = event.GetInt("winner");
1309
1310 if (winner == CS_TEAM_T)
1311 {
1312 for (int i = 1; i <= MaxClients; i++) if (IsValidClient(i, false, gc_bCreditsWinAlive.BoolValue)) if (GetAllPlayersCount() >= gc_iMinPlayersToGetCredits.IntValue && (gc_bCreditsWarmup.BoolValue || GameRules_GetProp("m_bWarmupPeriod") != 1))
1313 {
1314 if (IsPlayerReservationAdmin(i) && gc_iCreditsVIPWinT.IntValue != 0)
1315 {
1316 Forward_OnSetCredits(i, (Forward_OnGetCredits(i) + gc_iCreditsVIPWinT.IntValue));
1317 Forward_OnPlayerGetCredits(i, gc_iCreditsVIPWinT.IntValue);
1318
1319 if (gc_bNotification.BoolValue)
1320 {
1321 CPrintToChat(i, "%t %t", "shop_tag", "shop_win", Forward_OnGetCredits(i), gc_iCreditsVIPWinT.IntValue);
1322 }
1323 }
1324 else if (gc_iCreditsWinT.IntValue != 0)
1325 {
1326 Forward_OnSetCredits(i, (Forward_OnGetCredits(i) + gc_iCreditsWinT.IntValue));
1327 Forward_OnPlayerGetCredits(i, gc_iCreditsWinT.IntValue);
1328
1329 if (gc_bNotification.BoolValue)
1330 {
1331 CPrintToChat(i, "%t %t", "shop_tag", "shop_win", Forward_OnGetCredits(i), gc_iCreditsWinT.IntValue);
1332 }
1333 }
1334 }
1335 }
1336 else if (winner == CS_TEAM_CT)
1337 {
1338 for (int i = 1; i <= MaxClients; i++) if (IsValidClient(i, false, gc_bCreditsWinAlive.BoolValue)) if (GetAllPlayersCount() >= gc_iMinPlayersToGetCredits.IntValue && (gc_bCreditsWarmup.BoolValue || GameRules_GetProp("m_bWarmupPeriod") != 1))
1339 {
1340 if (IsPlayerReservationAdmin(i) && gc_iCreditsVIPWinCT.IntValue != 0)
1341 {
1342 Forward_OnSetCredits(i,(Forward_OnGetCredits(i) + gc_iCreditsVIPWinCT.IntValue));
1343 Forward_OnPlayerGetCredits(i, gc_iCreditsVIPWinCT.IntValue);
1344
1345 if (gc_bNotification.BoolValue)
1346 {
1347 CPrintToChat(i, "%t %t", "shop_tag", "shop_win", Forward_OnGetCredits(i), gc_iCreditsVIPWinCT.IntValue);
1348 }
1349 }
1350 else if (gc_iCreditsVIPWinCT.IntValue != 0)
1351 {
1352 Forward_OnSetCredits(i,(Forward_OnGetCredits(i) + gc_iCreditsWinCT.IntValue));
1353 Forward_OnPlayerGetCredits(i, gc_iCreditsWinCT.IntValue);
1354
1355 if (gc_bNotification.BoolValue)
1356 {
1357 CPrintToChat(i, "%t %t", "shop_tag", "shop_win", Forward_OnGetCredits(i), gc_iCreditsWinCT.IntValue);
1358 }
1359 }
1360 }
1361 }
1362
1363 for (int i = 1; i <= MaxClients; i++)
1364 {
1365 if (!IsValidClient(i, false, true))
1366 continue;
1367
1368 ResetPlayer(i);
1369
1370 if (gc_bMySQL.BoolValue)
1371 {
1372 DB_WriteCredits(i);
1373 }
1374 }
1375
1376 g_bIsLR = true;
1377}
1378
1379
1380public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
1381{
1382 g_bAllowBuy = true;
1383 g_bCellsOpen = false;
1384 g_bIsLR = false;
1385
1386 if (gc_fBuyTime.FloatValue != 0)
1387 {
1388 CreateTimer (gc_fBuyTime.FloatValue, Timer_BuyTime);
1389 }
1390}
1391
1392
1393public void Event_WeaponFire(Event event, char[] name, bool dontBroadcast)
1394{
1395 char weapon[20];
1396 event.GetString("weapon", weapon, sizeof(weapon));
1397
1398 if (StrContains(weapon, "knife", false) == -1)
1399 return;
1400
1401 int client = GetClientOfUserId(event.GetInt("userid"));
1402
1403 if (!g_bThrowingKnife[client])
1404 return;
1405
1406 g_hTimerDelay[client] = CreateTimer(0.0, Timer_CreateKnife, GetClientUserId(client));
1407}
1408
1409
1410/******************************************************************************
1411 FUNCTIONS LISTEN
1412******************************************************************************/
1413
1414
1415// Check for optional Plugins
1416public void OnAllPluginsLoaded()
1417{
1418 gp_bSmartJailDoors = LibraryExists("smartjaildoors");
1419 gp_bMyJailBreak = LibraryExists("myjailbreak");
1420 gp_bCustomPlayerSkins = LibraryExists("CustomPlayerSkins");
1421 gp_bMyJBWarden = LibraryExists("myjbwarden");
1422 gp_bMyIcons = LibraryExists("myicons");
1423
1424 g_bHandcuff = FindConVar("sm_warden_handcuffs");
1425}
1426
1427
1428public void OnLibraryRemoved(const char[] name)
1429{
1430 if (StrEqual(name, "smartjaildoors"))
1431 gp_bSmartJailDoors = false;
1432
1433 if (StrEqual(name, "myjailbreak"))
1434 gp_bMyJailBreak = false;
1435
1436 if (StrEqual(name, "CustomPlayerSkins"))
1437 gp_bCustomPlayerSkins = false;
1438
1439 if (StrEqual(name, "myjbwarden"))
1440 gp_bMyJBWarden = false;
1441
1442 if (StrEqual(name, "myicons"))
1443 gp_bMyIcons = false;
1444}
1445
1446
1447public void OnLibraryAdded(const char[] name)
1448{
1449 if (StrEqual(name, "smartjaildoors"))
1450 gp_bSmartJailDoors = true;
1451
1452 if (StrEqual(name, "myjailbreak"))
1453 gp_bMyJailBreak = true;
1454
1455 if (StrEqual(name, "CustomPlayerSkins"))
1456 gp_bCustomPlayerSkins = true;
1457
1458 if (StrEqual(name, "myjbwarden"))
1459 gp_bMyJBWarden = true;
1460
1461 if (StrEqual(name, "myicons"))
1462 gp_bMyIcons = true;
1463}
1464
1465
1466public void OnMapStart()
1467{
1468 g_iBeamSprite = PrecacheModel("materials/sprites/laserbeam.vmt", true);
1469 g_iHaloSprite = PrecacheModel("materials/sprites/halo.vmt", true);
1470 PrecacheModel("models/chicken/chicken.mdl");
1471 PrecacheModel(g_sModelPathFakeGuard);
1472
1473 if (!g_bDBConnected && gc_bMySQL.BoolValue)
1474 {
1475 DB_Connect();
1476 }
1477
1478 if (gc_bMySQL.BoolValue) for (int i = 1; i <= MaxClients; i++) if (IsValidClient(i, false, true))
1479 {
1480 DB_AddPlayer(i);
1481 DB_FetchCredits(i);
1482 }
1483
1484 if (gc_iCreditsTime.IntValue != 0)
1485 {
1486 g_hTimerCredits = CreateTimer(gc_fCreditsTimeInterval.FloatValue, Timer_Credits, _, TIMER_REPEAT);
1487 }
1488}
1489
1490
1491public void OnClientDisconnect(int client)
1492{
1493 if (!gc_bCreditsSave.BoolValue)
1494 {
1495 g_iCredits[client] = 0;
1496 return;
1497 }
1498
1499 if (gc_bMySQL.BoolValue)
1500 {
1501 if (!g_bDBConnected)
1502 {
1503 DB_Connect();
1504 }
1505
1506 DB_WriteCredits(client);
1507 }
1508 else if (AreClientCookiesCached(client))
1509 {
1510 char CreditsString[12];
1511 Format(CreditsString, sizeof(CreditsString), "%i", Forward_OnGetCredits(client));
1512 SetClientCookie(client, g_hCookieCredits, CreditsString);
1513 }
1514}
1515
1516
1517public void OnClientCookiesCached(int client)
1518{
1519 if (!gc_bCreditsSave.BoolValue)
1520 return;
1521
1522 if (gc_bMySQL.BoolValue)
1523 {
1524 if (!g_bDBConnected)
1525 {
1526 DB_Connect();
1527 }
1528
1529 DB_WriteCredits(client);
1530 }
1531 else
1532 {
1533 char CreditsString[12];
1534 GetClientCookie(client, g_hCookieCredits, CreditsString, sizeof(CreditsString));
1535 g_iCredits[client] = StringToInt(CreditsString);
1536 }
1537
1538 if (!gc_bCreditSystem.BoolValue)
1539 {
1540 g_iCredits[client] = Forward_OnGetCredits(client);
1541 }
1542}
1543
1544
1545public void OnPluginEnd()
1546{
1547 if (!gc_bCreditsSave.BoolValue)
1548 return;
1549
1550 for (int i = 1; i <= MaxClients; i++)
1551 {
1552 if (!IsValidClient(i, false, true))
1553 continue;
1554
1555 OnClientDisconnect(i);
1556 }
1557}
1558
1559
1560public void OnEntityCreated(int iEntity, const char[] classname)
1561{
1562 if (StrEqual(classname, "smokegrenade_projectile"))
1563 {
1564 SDKHook(iEntity, SDKHook_SpawnPost, Hook_OnEntitySpawned);
1565 }
1566}
1567
1568
1569public void Hook_OnEntitySpawned(int iGrenade)
1570{
1571 int client = GetEntPropEnt(iGrenade, Prop_Send, "m_hOwnerEntity");
1572
1573 if (IsValidClient(client, true, true) && g_bTeleportSmoke[client])
1574 {
1575 SetClientViewEntity(client, iGrenade);
1576 }
1577}
1578
1579
1580public void OnClientPostAdminCheck(int client)
1581{
1582 g_bNoDamage[client] = false;
1583 g_bInvisible[client] = false;
1584 g_bFireHE[client] = false;
1585 g_bSuperKnife[client] = false;
1586 g_bPoison[client] = false;
1587 g_bVampire[client] = false;
1588 g_bFly[client] = false;
1589 g_bFakeGuard[client] = false;
1590 g_bNoClip[client] = false;
1591 g_bThrowingKnife[client] = false;
1592 g_bFroggyJump[client] = false;
1593 g_bWallhack[client] = false;
1594 g_bOneBulletAWP[client] = false;
1595 g_bOneMagDeagle[client] = false;
1596 g_bTeleportSmoke[client] = false;
1597 g_bBhop[client] = false;
1598 g_bGravity[client] = false;
1599 g_bMolotov[client] = false;
1600 g_bHealth[client] = false;
1601}
1602
1603
1604public void OnClientPutInServer(int client)
1605{
1606 SDKHook(client, SDKHook_OnTakeDamage, Hook_OnTakeDamage);
1607 SDKHook(client, SDKHook_WeaponCanUse, Hook_OnWeaponCanUse);
1608
1609 g_bNoDamage[client] = false;
1610 g_bInvisible[client] = false;
1611 g_bPoison[client] = false;
1612 g_bVampire[client] = false;
1613 g_bSuperKnife[client] = false;
1614 g_bTeleportSmoke[client] = false;
1615 g_bNoClip[client] = false;
1616 g_bThrowingKnife[client] = false;
1617 g_bFroggyJump[client] = false;
1618 g_bWallhack[client] = false;
1619 g_bFireHE[client] = false;
1620 g_bBhop[client] = false;
1621 g_bGravity[client] = false;
1622 g_bMolotov[client] = false;
1623 g_bHealth[client] = false;
1624 g_bOneBulletAWP[client] = false;
1625 g_bOneMagDeagle[client] = false;
1626
1627 if (gc_bWelcome.BoolValue)
1628 {
1629 CreateTimer(5.0, Timer_WelcomeMessage, GetClientUserId(client));
1630 }
1631}
1632
1633
1634public Action Hook_OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype) // todo clean up a bit
1635{
1636 if (attacker > 0 && attacker <= MaxClients && victim > 0 && victim <= MaxClients)
1637 {
1638 if (g_bNoDamage[victim] || g_bNoClip[attacker])
1639 {
1640 damage = 0.0;
1641 return Plugin_Changed;
1642 }
1643 else if (IsValidClient(victim, true, false)|| attacker == victim || IsValidClient(attacker, true, false))
1644 {
1645 ConVar g_bFF = FindConVar("mp_friendlyfire");
1646 if ((g_bVampire[attacker] && GetClientTeam(victim) != GetClientTeam(attacker)) || (g_bVampire[attacker] && g_bFF.BoolValue))
1647 {
1648 int newHP = RoundToFloor(damage * gc_fVampireDamageMultiplier.FloatValue);
1649 newHP += GetClientHealth(attacker);
1650 SetEntityHealth(attacker, newHP);
1651 }
1652
1653 if (g_bSuperKnife[attacker])
1654 {
1655 char weaponName[255];
1656 GetClientWeapon(attacker, weaponName, sizeof(weaponName));
1657
1658 if (StrContains(weaponName, "knife") != -1)
1659 {
1660 damage = 1000.0;
1661 return Plugin_Changed;
1662 }
1663 }
1664 }
1665 }
1666 return Plugin_Continue;
1667}
1668
1669
1670public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
1671{
1672 int water = GetEntProp(client, Prop_Data, "m_nWaterLevel");
1673
1674 // Last button
1675 static bool bPressed[MAXPLAYERS+1] = false;
1676
1677 if (IsPlayerAlive(client))
1678 {
1679 if(g_bGravity[client])
1680 {
1681 if (GetEntityMoveType(client) == MOVETYPE_LADDER)
1682 {
1683 g_bLadder[client] = true;
1684 }
1685 else
1686 {
1687 if (g_bLadder[client])
1688 {
1689 SetEntityGravity(client, gc_fGravValue.FloatValue);
1690 g_bLadder[client] = false;
1691 }
1692 }
1693 }
1694
1695 // Reset when on Ground
1696 if (GetEntityFlags(client) & FL_ONGROUND)
1697 {
1698 g_iFroggyJumped[client] = 0;
1699 bPressed[client] = false;
1700 }
1701 else
1702 {
1703 // Player pressed jump button?
1704 if (buttons & IN_JUMP)
1705 {
1706 if (water <= 1)
1707 {
1708 if (!(GetEntityMoveType(client) & MOVETYPE_LADDER))
1709 {
1710 SetEntPropFloat(client, Prop_Send, "m_flStamina", 0.0);
1711 if (!(GetEntityFlags(client) & FL_ONGROUND) && g_bBhop[client]) buttons &= ~IN_JUMP;
1712 }
1713 }
1714
1715 if (!g_bFroggyJump[client])
1716 return Plugin_Continue;
1717
1718 // For second time?
1719 if (!bPressed[client] && g_iFroggyJumped[client]++ == 1)
1720 {
1721 float velocity[3];
1722 float velocity0;
1723 float velocity1;
1724 float velocity2;
1725 float velocity2_new;
1726
1727 // Get player velocity
1728 velocity0 = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[0]");
1729 velocity1 = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[1]");
1730 velocity2 = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[2]");
1731
1732 velocity2_new = 200.0;
1733
1734 // calculate new velocity^^
1735 if (velocity2 < 150.0) velocity2_new = velocity2_new + 20.0;
1736
1737 if (velocity2 < 100.0) velocity2_new = velocity2_new + 30.0;
1738
1739 if (velocity2 < 50.0) velocity2_new = velocity2_new + 40.0;
1740
1741 if (velocity2 < 0.0) velocity2_new = velocity2_new + 50.0;
1742
1743 if (velocity2 < -50.0) velocity2_new = velocity2_new + 60.0;
1744
1745 if (velocity2 < -100.0) velocity2_new = velocity2_new + 70.0;
1746
1747 if (velocity2 < -150.0) velocity2_new = velocity2_new + 80.0;
1748
1749 if (velocity2 < -200.0) velocity2_new = velocity2_new + 90.0;
1750
1751 // Set new velocity
1752 velocity[0] = velocity0 * 0.1;
1753 velocity[1] = velocity1 * 0.1;
1754 velocity[2] = velocity2_new;
1755
1756 // Double Jump
1757 SetEntPropVector(client, Prop_Send, "m_vecBaseVelocity", velocity);
1758 }
1759
1760 bPressed[client] = true;
1761 }
1762 else bPressed[client] = false;
1763 }
1764 }
1765
1766 return Plugin_Continue;
1767}
1768
1769
1770public Action Hook_OnWeaponCanUse(int client, int weapon)
1771{
1772 if (g_bInvisible[client])
1773 {
1774 char sClassname[32];
1775 GetEdictClassname(weapon, sClassname, sizeof(sClassname));
1776 if (!StrEqual(sClassname, "weapon_knife"))
1777 return Plugin_Handled;
1778 }
1779
1780 if (g_bFly[client])
1781 {
1782 char sClassname[32];
1783 GetEdictClassname(weapon, sClassname, sizeof(sClassname));
1784 if (!StrEqual(sClassname, "weapon_knife"))
1785 return Plugin_Handled;
1786 }
1787
1788 return Plugin_Continue;
1789}
1790
1791
1792public int OnAvailableLR(int Announced)
1793{
1794 g_bIsLR = true;
1795
1796 if (gc_bBuyOnLR.BoolValue)
1797 {
1798 g_bAllowBuy = false;
1799 }
1800
1801 for (int i = 1; i <= MaxClients; i++) if (IsValidClient(i, false, false)) if (GetClientTeam(i) == CS_TEAM_T && gc_bEnable.BoolValue)
1802 {
1803 if (GetAllPlayersCount() >= gc_iMinPlayersToGetCredits.IntValue)
1804 {
1805 if (IsPlayerReservationAdmin(i) && gc_iCreditsVIPLR.IntValue != 0)
1806 {
1807 Forward_OnSetCredits(i,(Forward_OnGetCredits(i)+gc_iCreditsVIPLR.IntValue));
1808 Forward_OnPlayerGetCredits(i, gc_iCreditsVIPLR.IntValue);
1809
1810 if (gc_bNotification.BoolValue) CPrintToChat(i, "%t %t", "shop_tag", "shop_lastrequest", Forward_OnGetCredits(i), gc_iCreditsVIPLR.IntValue);
1811 }
1812 else if (gc_iCreditsLR.IntValue != 0)
1813 {
1814 Forward_OnSetCredits(i,(Forward_OnGetCredits(i)+gc_iCreditsLR.IntValue));
1815 Forward_OnPlayerGetCredits(i, gc_iCreditsLR.IntValue);
1816
1817 if (gc_bNotification.BoolValue) CPrintToChat(i, "%t %t", "shop_tag", "shop_lastrequest", Forward_OnGetCredits(i), gc_iCreditsLR.IntValue);
1818 }
1819 }
1820 if (gc_bRemoveOnLR.BoolValue)
1821 {
1822 SetEntityGravity(i, 1.0);
1823 ResetPlayer(i);
1824 SetEntPropFloat(i, Prop_Data, "m_flLaggedMovementValue", 1.0);
1825 }
1826 }
1827}
1828
1829
1830public void SJD_DoorsOpened(int caller, int activator)
1831{
1832 if (gc_bBuyTimeCells.BoolValue && g_bAllowBuy)
1833 {
1834 g_bAllowBuy = false;
1835 CPrintToChatAll("%t %t", "shop_tag", "shop_buytime");
1836 }
1837
1838 g_bCellsOpen = true;
1839}
1840
1841
1842public void SJD_DoorsClosed(int caller, int activator)
1843{
1844 g_bCellsOpen = false;
1845}
1846
1847
1848public void OnEntityDestroyed(int entity)
1849{
1850 if (!IsValidEdict(entity)) return;
1851
1852 int index = FindValueInArray(g_hThrownKnives, EntIndexToEntRef(entity));
1853 if (index != -1)
1854 {
1855 RemoveFromArray(g_hThrownKnives, index);
1856 }
1857}
1858
1859
1860/******************************************************************************
1861 FUNCTIONS
1862******************************************************************************/
1863
1864
1865stock void DealDamage(int victim,int damage,int attacker = 0,int damagetype = DMG_GENERIC, char[] weapon = "")
1866{
1867 if (victim > 0 && IsValidEdict(victim) && IsClientInGame(victim) && IsPlayerAlive(victim) && damage > 0)
1868 {
1869 int EntityPointHurt = CreateEntityByName("point_hurt");
1870 if (EntityPointHurt != 0)
1871 {
1872 char sDamage[16];
1873 IntToString(damage, sDamage, sizeof(sDamage));
1874
1875 char sDamageType[32];
1876 IntToString(damagetype, sDamageType, sizeof(sDamageType));
1877
1878 DispatchKeyValue(victim, "targetname", "hurtme");
1879 DispatchKeyValue(EntityPointHurt, "DamageTarget", "hurtme");
1880 DispatchKeyValue(EntityPointHurt, "Damage", sDamage);
1881 DispatchKeyValue(EntityPointHurt, "DamageType", sDamageType);
1882 if (!StrEqual(weapon, ""))
1883 {
1884 DispatchKeyValue(EntityPointHurt, "classname", weapon);
1885 }
1886 DispatchSpawn(EntityPointHurt);
1887 AcceptEntityInput(EntityPointHurt, "Hurt", (attacker != 0) ? attacker : -1);
1888 DispatchKeyValue(EntityPointHurt, "classname", "point_hurt");
1889 DispatchKeyValue(victim, "targetname", "donthurtme");
1890
1891 RemoveEdict(EntityPointHurt);
1892 }
1893 }
1894}
1895
1896
1897public Action Hook_SetTransmit(int entity, int client)
1898{
1899 if (entity != client)
1900 return Plugin_Handled;
1901
1902 return Plugin_Continue;
1903}
1904
1905
1906public Action ResetPlayer(int client)
1907{
1908 if (g_bFly[client])
1909 {
1910 g_bFly[client] = false;
1911 ClientCommand(client, "firstperson");
1912 SetEntityModel(client, g_sModelPathPrevious[client]);
1913 SetEntityMoveType(client, MOVETYPE_WALK);
1914 }
1915
1916 if (g_bFakeGuard[client])
1917 {
1918 g_bFakeGuard[client] = false;
1919 SetEntityModel(client, g_sModelPathPrevious[client]);
1920 }
1921
1922 if (g_bInvisible[client])
1923 {
1924 g_bInvisible[client] = false;
1925 SDKUnhook(client, SDKHook_SetTransmit, Hook_SetTransmit);
1926 }
1927
1928 if (gp_bCustomPlayerSkins)
1929 {
1930 UnhookWallhack(client);
1931 }
1932
1933 if (gp_bMyIcons)
1934 {
1935 MyIcons_BlockClientIcon(client, false);
1936 }
1937
1938 g_bRandomTP[client] = false;
1939 g_bNoDamage[client] = false;
1940 g_bPoison[client] = false;
1941 g_bVampire[client] = false;
1942 g_bTeleportSmoke[client] = false;
1943 g_bFireHE[client] = false;
1944 g_bSuperKnife[client] = false;
1945 g_bThrowingKnife[client] = false;
1946 g_bFroggyJump[client] = false;
1947 g_bWallhack[client] = false;
1948 g_bBhop[client] = false;
1949 g_bGravity[client] = false;
1950 g_bOneBulletAWP[client] = false;
1951 g_bOneMagDeagle[client] = false;
1952 g_bMolotov[client] = false;
1953 g_bHealth[client] = false;
1954
1955 Forward_OnResetPlayer(client);
1956}
1957
1958
1959/******************************************************************************
1960 MENU
1961******************************************************************************/
1962
1963
1964public Action Menu_OpenShop(int client)
1965{
1966 char info[124];
1967 Menu menu = CreateMenu(Handler_Menu_OpenShop);
1968 int iCredits = Forward_OnGetCredits(client);
1969
1970 if (!g_bSale)
1971 {
1972 SetMenuTitle(menu, "%t","shop_menu_title", iCredits);
1973 }
1974 else
1975 {
1976 SetMenuTitle(menu, "%t\n%t","shop_menu_title", iCredits, "shop_menu_title_sale", gc_fSale.IntValue);
1977 }
1978
1979 if (GetClientTeam(client) == CS_TEAM_T)
1980 {
1981 if (gp_bSmartJailDoors)
1982 {
1983 if (SJD_IsCurrentMapConfigured())
1984 {
1985 Format(info, sizeof(info), "%T","shop_menu_openjail", client, gc_iOpenCells.IntValue);
1986 if (iCredits >= gc_iOpenCells.IntValue && gc_iOpenCells.IntValue != 0 && g_bAllowBuy && !g_bCellsOpen && CheckVipFlag(client, g_sOpenCellsFlag)) AddMenuItem(menu, "Doors", info);
1987 else if (gc_iOpenCells.IntValue != 0 && CheckVipFlag(client, g_sOpenCellsFlag)) AddMenuItem(menu, "Doors", info, ITEMDRAW_DISABLED);
1988 }
1989 }
1990
1991 Format(info, sizeof(info), "%T","shop_menu_heal", client, gc_iHeal.IntValue);
1992 if (gc_iHealOnlyTeam.IntValue >= 1 && iCredits >= gc_iHeal.IntValue && gc_iHeal.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && CheckVipFlag(client, g_sHealFlag)) AddMenuItem(menu, "Heal", info);
1993 else if (gc_iHealOnlyTeam.IntValue >= 1 && gc_iHeal.IntValue != 0 && CheckVipFlag(client, g_sHealFlag)) AddMenuItem(menu, "Heal", info, ITEMDRAW_DISABLED);
1994
1995 Format(info, sizeof(info), "%T","shop_menu_health", client, gc_iHealth.IntValue, gc_iHealthExtra.IntValue);
1996 if (gc_iHealthExtraOnlyTeam.IntValue >= 1 && iCredits >= gc_iHealth.IntValue && gc_iHealth.IntValue != 0 && g_bAllowBuy && !g_bHealth[client] && IsPlayerAlive(client) && CheckVipFlag(client, g_sHealthFlag)) AddMenuItem(menu, "Health", info);
1997 else if (gc_iHealthExtraOnlyTeam.IntValue >= 1 && gc_iHealth.IntValue != 0 && CheckVipFlag(client, g_sHealthFlag)) AddMenuItem(menu, "Health", info, ITEMDRAW_DISABLED);
1998
1999 Format(info, sizeof(info), "%T","shop_menu_revive", client, gc_iRevive.IntValue);
2000 if (gc_iReviveOnlyTeam.IntValue >= 1 && iCredits >= gc_iRevive.IntValue && gc_iRevive.IntValue != 0 && !IsPlayerAlive(client) && !g_bIsLR && GetAlivePlayersCount(GetClientTeam(client)) > 1 && CheckVipFlag(client, g_sReviveFlag)) AddMenuItem(menu, "Revive", info);
2001 else if (gc_iReviveOnlyTeam.IntValue >= 1 && gc_iRevive.IntValue != 0 && CheckVipFlag(client, g_sReviveFlag)) AddMenuItem(menu, "Revive", info, ITEMDRAW_DISABLED);
2002
2003 Format(info, sizeof(info), "%T","shop_menu_vampire", client, gc_iVampire.IntValue);
2004 if (iCredits >= gc_iVampire.IntValue && gc_iVampire.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && CheckVipFlag(client, g_sVampireFlag)) AddMenuItem(menu, "Vampire", info);
2005 else if (gc_iVampire.IntValue != 0 && CheckVipFlag(client, g_sVampireFlag)) AddMenuItem(menu, "Vampire", info, ITEMDRAW_DISABLED);
2006
2007 Format(info, sizeof(info), "%T","shop_menu_bhop", client, gc_iBhop.IntValue);
2008 if (gc_iBhopOnlyTeam.IntValue >= 1 && iCredits >= gc_iBhop.IntValue && gc_iBhop.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && !g_bFroggyJump[client] && CheckVipFlag(client, g_sBhopFlag)) AddMenuItem(menu, "Bhop", info);
2009 else if (gc_iBhopOnlyTeam.IntValue >= 1 && gc_iBhop.IntValue != 0 && CheckVipFlag(client, g_sBhopFlag)) AddMenuItem(menu, "Bhop", info, ITEMDRAW_DISABLED);
2010
2011 Format(info, sizeof(info), "%T","shop_menu_froggyjump", client, gc_iFroggyJump.IntValue);
2012 if (gc_iFroggyJumpOnlyTeam.IntValue >= 1 && iCredits >= gc_iFroggyJump.IntValue && gc_iFroggyJump.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && !g_bBhop[client] && CheckVipFlag(client, g_sFroggyJumpFlag)) AddMenuItem(menu, "FroggyJump", info);
2013 else if (gc_iFroggyJumpOnlyTeam.IntValue >= 1 && gc_iFroggyJump.IntValue != 0 && CheckVipFlag(client, g_sFroggyJumpFlag)) AddMenuItem(menu, "FroggyJump", info, ITEMDRAW_DISABLED);
2014
2015 Format(info, sizeof(info), "%T","shop_menu_gravity", client, gc_iGravity.IntValue);
2016 if (gc_iGravOnlyTeam.IntValue >= 1 && iCredits >= gc_iGravity.IntValue && gc_iGravity.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && !g_bGravity[client] && CheckVipFlag(client, g_sGravityFlag)) AddMenuItem(menu, "Gravity", info);
2017 else if (gc_iGravOnlyTeam.IntValue >= 1 && gc_iGravity.IntValue != 0 && CheckVipFlag(client, g_sGravityFlag)) AddMenuItem(menu, "Gravity", info, ITEMDRAW_DISABLED);
2018
2019 Format(info, sizeof(info), "%T","shop_menu_invisible", client, gc_iInvisible.IntValue, RoundToCeil(gc_fInvisibleTime.FloatValue));
2020 if (iCredits >= gc_iInvisible.IntValue && gc_iInvisible.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && CheckVipFlag(client, g_sInvisibleFlag)) AddMenuItem(menu, "Invisible", info);
2021 else if (gc_iInvisible.IntValue != 0 && CheckVipFlag(client, g_sInvisibleFlag))AddMenuItem(menu, "Invisible", info, ITEMDRAW_DISABLED);
2022
2023 Format(info, sizeof(info), "%T","shop_menu_nodamage", client, gc_iNoDamage.IntValue, RoundToCeil(gc_fNoDamageTime.FloatValue));
2024 if (gc_iNoDamageOnlyTeam.IntValue >= 1 && iCredits >= gc_iNoDamage.IntValue && gc_iNoDamage.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && CheckVipFlag(client, g_sNoDamageFlag)) AddMenuItem(menu, "NoDamage", info);
2025 else if (gc_iNoDamageOnlyTeam.IntValue >= 1 && gc_iNoDamage.IntValue != 0 && CheckVipFlag(client, g_sNoDamageFlag)) AddMenuItem(menu, "NoDamage", info, ITEMDRAW_DISABLED);
2026
2027 Format(info, sizeof(info), "%T","shop_menu_noclip", client, gc_iNoClip.IntValue, RoundToCeil(gc_fNoClipTime.FloatValue));
2028 if (iCredits >= gc_iNoClip.IntValue && gc_iNoClip.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && CheckVipFlag(client, g_sNoClipFlag)) AddMenuItem(menu, "NoClip", info);
2029 else if (gc_iNoClip.IntValue != 0 && CheckVipFlag(client, g_sNoClipFlag)) AddMenuItem(menu, "NoClip", info, ITEMDRAW_DISABLED);
2030
2031 if (gp_bCustomPlayerSkins)
2032 {
2033 Format(info, sizeof(info), "%T","shop_menu_wallhack", client, gc_iWallhack.IntValue);
2034 if (gc_iWallhackOnlyTeam.IntValue >= 1 && iCredits >= gc_iWallhack.IntValue && gc_iWallhack.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && CheckVipFlag(client, g_sWallhackFlag)) AddMenuItem(menu, "Wallhack", info);
2035 else if (gc_iWallhackOnlyTeam.IntValue >= 1 && gc_iWallhack.IntValue != 0 && CheckVipFlag(client, g_sWallhackFlag)) AddMenuItem(menu, "Wallhack", info, ITEMDRAW_DISABLED);
2036 }
2037
2038 if (gp_bMyJBWarden)
2039 {
2040 if (g_bHandcuff != null)
2041 {
2042 if (g_bHandcuff.BoolValue)
2043 {
2044 Format(info, sizeof(info), "%T","shop_menu_paperclip", client, gc_iPaperClip.IntValue, gc_iPaperClipAmount.IntValue);
2045 if (iCredits >= gc_iPaperClip.IntValue && gc_iPaperClip.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && CheckVipFlag(client, g_sPaperClipFlag)) AddMenuItem(menu, "PaperClip", info);
2046 else if (gc_iPaperClip.IntValue != 0 && CheckVipFlag(client, g_sPaperClipFlag)) AddMenuItem(menu, "PaperClip", info, ITEMDRAW_DISABLED);
2047 }
2048 }
2049 }
2050
2051 Format(info, sizeof(info), "%T","shop_menu_model", client, gc_iFakeModel.IntValue);
2052 if (iCredits >= gc_iFakeModel.IntValue && gc_iFakeModel.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && CheckVipFlag(client, g_sFakeModelFlag)) AddMenuItem(menu, "FakeModel", info);
2053 else if (gc_iFakeModel.IntValue != 0 && CheckVipFlag(client, g_sFakeModelFlag)) AddMenuItem(menu, "FakeModel", info, ITEMDRAW_DISABLED);
2054
2055 Format(info, sizeof(info), "%T","shop_menu_teleportsmoke", client, gc_iTeleportSmoke.IntValue);
2056 if (iCredits >= gc_iTeleportSmoke.IntValue && gc_iTeleportSmoke.IntValue != 0 && g_bAllowBuy && !g_bTeleportSmoke[client] && IsPlayerAlive(client) && CheckVipFlag(client, g_sTeleportSmokeFlag)) AddMenuItem(menu, "TeleportSmoke", info);
2057 else if (gc_iTeleportSmoke.IntValue != 0 && CheckVipFlag(client, g_sTeleportSmokeFlag)) AddMenuItem(menu, "TeleportSmoke", info, ITEMDRAW_DISABLED);
2058
2059 Format(info, sizeof(info), "%T","shop_menu_poisonsmoke", client, gc_iPoisonSmoke.IntValue);
2060 if (iCredits >= gc_iPoisonSmoke.IntValue && gc_iPoisonSmoke.IntValue != 0 && g_bAllowBuy && !g_bPoison[client] && IsPlayerAlive(client) && CheckVipFlag(client, g_sPoisonSmokeFlag)) AddMenuItem(menu, "PoisonSmoke", info);
2061 else if (gc_iPoisonSmoke.IntValue != 0 && CheckVipFlag(client, g_sPoisonSmokeFlag)) AddMenuItem(menu, "PoisonSmoke", info, ITEMDRAW_DISABLED);
2062
2063 Format(info, sizeof(info), "%T","shop_menu_firegrenade", client, gc_iFireHE.IntValue);
2064 if (iCredits >= gc_iFireHE.IntValue && gc_iFireHE.IntValue != 0 && g_bAllowBuy && !g_bFireHE[client] && IsPlayerAlive(client) && CheckVipFlag(client, g_sFireHEFlag)) AddMenuItem(menu, "FireGrenade", info);
2065 else if (gc_iFireHE.IntValue != 0 && CheckVipFlag(client, g_sFireHEFlag)) AddMenuItem(menu, "FireGrenade", info, ITEMDRAW_DISABLED);
2066
2067 Format(info, sizeof(info), "%T","shop_menu_awp", client, gc_iAWP.IntValue);
2068 if (iCredits >= gc_iAWP.IntValue && gc_iAWP.IntValue != 0 && g_bAllowBuy && !g_bOneBulletAWP[client] && IsPlayerAlive(client) && CheckVipFlag(client, g_sAWPFlag)) AddMenuItem(menu, "AWP", info);
2069 else if (gc_iAWP.IntValue != 0 && CheckVipFlag(client, g_sAWPFlag)) AddMenuItem(menu, "AWP", info, ITEMDRAW_DISABLED);
2070
2071 Format(info, sizeof(info), "%T","shop_menu_deagle", client, gc_iDeagle.IntValue);
2072 if (iCredits >= gc_iDeagle.IntValue && gc_iDeagle.IntValue != 0 && g_bAllowBuy && !g_bOneMagDeagle[client] && IsPlayerAlive(client) && CheckVipFlag(client, g_sDeagleFlag)) AddMenuItem(menu, "Deagle", info);
2073 else if (gc_iDeagle.IntValue != 0 && CheckVipFlag(client, g_sDeagleFlag)) AddMenuItem(menu, "Deagle", info, ITEMDRAW_DISABLED);
2074
2075 Format(info, sizeof(info), "%T","shop_menu_knife", client, gc_iKnife.IntValue);
2076 if (iCredits >= gc_iKnife.IntValue && gc_iKnife.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && !g_bSuperKnife[client] && CheckVipFlag(client, g_sKnifeFlag)) AddMenuItem(menu, "Knife", info);
2077 else if (gc_iKnife.IntValue != 0 && CheckVipFlag(client, g_sKnifeFlag)) AddMenuItem(menu, "Knife", info, ITEMDRAW_DISABLED);
2078
2079 Format(info, sizeof(info), "%T","shop_menu_throwingknife", client, gc_iThrowKnife.IntValue);
2080 if (iCredits >= gc_iThrowKnife.IntValue && gc_iThrowKnife.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && !g_bThrowingKnife[client] && CheckVipFlag(client, g_sThrowKnifeFlag)) AddMenuItem(menu, "ThrowingKnife", info);
2081 else if (gc_iThrowKnife.IntValue != 0 && CheckVipFlag(client, g_sThrowKnifeFlag)) AddMenuItem(menu, "ThrowingKnife", info, ITEMDRAW_DISABLED);
2082
2083 Format(info, sizeof(info), "%T","shop_menu_taser", client, gc_iTaser.IntValue);
2084 if (iCredits >= gc_iTaser.IntValue && gc_iTaser.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && CheckVipFlag(client, g_sTaserFlag)) AddMenuItem(menu, "Taser", info);
2085 else if (gc_iTaser.IntValue != 0 && CheckVipFlag(client, g_sTaserFlag)) AddMenuItem(menu, "Taser", info, ITEMDRAW_DISABLED);
2086
2087 Format(info, sizeof(info), "%T","shop_menu_molotov", client, gc_iMolotov.IntValue);
2088 if (iCredits >= gc_iMolotov.IntValue && gc_iMolotov.IntValue != 0 && g_bAllowBuy && !g_bMolotov[client] && IsPlayerAlive(client) && CheckVipFlag(client, g_sMolotovFlag)) AddMenuItem(menu, "Molotov", info);
2089 else if (gc_iMolotov.IntValue != 0 && CheckVipFlag(client, g_sMolotovFlag)) AddMenuItem(menu, "Molotov", info, ITEMDRAW_DISABLED);
2090
2091 Format(info, sizeof(info), "%T","shop_menu_bird", client, gc_iBird.IntValue);
2092 if (iCredits >= gc_iBird.IntValue && gc_iBird.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && CheckVipFlag(client, g_sBirdFlag)) AddMenuItem(menu, "Bird", info);
2093 else if (gc_iBird.IntValue != 0 && CheckVipFlag(client, g_sBirdFlag)) AddMenuItem(menu, "Bird", info, ITEMDRAW_DISABLED);
2094
2095 Format(info, sizeof(info), "%T", "shop_menu_randomtp", client, gc_iRandomTP.IntValue);
2096 if (iCredits >= gc_iRandomTP.IntValue && gc_iRandomTP.IntValue != 0 && g_bAllowBuy && !g_bRandomTP[client] && IsPlayerAlive(client) && CheckVipFlag(client, g_sRandomTPFlag) && GetAlivePlayersCount(CS_TEAM_T) > 1) AddMenuItem(menu, "RandomTP", info);
2097 else if (gc_iRandomTP.IntValue != 0 && CheckVipFlag(client, g_sRandomTPFlag))AddMenuItem(menu, "RandomTP", info, ITEMDRAW_DISABLED);
2098 }
2099 else if (GetClientTeam(client) == CS_TEAM_CT)
2100 {
2101 Format(info, sizeof(info), "%T","shop_menu_heal", client, gc_iHeal.IntValue);
2102 if (gc_iHealOnlyTeam.IntValue <= 1 && iCredits >= gc_iHeal.IntValue && gc_iHeal.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && CheckVipFlag(client, g_sHealFlag)) AddMenuItem(menu, "Heal", info);
2103 else if (gc_iHealOnlyTeam.IntValue <= 1 && gc_iHeal.IntValue != 0 && CheckVipFlag(client, g_sHealFlag)) AddMenuItem(menu, "Heal", info, ITEMDRAW_DISABLED);
2104
2105 Format(info, sizeof(info), "%T","shop_menu_health", client, gc_iHealth.IntValue, gc_iHealthExtra.IntValue);
2106 if (gc_iHealthExtraOnlyTeam.IntValue <= 1 && iCredits >= gc_iHealth.IntValue && gc_iHealth.IntValue != 0 && g_bAllowBuy && !g_bHealth[client] && IsPlayerAlive(client) && CheckVipFlag(client, g_sHealthFlag)) AddMenuItem(menu, "Health", info);
2107 else if (gc_iHealthExtraOnlyTeam.IntValue <= 1 && gc_iHealth.IntValue != 0 && CheckVipFlag(client, g_sHealthFlag)) AddMenuItem(menu, "Health", info, ITEMDRAW_DISABLED);
2108
2109 Format(info, sizeof(info), "%T","shop_menu_revive", client, gc_iRevive.IntValue);
2110 if (gc_iReviveOnlyTeam.IntValue <= 1 && iCredits >= gc_iRevive.IntValue && gc_iRevive.IntValue != 0 && !IsPlayerAlive(client) && !g_bIsLR && GetAlivePlayersCount(GetClientTeam(client)) > 1 && CheckVipFlag(client, g_sReviveFlag)) AddMenuItem(menu, "Revive", info);
2111 else if (gc_iReviveOnlyTeam.IntValue <= 1 && gc_iRevive.IntValue != 0 && CheckVipFlag(client, g_sReviveFlag)) AddMenuItem(menu, "Revive", info, ITEMDRAW_DISABLED);
2112
2113 Format(info, sizeof(info), "%T","shop_menu_bhop", client, gc_iBhop.IntValue);
2114 if (gc_iBhopOnlyTeam.IntValue <= 1 && iCredits >= gc_iBhop.IntValue && gc_iBhop.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && !g_bFroggyJump[client] && CheckVipFlag(client, g_sBhopFlag)) AddMenuItem(menu, "Bhop", info);
2115 else if (gc_iBhopOnlyTeam.IntValue <= 1 && gc_iBhop.IntValue != 0 && CheckVipFlag(client, g_sBhopFlag)) AddMenuItem(menu, "Bhop", info, ITEMDRAW_DISABLED);
2116
2117 Format(info, sizeof(info), "%T","shop_menu_froggyjump", client, gc_iFroggyJump.IntValue);
2118 if (gc_iFroggyJumpOnlyTeam.IntValue <= 1 && iCredits >= gc_iFroggyJump.IntValue && gc_iFroggyJump.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && !g_bBhop[client] && CheckVipFlag(client, g_sFroggyJumpFlag)) AddMenuItem(menu, "FroggyJump", info);
2119 else if (gc_iFroggyJumpOnlyTeam.IntValue <= 1 && gc_iFroggyJump.IntValue != 0 && CheckVipFlag(client, g_sFroggyJumpFlag)) AddMenuItem(menu, "FroggyJump", info, ITEMDRAW_DISABLED);
2120
2121 Format(info, sizeof(info), "%T","shop_menu_gravity", client, gc_iGravity.IntValue);
2122 if (gc_iGravOnlyTeam.IntValue <= 1 && iCredits >= gc_iGravity.IntValue && gc_iGravity.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && CheckVipFlag(client, g_sGravityFlag)) AddMenuItem(menu, "Gravity", info);
2123 else if (gc_iGravOnlyTeam.IntValue <= 1 && gc_iGravity.IntValue != 0 && CheckVipFlag(client, g_sGravityFlag)) AddMenuItem(menu, "Gravity", info, ITEMDRAW_DISABLED);
2124
2125 Format(info, sizeof(info), "%T","shop_menu_nodamage", client, gc_iNoDamage.IntValue, RoundToCeil(gc_fNoDamageTime.FloatValue));
2126 if (gc_iNoDamageOnlyTeam.IntValue <= 1 && iCredits >= gc_iNoDamage.IntValue && gc_iNoDamage.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && CheckVipFlag(client, g_sNoDamageFlag)) AddMenuItem(menu, "NoDamage", info);
2127 else if (gc_iNoDamageOnlyTeam.IntValue <= 1 && gc_iNoDamage.IntValue != 0 && CheckVipFlag(client, g_sNoDamageFlag)) AddMenuItem(menu, "NoDamage", info, ITEMDRAW_DISABLED);
2128
2129 if (gp_bCustomPlayerSkins)
2130 {
2131 Format(info, sizeof(info), "%T","shop_menu_wallhack", client, gc_iWallhack.IntValue);
2132 if (gc_iWallhackOnlyTeam.IntValue <= 1 && iCredits >= gc_iWallhack.IntValue && gc_iWallhack.IntValue != 0 && g_bAllowBuy && IsPlayerAlive(client) && CheckVipFlag(client, g_sWallhackFlag)) AddMenuItem(menu, "Wallhack", info);
2133 else if (gc_iWallhackOnlyTeam.IntValue <= 1 && gc_iWallhack.IntValue != 0 && CheckVipFlag(client, g_sWallhackFlag)) AddMenuItem(menu, "Wallhack", info, ITEMDRAW_DISABLED);
2134 }
2135 }
2136
2137 Call_StartForward(gF_hOnShopMenu);
2138 Call_PushCell(client);
2139 Call_PushCell(menu);
2140 Call_Finish();
2141
2142 menu.ExitButton = true;
2143 menu.Display(client, MENU_TIME_FOREVER);
2144
2145 return Plugin_Handled;
2146}
2147
2148
2149public int Handler_Menu_OpenShop(Menu menu, MenuAction action, int client, int itemNum)
2150{
2151 Call_StartForward(gF_hOnShopMenuHandler);
2152 Call_PushCell(menu);
2153 Call_PushCell(action);
2154 Call_PushCell(client);
2155 Call_PushCell(itemNum);
2156 Call_Finish();
2157
2158 if (action == MenuAction_Select)
2159 {
2160 if (g_bAllowBuy && gc_bEnable.BoolValue)
2161 {
2162 if (gp_bMyJailBreak && !gc_bEventdays.BoolValue)
2163 {
2164 if (MyJailbreak_IsEventDayRunning())
2165 {
2166 CReplyToCommand(client, "%t %t", "shop_tag", "shop_disabled");
2167 return;
2168 }
2169 }
2170
2171 char info[32];
2172 menu.GetItem(itemNum, info, sizeof(info));
2173
2174 if (strcmp(info,"Invisible") == 0)
2175 {
2176 Item_Invisible(client, info);
2177 }
2178 else if (strcmp(info,"AWP") == 0)
2179 {
2180 Item_AWP(client, info);
2181 }
2182 else if (strcmp(info,"NoDamage") == 0)
2183 {
2184 Item_NoDamage(client, info);
2185 }
2186 else if (strcmp(info,"Doors") == 0)
2187 {
2188 Item_Doors(client, info);
2189 }
2190 else if (strcmp(info,"Vampire") == 0)
2191 {
2192 Item_Vampire(client, info);
2193 }
2194 else if (strcmp(info,"Health") == 0)
2195 {
2196 Item_Health(client, info);
2197 }
2198 else if (strcmp(info,"Deagle") == 0)
2199 {
2200 Item_Deagle(client, info);
2201 }
2202 else if (strcmp(info,"Knife") == 0)
2203 {
2204 Item_Knife(client, info);
2205 }
2206 else if (strcmp(info,"Heal") == 0)
2207 {
2208 Item_Heal(client, info);
2209 }
2210 else if (strcmp(info,"Molotov") == 0)
2211 {
2212 Item_Molotov(client, info);
2213 }
2214 else if (strcmp(info,"FakeModel") == 0)
2215 {
2216 Item_FakeModel(client, info);
2217 }
2218 else if (strcmp(info,"PoisonSmoke") == 0)
2219 {
2220 Item_PoisonSmoke(client, info);
2221 }
2222 else if (strcmp(info,"Bird") == 0)
2223 {
2224 Item_Bird(client, info);
2225 }
2226 else if (strcmp(info,"TeleportSmoke") == 0)
2227 {
2228 Item_TeleportSmoke(client, info);
2229 }
2230 else if (strcmp(info,"FireGrenade") == 0)
2231 {
2232 Item_FireGrenade(client, info);
2233 }
2234 else if (strcmp(info,"Bhop") == 0)
2235 {
2236 Item_Bhop(client, info);
2237 }
2238 else if (strcmp(info,"Gravity") == 0)
2239 {
2240 Item_Gravity(client, info);
2241 }
2242 else if (strcmp(info,"Taser") == 0)
2243 {
2244 Item_Taser(client, info);
2245 }
2246 else if (strcmp(info,"NoClip") == 0)
2247 {
2248 Item_NoClip(client, info);
2249 }
2250 else if (strcmp(info,"Revive") == 0)
2251 {
2252 Item_Revive(client, info);
2253 }
2254 else if (strcmp(info,"Wallhack") == 0)
2255 {
2256 Item_Wallhack(client, info);
2257 }
2258 else if (strcmp(info,"ThrowingKnife") == 0)
2259 {
2260 Item_ThrowingKnife(client, info);
2261 }
2262 else if (strcmp(info,"FroggyJump") == 0)
2263 {
2264 Item_FroggyJump(client, info);
2265 }
2266 else if (strcmp(info,"PaperClip") == 0)
2267 {
2268 Item_PaperClip(client, info);
2269 }
2270 else if (strcmp(info, "RandomTP") == 0)
2271 {
2272 Item_RandomTP(client, info);
2273 }
2274
2275 if (!gc_bClose.BoolValue)
2276 {
2277 Menu_OpenShop(client);
2278 }
2279 }
2280 else CPrintToChat(client, "%t %t", "shop_tag", "shop_buytime");
2281 }
2282}
2283
2284
2285/******************************************************************************
2286 'ITEMS'
2287******************************************************************************/
2288
2289
2290void Item_Invisible(int client, char[] name)
2291{
2292 if (IsPlayerAlive(client))
2293 {
2294 if (Forward_OnGetCredits(client) >= gc_iInvisible.IntValue)
2295 {
2296 SDKHook(client, SDKHook_SetTransmit, Hook_SetTransmit);
2297 g_bInvisible[client] = true;
2298 CreateTimer(gc_fInvisibleTime.FloatValue, Timer_Invisible, GetClientUserId(client));
2299
2300 StripAllPlayerWeapons(client);
2301 GivePlayerItem(client, "weapon_knife");
2302
2303 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iInvisible.IntValue));
2304 Forward_OnPlayerBuyItem(client, name);
2305
2306 if (gp_bMyIcons) MyIcons_BlockClientIcon(client, true);
2307
2308 CPrintToChat(client, "%t %t", "shop_tag", "shop_invisible", RoundToCeil(gc_fInvisibleTime.FloatValue));
2309 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iInvisible.IntValue);
2310 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Invisible", client);
2311 }
2312 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iInvisible.IntValue);
2313 }
2314 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2315}
2316
2317
2318void Item_AWP(int client, char[] name)
2319{
2320 if (g_bOneBulletAWP[client])
2321 {
2322 CPrintToChat(client, "%t %t", "shop_tag", "shop_max");
2323 }
2324 else if (IsPlayerAlive(client))
2325 {
2326 if (Forward_OnGetCredits(client) >= gc_iAWP.IntValue)
2327 {
2328 int weapon;
2329 if ((weapon = GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY)) != -1) // if player has already a weapon
2330 {
2331 SDKHooks_DropWeapon(client, weapon, NULL_VECTOR, NULL_VECTOR);
2332 if (gc_bRemoveWeapon.BoolValue) AcceptEntityInput(weapon, "Kill");
2333 }
2334 int iAWP = GivePlayerItem(client, "weapon_awp");
2335 g_bOneBulletAWP[client] = true;
2336 SetPlayerAmmo(client, iAWP, 1, 0);
2337 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iAWP.IntValue));
2338 Forward_OnPlayerBuyItem(client, name);
2339
2340 CPrintToChat(client, "%t %t", "shop_tag", "shop_awp");
2341 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iAWP.IntValue);
2342 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: AWP", client);
2343 }
2344 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iAWP.IntValue);
2345 }
2346 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2347}
2348
2349
2350void Item_NoDamage(int client, char[] name)
2351{
2352 if (IsPlayerAlive(client))
2353 {
2354 if (Forward_OnGetCredits(client) >= gc_iNoDamage.IntValue)
2355 {
2356 g_bNoDamage[client] = true;
2357 CreateTimer(gc_fNoDamageTime.FloatValue, Timer_NoDamage, GetClientUserId(client));
2358 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iNoDamage.IntValue));
2359 Forward_OnPlayerBuyItem(client, name);
2360
2361 CPrintToChat(client, "%t %t", "shop_tag", "shop_nodamage", RoundToCeil(gc_fNoDamageTime.FloatValue));
2362 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iNoDamage.IntValue);
2363 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: No Damage", client);
2364 }
2365 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iNoDamage.IntValue);
2366 }
2367 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2368}
2369
2370
2371void Item_Doors(int client, char[] name)
2372{
2373 if (!g_bCellsOpen)
2374 {
2375 if (Forward_OnGetCredits(client) >= gc_iOpenCells.IntValue)
2376 {
2377 SJD_OpenDoors();
2378 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iOpenCells.IntValue));
2379 Forward_OnPlayerBuyItem(client, name);
2380
2381 CPrintToChat(client, "%t %t", "shop_tag", "shop_opencell");
2382 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iOpenCells.IntValue);
2383 CPrintToChatAll("%t %t", "shop_tag", "shop_opencellall", client);
2384 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Open cells", client);
2385 }
2386 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iOpenCells.IntValue);
2387 }
2388 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alreadyopen");
2389}
2390
2391
2392void Item_Vampire(int client, char[] name)
2393{
2394 if (IsPlayerAlive(client))
2395 {
2396 if (Forward_OnGetCredits(client) >= gc_iVampire.IntValue)
2397 {
2398 SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", gc_fVampireSpeed.FloatValue);
2399 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iVampire.IntValue));
2400 Forward_OnPlayerBuyItem(client, name);
2401 g_bVampire[client] = true;
2402
2403 CPrintToChat(client, "%t %t", "shop_tag", "shop_vapire");
2404 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iVampire.IntValue);
2405 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Vampire", client);
2406 }
2407 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iVampire.IntValue);
2408 }
2409 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2410}
2411
2412
2413void Item_Health(int client, char[] name)
2414{
2415 if (g_bHealth[client])
2416 {
2417 CPrintToChat(client, "%t %t", "shop_tag", "shop_max");
2418 }
2419 else if (IsPlayerAlive(client))
2420 {
2421 if (Forward_OnGetCredits(client) >= gc_iHealth.IntValue)
2422 {
2423 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iHealth.IntValue));
2424 Forward_OnPlayerBuyItem(client, name);
2425
2426 int health = (GetClientHealth(client) + gc_iHealthExtra.IntValue);
2427 SetEntityHealth(client, health);
2428 GivePlayerItem(client, "_assaultsuit");
2429 SetEntProp(client, Prop_Send, "m_ArmorValue", 100, 1);
2430 g_bHealth[client] = true;
2431
2432 CPrintToChat(client, "%t %t", "shop_tag", "shop_health", gc_iHealthExtra.IntValue);
2433 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iHealth.IntValue);
2434 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Health", client);
2435 }
2436 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iHealth.IntValue);
2437 }
2438 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2439}
2440
2441
2442void Item_Deagle(int client, char[] name)
2443{
2444 if (g_bOneMagDeagle[client])
2445 {
2446 CPrintToChat(client, "%t %t", "shop_tag", "shop_max");
2447 }
2448 else if (IsPlayerAlive(client))
2449 {
2450 if (Forward_OnGetCredits(client) >= gc_iDeagle.IntValue)
2451 {
2452 int weapon;
2453 if ((weapon = GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY)) != -1) // if player has already a weapon
2454 {
2455 SDKHooks_DropWeapon(client, weapon, NULL_VECTOR, NULL_VECTOR);
2456 if (gc_bRemoveWeapon.BoolValue) AcceptEntityInput(weapon, "Kill");
2457 }
2458 int iDeagle = GivePlayerItem(client, "weapon_deagle");
2459 g_bOneMagDeagle[client] = true;
2460 SetPlayerAmmo(client, iDeagle, 7, 0);
2461
2462 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iDeagle.IntValue));
2463 Forward_OnPlayerBuyItem(client, name);
2464
2465 CPrintToChat(client, "%t %t", "shop_tag", "shop_deagle");
2466 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iDeagle.IntValue);
2467 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Deagle", client);
2468 }
2469 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iDeagle.IntValue);
2470 }
2471 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2472}
2473
2474
2475void Item_Knife(int client, char[] name)
2476{
2477 if (IsPlayerAlive(client))
2478 {
2479 if (Forward_OnGetCredits(client) >= gc_iKnife.IntValue)
2480 {
2481 int currentknife = GetPlayerWeaponSlot(client, CS_SLOT_KNIFE);
2482 if (IsValidEntity(currentknife) && currentknife != INVALID_ENT_REFERENCE)
2483 {
2484 RemovePlayerItem(client, currentknife);
2485 RemoveEdict(currentknife);
2486 }
2487 GivePlayerItem(client, "weapon_knifegg");
2488
2489 g_bSuperKnife[client] = true;
2490 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iKnife.IntValue));
2491 Forward_OnPlayerBuyItem(client, name);
2492
2493 CPrintToChat(client, "%t %t", "shop_tag", "shop_knife");
2494 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iKnife.IntValue);
2495 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: One hit knife", client);
2496 }
2497 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iKnife.IntValue);
2498 }
2499 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2500}
2501
2502
2503void Item_Heal(int client, char[] name)
2504{
2505 if (IsPlayerAlive(client))
2506 {
2507 if (Forward_OnGetCredits(client) >= gc_iHeal.IntValue)
2508 {
2509 int health = GetEntProp(client, Prop_Send, "m_iHealth");
2510
2511 if (health >= 100)
2512 {
2513 CPrintToChat(client, "%t %t", "shop_tag", "shop_fulllive");
2514 }
2515 else
2516 {
2517 SetEntityHealth(client, 100);
2518 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iHeal.IntValue));
2519 Forward_OnPlayerBuyItem(client, name);
2520
2521 EmitSoundToAll("medicsound/medic.wav");
2522 CPrintToChat(client, "%t %t", "shop_tag", "shop_heal");
2523 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iHeal.IntValue);
2524 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: heal", client);
2525 }
2526 }
2527 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iHeal.IntValue);
2528 }
2529 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2530}
2531
2532
2533void Item_Molotov(int client, char[] name)
2534{
2535 if (g_bMolotov[client])
2536 {
2537 CPrintToChat(client, "%t %t", "shop_tag", "shop_max");
2538 }
2539 else if (IsPlayerAlive(client))
2540 {
2541 if (Forward_OnGetCredits(client) >= gc_iMolotov.IntValue)
2542 {
2543 GivePlayerItem(client, "weapon_molotov");
2544 GivePlayerItem(client, "weapon_flashbang");
2545 GivePlayerItem(client, "weapon_flashbang");
2546 g_bMolotov[client] = true;
2547 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iMolotov.IntValue));
2548 Forward_OnPlayerBuyItem(client, name);
2549
2550 CPrintToChat(client, "%t %t", "shop_tag", "shop_molotov");
2551 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iMolotov.IntValue);
2552 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Molotov", client);
2553 }
2554 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iMolotov.IntValue);
2555 }
2556 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2557}
2558
2559
2560void Item_FakeModel(int client, char[] name)
2561{
2562 if (IsPlayerAlive(client))
2563 {
2564 if (Forward_OnGetCredits(client) >= gc_iFakeModel.IntValue)
2565 {
2566 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iFakeModel.IntValue));
2567 Forward_OnPlayerBuyItem(client, name);
2568
2569 g_bFakeGuard[client] = true;
2570
2571 GetEntPropString(client, Prop_Data, "m_ModelName", g_sModelPathPrevious[client], sizeof(g_sModelPathPrevious[]));
2572 SetEntityModel(client, g_sModelPathFakeGuard);
2573
2574 CPrintToChat(client, "%t %t", "shop_tag", "shop_model");
2575 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iFakeModel.IntValue);
2576 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: FakeModel", client);
2577 if (gp_bMyIcons) MyIcons_BlockClientIcon(client, true);
2578 }
2579 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iFakeModel.IntValue);
2580 }
2581 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2582}
2583
2584
2585void Item_PoisonSmoke(int client, char[] name)
2586{
2587 if (IsPlayerAlive(client))
2588 {
2589 if (Forward_OnGetCredits(client) >= gc_iPoisonSmoke.IntValue)
2590 {
2591 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iPoisonSmoke.IntValue));
2592 Forward_OnPlayerBuyItem(client, name);
2593
2594 GivePlayerItem(client, "weapon_smokegrenade");
2595
2596 g_bPoison[client] = true;
2597
2598 CPrintToChat(client, "%t %t", "shop_tag", "shop_poisensmoke");
2599 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iPoisonSmoke.IntValue);
2600 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Poison smoke", client);
2601 }
2602 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iPoisonSmoke.IntValue);
2603 }
2604 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2605}
2606
2607
2608void Item_Bird(int client, char[] name)
2609{
2610 if (IsPlayerAlive(client))
2611 {
2612 if (Forward_OnGetCredits(client) >= gc_iBird.IntValue)
2613 {
2614 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iBird.IntValue));
2615 Forward_OnPlayerBuyItem(client, name);
2616
2617 SetEntityMoveType(client, MOVETYPE_FLY);
2618 ClientCommand(client, "thirdperson");
2619 GetEntPropString(client, Prop_Data, "m_ModelName", g_sModelPathPrevious[client], sizeof(g_sModelPathPrevious[]));
2620 if (gc_iBirdMode.IntValue == 1) SetEntityModel(client, "models/chicken/chicken.mdl");
2621 if (gc_iBirdMode.IntValue == 2) SetEntityModel(client, "models/pigeon.mdl");
2622 if (gc_iBirdMode.IntValue == 3) SetEntityModel(client, "models/crow.mdl");
2623
2624 g_bFly[client] = true;
2625
2626 CPrintToChat(client, "%t %t", "shop_tag", "shop_bird");
2627 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iBird.IntValue);
2628 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: be a bird", client);
2629 if (gp_bMyIcons) MyIcons_BlockClientIcon(client, true);
2630 }
2631 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iBird.IntValue);
2632 }
2633 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2634}
2635
2636
2637void Item_TeleportSmoke(int client, char[] name)
2638{
2639 if (IsPlayerAlive(client))
2640 {
2641 if (Forward_OnGetCredits(client) >= gc_iTeleportSmoke.IntValue)
2642 {
2643 GivePlayerItem(client, "weapon_smokegrenade");
2644
2645 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iTeleportSmoke.IntValue));
2646 Forward_OnPlayerBuyItem(client, name);
2647
2648 g_bTeleportSmoke[client] = true;
2649 CPrintToChat(client, "%t %t", "shop_tag", "shop_teleportsmoke");
2650 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iTeleportSmoke.IntValue);
2651 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Teleport smoke", client);
2652 }
2653 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iTeleportSmoke.IntValue);
2654 }
2655 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2656}
2657
2658
2659void Item_FireGrenade(int client, char[] name)
2660{
2661 if (IsPlayerAlive(client))
2662 {
2663 if (Forward_OnGetCredits(client) >= gc_iFireHE.IntValue)
2664 {
2665 GivePlayerItem(client, "weapon_hegrenade");
2666
2667 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iFireHE.IntValue));
2668 Forward_OnPlayerBuyItem(client, name);
2669
2670 g_bFireHE[client] = true;
2671 CPrintToChat(client, "%t %t", "shop_tag", "shop_firegrenade");
2672 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iFireHE.IntValue);
2673 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Fire HE", client);
2674 }
2675 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iFireHE.IntValue);
2676 }
2677 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2678}
2679
2680
2681void Item_Gravity(int client, char[] name)
2682{
2683 if (IsPlayerAlive(client))
2684 {
2685 if (Forward_OnGetCredits(client) >= gc_iGravity.IntValue)
2686 {
2687 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iGravity.IntValue));
2688 Forward_OnPlayerBuyItem(client, name);
2689
2690 g_bGravity[client] = true;
2691 SetEntityGravity(client, gc_fGravValue.FloatValue);
2692 CPrintToChat(client, "%t %t", "shop_tag", "shop_gravity");
2693 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iGravity.IntValue);
2694 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Gravity", client);
2695 }
2696 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iGravity.IntValue);
2697 }
2698 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2699}
2700
2701
2702void Item_Bhop(int client, char[] name)
2703{
2704 if (IsPlayerAlive(client))
2705 {
2706 if (Forward_OnGetCredits(client) >= gc_iBhop.IntValue)
2707 {
2708 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iBhop.IntValue));
2709 Forward_OnPlayerBuyItem(client, name);
2710
2711 g_bBhop[client] = true;
2712 CPrintToChat(client, "%t %t", "shop_tag", "shop_bhop");
2713 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iBhop.IntValue);
2714 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Bhop", client);
2715 }
2716 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iBhop.IntValue);
2717 }
2718 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2719}
2720
2721
2722void Item_Taser(int client, char[] name)
2723{
2724 if (IsPlayerAlive(client))
2725 {
2726 if (Forward_OnGetCredits(client) >= gc_iTaser.IntValue)
2727 {
2728 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iTaser.IntValue));
2729 Forward_OnPlayerBuyItem(client, name);
2730
2731 int iTaser = GivePlayerItem(client, "weapon_taser");
2732 SetEntProp(iTaser, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
2733 SetEntProp(iTaser, Prop_Send, "m_iClip1", 3);
2734
2735 CPrintToChat(client, "%t %t", "shop_tag", "shop_taser");
2736 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iTaser.IntValue);
2737 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Taser", client);
2738 }
2739 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iTaser.IntValue);
2740 }
2741 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2742}
2743
2744
2745void Item_NoClip(int client, char[] name)
2746{
2747 if (IsPlayerAlive(client))
2748 {
2749 if (Forward_OnGetCredits(client) >= gc_iNoClip.IntValue)
2750 {
2751 g_bNoClip[client] = true;
2752 SetEntityMoveType(client, MOVETYPE_NOCLIP);
2753 CreateTimer(gc_fNoClipTime.FloatValue, Timer_NoClip, GetClientUserId(client));
2754 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iNoClip.IntValue));
2755 Forward_OnPlayerBuyItem(client, name);
2756
2757 CPrintToChat(client, "%t %t", "shop_tag", "shop_noclip", RoundToCeil(gc_fNoClipTime.FloatValue));
2758 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iNoClip.IntValue);
2759 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: No clip", client);
2760 }
2761 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iNoClip.IntValue);
2762 }
2763 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2764}
2765
2766
2767void Item_ThrowingKnife(int client, char[] name)
2768{
2769 if (g_bThrowingKnife[client])
2770 {
2771 CPrintToChat(client, "%t %t", "shop_tag", "shop_max");
2772 }
2773 else if (IsPlayerAlive(client))
2774 {
2775 if (Forward_OnGetCredits(client) >= gc_iThrowKnife.IntValue)
2776 {
2777 g_bThrowingKnife[client] = true;
2778 g_iKnifesThrown[client] = 0;
2779
2780 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iThrowKnife.IntValue));
2781 Forward_OnPlayerBuyItem(client, name);
2782
2783 CPrintToChat(client, "%t %t", "shop_tag", "shop_throwingknife");
2784 CPrintToChat(client, "%t %t", "shop_tag", "shop_costs", Forward_OnGetCredits(client), gc_iThrowKnife.IntValue);
2785 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Throw knife", client);
2786 }
2787 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iThrowKnife.IntValue);
2788 }
2789 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2790}
2791
2792
2793void Item_Revive(int client, char[] name)
2794{
2795 if (!IsPlayerAlive(client))
2796 {
2797 if (!g_bIsLR && GetAlivePlayersCount(GetClientTeam(client)) > 1)
2798 {
2799 if (Forward_OnGetCredits(client) >= gc_iRevive.IntValue)
2800 {
2801 CS_RespawnPlayer(client);
2802
2803 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iRevive.IntValue));
2804 Forward_OnPlayerBuyItem(client, name);
2805
2806 CPrintToChatAll("%t %t", "shop_tag", "shop_revived", client);
2807 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Revive", client);
2808 }
2809 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iRevive.IntValue);
2810 }
2811 }
2812 else CPrintToChat(client, "%t %t", "shop_tag", "shop_dead");
2813}
2814
2815
2816void Item_FroggyJump(int client, char[] name)
2817{
2818 if (IsPlayerAlive(client))
2819 {
2820 if (Forward_OnGetCredits(client) >= gc_iFroggyJump.IntValue)
2821 {
2822 g_bFroggyJump[client] = true;
2823
2824 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iFroggyJump.IntValue));
2825 Forward_OnPlayerBuyItem(client, name);
2826
2827 CPrintToChat(client, "%t %t", "shop_tag", "shop_froggyjump", client);
2828 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: FroggyJump", client);
2829 }
2830 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iFroggyJump.IntValue);
2831 }
2832 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2833}
2834
2835
2836void Item_PaperClip(int client, char[] name)
2837{
2838 if (IsPlayerAlive(client))
2839 {
2840 if (Forward_OnGetCredits(client) >= gc_iPaperClip.IntValue)
2841 {
2842 warden_handcuffs_givepaperclip(client, gc_iPaperClipAmount.IntValue);
2843
2844 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iPaperClip.IntValue));
2845 Forward_OnPlayerBuyItem(client, name);
2846
2847 CPrintToChat(client, "%t %t", "shop_tag", "shop_paperclip", gc_iPaperClipAmount.IntValue);
2848 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Paperclip", client);
2849 }
2850 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iPaperClip.IntValue);
2851 }
2852 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2853}
2854
2855
2856void Item_Wallhack(int client, char[] name)
2857{
2858 if (IsPlayerAlive(client))
2859 {
2860 if (Forward_OnGetCredits(client) >= gc_iWallhack.IntValue)
2861 {
2862 g_bWallhack[client] = true;
2863
2864 for (int i = 1; i <= MaxClients; i++) if (IsClientInGame(i)) Setup_WallhackSkin(i);
2865
2866 CreateTimer (gc_fWallhackTime.FloatValue, Timer_Wallhack, GetClientUserId(client));
2867
2868 Forward_OnSetCredits(client,(Forward_OnGetCredits(client)-gc_iWallhack.IntValue));
2869
2870 Forward_OnPlayerBuyItem(client, name);
2871
2872 CPrintToChat(client, "%t %t", "shop_tag", "shop_wallhack", client);
2873 if (gc_bLogging.BoolValue) LogToFileEx(g_sPurchaseLogFile, "Player %L bought: Wallhack", client);
2874 }
2875 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iWallhack.IntValue);
2876 }
2877 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2878}
2879
2880//by Hexer10
2881void Item_RandomTP(int client, char[] name)
2882{
2883 if (IsPlayerAlive(client))
2884 {
2885 if (Forward_OnGetCredits(client) >= gc_iRandomTP.IntValue)
2886 {
2887 if (GetAlivePlayersCount(CS_TEAM_T) < 2)
2888 {
2889 CPrintToChat(client, "%t %t", "shop_tag", "shop_randomtp_fail");
2890 return;
2891 }
2892
2893 int iRandomClient = GetRandomPlayer(CS_TEAM_T);
2894 while (client == iRandomClient)
2895 {
2896 iRandomClient = GetRandomPlayer(CS_TEAM_T);
2897 }
2898
2899 float origin[3];
2900 GetClientAbsOrigin(iRandomClient, origin);
2901 float location[3];
2902 GetClientEyePosition(iRandomClient, location);
2903 float ang[3];
2904 GetClientEyeAngles(iRandomClient, ang);
2905 float location2[3];
2906 location2[0] = (location[0]+(100*((Cosine(DegToRad(ang[1]))) * (Cosine(DegToRad(ang[0]))))));
2907 location2[1] = (location[1]+(100*((Sine(DegToRad(ang[1]))) * (Cosine(DegToRad(ang[0]))))));
2908 ang[0] -= (2*ang[0]);
2909 location2[2] = origin[2] += 5.0;
2910
2911 TeleportEntity(client, location2, NULL_VECTOR, NULL_VECTOR);
2912
2913 Forward_OnSetCredits(client, (Forward_OnGetCredits(client) - gc_iRandomTP.IntValue));
2914 Forward_OnPlayerBuyItem(client, name);
2915
2916 CPrintToChat(client, "%t %t", "shop_tag", "shop_randomtp", iRandomClient);
2917 CPrintToChat(iRandomClient, "%t %t", "shop_tag", "shop_randomtp_teleported", client);
2918
2919 g_bRandomTP[client] = true;
2920
2921 if (gc_bLogging.BoolValue)LogToFileEx(g_sPurchaseLogFile, "Player %L bought: RandomTP", client);
2922 }
2923 else CPrintToChat(client, "%t %t", "shop_tag", "shop_missingcredits", Forward_OnGetCredits(client), gc_iRandomTP.IntValue);
2924 }
2925 else CPrintToChat(client, "%t %t", "shop_tag", "shop_alive");
2926}
2927
2928
2929// Perpare client for wallhack
2930void Setup_WallhackSkin(int client)
2931{
2932 char sModel[PLATFORM_MAX_PATH];
2933 GetClientModel(client, sModel, sizeof(sModel));
2934 int iSkin = CPS_SetSkin(client, sModel, CPS_RENDER);
2935
2936 if (iSkin == -1)
2937 return;
2938
2939 if (SDKHookEx(iSkin, SDKHook_SetTransmit, OnSetTransmit_Wallhack))
2940 Setup_Wallhack(iSkin, client);
2941}
2942
2943
2944// set client wallhacked
2945void Setup_Wallhack(int iSkin, int client)
2946{
2947 int iOffset;
2948
2949 if ((iOffset = GetEntSendPropOffs(iSkin, "m_clrGlow")) == -1)
2950 return;
2951
2952 SetEntProp(iSkin, Prop_Send, "m_bShouldGlow", true, true);
2953 SetEntProp(iSkin, Prop_Send, "m_nGlowStyle", 0);
2954 SetEntPropFloat(iSkin, Prop_Send, "m_flGlowMaxDist", 10000000.0);
2955
2956 int iRed = 60;
2957 int iGreen = 60;
2958 int iBlue = 60;
2959
2960 if (GetClientTeam(client) == CS_TEAM_CT) iBlue = 240;
2961 if (GetClientTeam(client) == CS_TEAM_T) iRed = 240;
2962
2963 SetEntData(iSkin, iOffset, iRed, _, true);
2964 SetEntData(iSkin, iOffset + 1, iGreen, _, true);
2965 SetEntData(iSkin, iOffset + 2, iBlue, _, true);
2966 SetEntData(iSkin, iOffset + 3, 255, _, true);
2967}
2968
2969
2970// Who can see wallhack if vaild
2971public Action OnSetTransmit_Wallhack(int iSkin, int client)
2972{
2973 if (!IsPlayerAlive(client))
2974 return Plugin_Handled;
2975
2976 for (int i = 1; i <= MaxClients; i++) if (IsClientInGame(i))
2977 {
2978 if (!CPS_HasSkin(i))
2979 continue;
2980
2981 if (GetClientTeam(i) == GetClientTeam(client))
2982 continue;
2983
2984 if (EntRefToEntIndex(CPS_GetSkin(i)) != iSkin)
2985 continue;
2986
2987 if (g_bWallhack[client])
2988
2989 return Plugin_Continue;
2990 }
2991
2992 return Plugin_Handled;
2993}
2994
2995
2996// remove wallhack
2997void UnhookWallhack(int client)
2998{
2999 if (IsValidClient(client, true, true))
3000 {
3001 char sModel[PLATFORM_MAX_PATH];
3002 GetClientModel(client, sModel, sizeof(sModel));
3003 SDKUnhook(client, SDKHook_SetTransmit, OnSetTransmit_Wallhack);
3004 }
3005}
3006
3007
3008// awesome code by bacardi https:// forums.alliedmods.net/showthread.php?t=269846
3009public Action KnifeHit(int knife, int other)
3010{
3011 if ((0 < other <= MaxClients) && GetClientTeam(other) != CS_TEAM_T) // Hits player index
3012 {
3013 int victim = other;
3014
3015 SetVariantString("csblood");
3016 AcceptEntityInput(knife, "DispatchEffect");
3017 AcceptEntityInput(knife, "Kill");
3018
3019 int attacker = GetEntPropEnt(knife, Prop_Send, "m_hThrower");
3020 int inflictor = GetPlayerWeaponSlot(attacker, CS_SLOT_KNIFE);
3021
3022 if (inflictor == -1)
3023 {
3024 inflictor = attacker;
3025 }
3026
3027 float victimeye[3];
3028 GetClientEyePosition(victim, victimeye);
3029
3030 float damagePosition[3];
3031 float damageForce[3];
3032
3033 GetEntPropVector(knife, Prop_Data, "m_vecOrigin", damagePosition);
3034 GetEntPropVector(knife, Prop_Data, "m_vecVelocity", damageForce);
3035
3036 if (GetVectorLength(damageForce) == 0.0) // knife movement stop
3037 {
3038 return;
3039 }
3040
3041 // damage values and type
3042 float damage = 200.0;
3043 int dmgtype = DMG_SLASH|DMG_NEVERGIB;
3044
3045 // create damage
3046 SDKHooks_TakeDamage(victim, inflictor, attacker, damage, dmgtype, knife, damageForce, damagePosition);
3047
3048 // blood effect
3049 int color[] = {255, 0, 0, 255};
3050 float dir[3];
3051
3052 TE_SetupBloodSprite(damagePosition, dir, color, 1, PrecacheDecal("sprites/blood.vmt"), PrecacheDecal("sprites/blood.vmt"));
3053 TE_SendToAll(0.0);
3054
3055 // ragdoll effect
3056 int ragdoll = GetEntPropEnt(victim, Prop_Send, "m_hRagdoll");
3057 if (ragdoll != -1)
3058 {
3059 ScaleVector(damageForce, 50.0);
3060 damageForce[2] = FloatAbs(damageForce[2]); // push up!
3061 SetEntPropVector(ragdoll, Prop_Send, "m_vecForce", damageForce);
3062 SetEntPropVector(ragdoll, Prop_Send, "m_vecRagdollVelocity", damageForce);
3063 }
3064 }
3065 else if (FindValueInArray(g_hThrownKnives, EntIndexToEntRef(other)) != -1) // knives collide
3066 {
3067 SDKUnhook(knife, SDKHook_Touch, KnifeHit);
3068 float pos[3], dir[3];
3069 GetEntPropVector(knife, Prop_Data, "m_vecOrigin", pos);
3070 TE_SetupArmorRicochet(pos, dir);
3071 TE_SendToAll(0.0);
3072
3073 DispatchKeyValue(knife, "OnUser1", "!self,Kill,,1.0,-1");
3074 AcceptEntityInput(knife, "FireUser1");
3075 }
3076}
3077
3078
3079/******************************************************************************
3080 TIMER
3081******************************************************************************/
3082
3083
3084public Action Timer_BuyTime(Handle timer)
3085{
3086 if (g_bAllowBuy && gc_bEnable.BoolValue)
3087 {
3088 g_bAllowBuy = false;
3089 CPrintToChatAll("%t %t", "shop_tag", "shop_buytime");
3090 }
3091}
3092
3093
3094public Action Timer_NoClip(Handle timer, int userid)
3095{
3096 int client = GetClientOfUserId(userid);
3097
3098 g_bNoClip[client] = false;
3099 SetEntityMoveType(client, MOVETYPE_WALK);
3100 CPrintToChat(client, "%t %t", "shop_tag", "shop_noclipend");
3101
3102 if (IsClientStuck(client))
3103 {
3104 if (gc_bNoClipKill.BoolValue) CreateTimer(3.0, Timer_StuckNoClip, userid);
3105 CPrintToChatAll("%t %t", "shop_tag", "shop_noclipstuck", client);
3106 }
3107
3108 return Plugin_Stop;
3109}
3110
3111public Action Timer_StuckNoClip(Handle timer, int userid)
3112{
3113 int client = GetClientOfUserId(userid);
3114
3115 if (GetCommandFlags("sm_timebomb") != INVALID_FCVAR_FLAGS)
3116 {
3117 ServerCommand("sm_timebomb %N 1", client);
3118 }
3119 else ForcePlayerSuicide(client);
3120
3121 return Plugin_Stop;
3122}
3123
3124
3125public Action Timer_WelcomeMessage(Handle timer, int userid)
3126{
3127 int client = GetClientOfUserId(userid);
3128
3129 if (gc_bWelcome.BoolValue && IsClientInGame(client) && gc_bEnable.BoolValue) CPrintToChat(client, "%t %t", "shop_tag", "shop_welcome");
3130}
3131
3132
3133public Action Timer_DeathMessage(Handle timer, int userid)
3134{
3135 int client = GetClientOfUserId(userid);
3136
3137 if (IsClientInGame(client) && !g_bIsLR && GetAlivePlayersCount(GetClientTeam(client)) > 1 && gc_bEnable.BoolValue) CPrintToChat(client, "%t %t", "shop_tag", "shop_revivehint", gc_iRevive.IntValue);
3138}
3139
3140
3141public Action Timer_Delete(Handle timer, any entity)
3142{
3143 if (IsValidEdict(entity)) AcceptEntityInput(entity, "kill");
3144}
3145
3146
3147public Action Timer_CheckDamage(Handle timer, any iEntity)
3148{
3149 if (!IsValidEdict(iEntity))
3150 return Plugin_Stop;
3151
3152 int client = GetEntPropEnt(iEntity, Prop_Send, "m_hOwnerEntity");
3153
3154 if (!IsValidClient(client, true, false))
3155 return Plugin_Stop;
3156
3157 float fSmokeOrigin[3], fOrigin[3];
3158 GetEntPropVector(iEntity, Prop_Send, "m_vecOrigin", fSmokeOrigin);
3159
3160 for (int i = 1; i <= MaxClients; i++) if (IsValidClient(i, true, true))
3161 {
3162 if (GetClientTeam(i) != GetClientTeam(client))
3163 {
3164 GetClientAbsOrigin(i, fOrigin);
3165 if (GetVectorDistance(fSmokeOrigin, fOrigin) <= 220) DealDamage(i, 75, client, DMG_POISON, "weapon_smokegrenade");
3166 }
3167 }
3168 return Plugin_Continue;
3169}
3170
3171
3172public Action Timer_Credits (Handle timer)
3173{
3174 for (int i = 1; i <= MaxClients; i++) if (IsValidClient(i, false, true)) if (GetClientTeam(i) != CS_TEAM_SPECTATOR && gc_bEnable.BoolValue)
3175 {
3176 if (GetAllPlayersCount() >= gc_iMinPlayersToGetCredits.IntValue && (gc_bCreditsWarmup.BoolValue || GameRules_GetProp("m_bWarmupPeriod") != 1))
3177 {
3178 if (IsPlayerReservationAdmin(i))
3179 {
3180 if (gc_bNotification.BoolValue) CPrintToChat(i, "%t %t", "shop_tag", "shop_playtime", gc_iCreditsVIPPerTime.IntValue);
3181 Forward_OnSetCredits(i,(Forward_OnGetCredits(i)+gc_iCreditsVIPPerTime.IntValue));
3182 Forward_OnPlayerGetCredits(i, gc_iCreditsVIPPerTime.IntValue);
3183 }
3184 else
3185 {
3186 if (gc_bNotification.BoolValue) CPrintToChat(i, "%t %t", "shop_tag", "shop_playtime", gc_iCreditsTime.IntValue);
3187 Forward_OnSetCredits(i,(Forward_OnGetCredits(i)+gc_iCreditsTime.IntValue));
3188 Forward_OnPlayerGetCredits(i, gc_iCreditsTime.IntValue);
3189 }
3190 }
3191 }
3192}
3193
3194
3195public Action Timer_NoDamage(Handle timer, int userid)
3196{
3197 int client = GetClientOfUserId(userid);
3198
3199 if (IsClientInGame(client) && IsPlayerAlive(client))
3200 {
3201 CPrintToChat(client, "%t %t", "shop_tag", "shop_unnodamage");
3202 g_bNoDamage[client] = false;
3203 }
3204
3205}
3206
3207public Action Timer_Wallhack(Handle timer, int userid)
3208{
3209 int client = GetClientOfUserId(userid);
3210
3211 if (IsClientInGame(client) && IsPlayerAlive(client))
3212 {
3213 CPrintToChat(client, "%t %t", "shop_tag", "shop_unwallhack");
3214 g_bWallhack[client] = false;
3215
3216 for (int i = 1; i <= MaxClients; i++) if (IsClientInGame(i))
3217 {
3218 if (g_bWallhack[i]) return;
3219 UnhookWallhack(i);
3220 }
3221 }
3222}
3223
3224
3225public Action Timer_Invisible(Handle timer, int userid)
3226{
3227 int client = GetClientOfUserId(userid);
3228
3229 if (IsClientInGame(client) && IsPlayerAlive(client))
3230 {
3231 g_bInvisible[client] = false;
3232 CPrintToChat(client, "%t %t", "shop_tag", "shop_visible");
3233 SDKUnhook(client, SDKHook_SetTransmit, Hook_SetTransmit);
3234 if (gp_bMyIcons) MyIcons_BlockClientIcon(client, false);
3235 }
3236}
3237
3238
3239// awesome code by bacardi https:// forums.alliedmods.net/showthread.php?t=269846
3240public Action Timer_CreateKnife(Handle timer, int userid)
3241{
3242 int client = GetClientOfUserId(userid);
3243
3244 g_hTimerDelay[client] = INVALID_HANDLE;
3245
3246 int slot_knife = GetPlayerWeaponSlot(client, CS_SLOT_KNIFE);
3247 int knife = CreateEntityByName("smokegrenade_projectile");
3248
3249 g_iKnifesThrown[client]++;
3250
3251 if (g_iKnifesThrown[client] > gc_iThrowKnifeCount.IntValue) return;
3252
3253 if (knife == -1 || !DispatchSpawn(knife))
3254 {
3255 return;
3256 }
3257
3258 // owner
3259 int team = GetClientTeam(client);
3260 SetEntPropEnt(knife, Prop_Send, "m_hOwnerEntity", client);
3261 SetEntPropEnt(knife, Prop_Send, "m_hThrower", client);
3262 SetEntProp(knife, Prop_Send, "m_iTeamNum", team);
3263
3264 // player knife model
3265 char model[PLATFORM_MAX_PATH];
3266 if (slot_knife != -1)
3267 {
3268 GetEntPropString(slot_knife, Prop_Data, "m_ModelName", model, sizeof(model));
3269 if (ReplaceString(model, sizeof(model), "v_knife_", "w_knife_", true) != 1)
3270 {
3271 model[0] = '\0';
3272 }
3273 else if (ReplaceString(model, sizeof(model), ".mdl", "_dropped.mdl", true) != 1)
3274 {
3275 model[0] = '\0';
3276 }
3277 }
3278
3279 // model and size
3280 SetEntProp(knife, Prop_Send, "m_nModelIndex", PrecacheModel(model));
3281 SetEntPropFloat(knife, Prop_Send, "m_flModelScale", 1.0);
3282
3283 // knive elasticity
3284 SetEntPropFloat(knife, Prop_Send, "m_flElasticity", 0.2);
3285 // gravity
3286 SetEntPropFloat(knife, Prop_Data, "m_flGravity", 1.0);
3287
3288 // Player origin and angle
3289 float origin[3], angle[3];
3290 GetClientEyePosition(client, origin);
3291 GetClientEyeAngles(client, angle);
3292
3293 // knive new spawn position and angle is same as player's
3294 float pos[3];
3295 GetAngleVectors(angle, pos, NULL_VECTOR, NULL_VECTOR);
3296 ScaleVector(pos, 50.0);
3297 AddVectors(pos, origin, pos);
3298
3299 // knive flying direction and speed/power
3300 float player_velocity[3], velocity[3];
3301 GetEntPropVector(client, Prop_Data, "m_vecVelocity", player_velocity);
3302 GetAngleVectors(angle, velocity, NULL_VECTOR, NULL_VECTOR);
3303 ScaleVector(velocity, 2250.0);
3304 AddVectors(velocity, player_velocity, velocity);
3305
3306 // spin knive
3307 float spin[] = {4000.0, 0.0, 0.0};
3308 SetEntPropVector(knife, Prop_Data, "m_vecAngVelocity", spin);
3309
3310 // Stop grenade detonate and Kill knive after 1 - 30 sec
3311 SetEntProp(knife, Prop_Data, "m_nNextThinkTick", -1);
3312 char buffer[25];
3313 Format(buffer, sizeof(buffer), "!self,Kill,,%0.1f,-1", 1.5);
3314 DispatchKeyValue(knife, "OnUser1", buffer);
3315 AcceptEntityInput(knife, "FireUser1");
3316
3317 int color[4] = {255, ...};
3318 TE_SetupBeamFollow(knife, PrecacheModel("effects/blueblacklargebeam.vmt"), 0, 0.5, 1.0, 0.1, 0, color);
3319
3320 TE_SendToAll();
3321
3322 // Throw knive!
3323 TeleportEntity(knife, pos, angle, velocity);
3324 SDKHookEx(knife, SDKHook_Touch, KnifeHit);
3325
3326 PushArrayCell(g_hThrownKnives, EntIndexToEntRef(knife));
3327}
3328
3329
3330/******************************************************************************
3331 MYSQL
3332******************************************************************************/
3333
3334
3335public void OnMapEnd ()
3336{
3337 if (g_hTimerCredits != INVALID_HANDLE)
3338 {
3339 CloseHandle(g_hTimerCredits);
3340 g_hTimerCredits = INVALID_HANDLE;
3341 }
3342 if (!g_bDBConnected && gc_bMySQL.BoolValue)
3343 DB_Connect();
3344
3345 for (int i = 1; i <= MaxClients; i++) if (IsValidClient(i, false, true))
3346 {
3347 if (gc_bMySQL.BoolValue) DB_WriteCredits(i);
3348 OnClientDisconnect(i);
3349 }
3350}
3351
3352
3353public void OnClientAuthorized(int client, const char[] auth)
3354{
3355 if (!g_bDBConnected && gc_bMySQL.BoolValue) DB_Connect();
3356
3357 if (gc_bMySQL.BoolValue && !IsFakeClient(client))
3358 {
3359 DB_AddPlayer(client);
3360 DB_FetchCredits(client);
3361 }
3362}
3363
3364
3365public Action Event_PlayerDisconnect(Event event, const char[] name, bool dontBroadcast) // EVENT OR FORWARD
3366{
3367 int client = GetClientOfUserId(event.GetInt("userid"));
3368
3369 if (gc_bMySQL.BoolValue && client > 0 && !IsFakeClient(client))
3370 {
3371 if (!g_bDBConnected && gc_bMySQL.BoolValue) DB_Connect();
3372 DB_WriteCredits(client);
3373 }
3374 if (gp_bCustomPlayerSkins) UnhookWallhack(client);
3375 return Plugin_Continue;
3376}
3377
3378
3379stock bool IsPlayerReservationAdmin(int client)
3380{
3381 if (CheckCommandAccess(client, "Admin_Reservation", ADMFLAG_RESERVATION, false))
3382 {
3383 return true;
3384 }
3385 return false;
3386}
3387
3388/**
3389 * Attempts to connect to the database.
3390 * Creates the credits table (TABLE_NAME) ifneeded.
3391 * 'Cleans' the database eliminating players with a very small number of wins+losses. (meant to reduce database size)
3392 */
3393public void DB_Connect()
3394{
3395 char error[255];
3396 g_hDB = SQL_Connect("MyJailShop", true, error, sizeof(error));
3397 if (g_hDB == INVALID_HANDLE)
3398 {
3399 g_bDBConnected = false;
3400 LogError("Could not connect: %s", error);
3401 }
3402 else
3403 {
3404 // create the table
3405 SQL_LockDatabase(g_hDB);
3406 CreateTables();
3407 SQL_UnlockDatabase(g_hDB);
3408 g_bDBConnected = true;
3409 }
3410}
3411
3412static void CreateTables()
3413{
3414 Format(g_sSQLBuffer, sizeof(g_sSQLBuffer), "CREATE TABLE if NOT EXISTS myjs_credits (accountID INT NOT NULL PRIMARY KEY default 0, steamid varchar(64) NOT NULL default '', name varchar(64) NOT NULL default '', credits INT NOT NULL default 0);");
3415 SQL_FastQuery(g_hDB, g_sSQLBuffer);
3416}
3417
3418/**
3419 * Generic SQL threaded query error callback.
3420 */
3421public void SQLErrorCheckCallback(Handle owner, Handle hndl, const char[] error, any data)
3422{
3423 if (!StrEqual("", error))
3424 {
3425 g_hDB = INVALID_HANDLE;
3426 g_bDBConnected = false;
3427 LogError("Last Connect SQL (error: %s)", error);
3428 }
3429}
3430
3431/**
3432 * Adds a player, updating their name ifthey already exist, to the database.
3433 */
3434public void DB_AddPlayer(int client)
3435{
3436 if (g_hDB != INVALID_HANDLE)
3437 {
3438 int id = GetSteamAccountID(client);
3439
3440 // player name
3441 char name[64];
3442 GetClientName(client, name, sizeof(name));
3443 char sanitized_name[64];
3444 SQL_EscapeString(g_hDB, name, sanitized_name, sizeof(name));
3445
3446 // steam id
3447 char steamid[24];
3448 GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid));
3449
3450 // insert ifnot already in the table
3451 Format(g_sSQLBuffer, sizeof(g_sSQLBuffer),
3452 "INSERT IGNORE INTO myjs_credits (accountID,steamid,name,credits) VALUES (%d, '%s', '%s', 0);", id, steamid, sanitized_name);
3453 SQL_TQuery(g_hDB, SQLErrorCheckCallback, g_sSQLBuffer);
3454
3455 // update the player name
3456 Format(g_sSQLBuffer, sizeof(g_sSQLBuffer),
3457 "UPDATE myjs_credits SET name = '%s' WHERE accountID = %d", sanitized_name, id);
3458 SQL_TQuery(g_hDB, SQLErrorCheckCallback, g_sSQLBuffer);
3459 }
3460}
3461
3462/**
3463 * Reads a player credits from the database.
3464 * Note that this is a *SLOW* operation and you should not do it during gameplay
3465 */
3466public void DB_FetchCredits(int client)
3467{
3468 int credits = 0;
3469
3470 if (g_hDB != INVALID_HANDLE)
3471 {
3472 SQL_LockDatabase(g_hDB);
3473 Format(g_sSQLBuffer, sizeof(g_sSQLBuffer),
3474 "SELECT credits FROM myjs_credits WHERE accountID = %d", GetSteamAccountID(client));
3475 Handle query = SQL_Query(g_hDB, g_sSQLBuffer);
3476
3477 if (query == INVALID_HANDLE)
3478 {
3479 char error[255];
3480 SQL_GetError(g_hDB, error, sizeof(error));
3481 LogError("Failed to query (error: %s)", error);
3482 g_bDBConnected = false;
3483 CloseHandle(g_hDB);
3484 }
3485 else if (SQL_FetchRow(query)) credits = SQL_FetchInt(query, 0);
3486 else LogMessage("Couldn't fetchcredits for %N, probably it is first connection of client", client);
3487
3488 CloseHandle(query);
3489 SQL_UnlockDatabase(g_hDB);
3490 }
3491 g_iCredits[client] = credits;
3492}
3493
3494/**
3495 * Writes the credits to the database.
3496 */
3497
3498
3499public void DB_WriteCredits(int client)
3500{
3501 Format(g_sSQLBuffer, sizeof(g_sSQLBuffer), "UPDATE myjs_credits set credits = %d WHERE accountID = %d", Forward_OnGetCredits(client), GetSteamAccountID(client));
3502 SQL_TQuery(g_hDB, SQLErrorCheckCallback, g_sSQLBuffer);
3503}
3504
3505
3506/******************************************************************************
3507 NATIVES
3508******************************************************************************/
3509
3510
3511// Register Natives
3512public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
3513{
3514 // Forwards
3515 gF_hOnPlayerGetCredits = CreateGlobalForward("MyJailShop_OnPlayerGetCredits", ET_Ignore, Param_Cell, Param_Cell);
3516 gF_hOnPlayerBuyItem = CreateGlobalForward("MyJailShop_OnPlayerBuyItem", ET_Ignore, Param_Cell, Param_String);
3517 gF_hOnResetPlayer = CreateGlobalForward("MyJailShop_OnResetPlayer", ET_Ignore, Param_Cell);
3518
3519 gF_hOnGetCredits = CreateGlobalForward("MyJailShop_OnGetCredits", ET_Event, Param_Cell);
3520 gF_hOnSetCredits = CreateGlobalForward("MyJailShop_OnSetCredits", ET_Event, Param_Cell, Param_Cell);
3521 gF_hOnShopMenuHandler= CreateGlobalForward("MyJailShop_OnShopMenuHandler", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
3522 gF_hOnShopMenu = CreateGlobalForward("MyJailShop_OnShopMenu", ET_Ignore, Param_Cell, Param_Cell);
3523
3524 // Natives
3525 CreateNative("MyJailShop_SetCredits", Native_SetCredits);
3526 CreateNative("MyJailShop_GetCredits", Native_GetCredits);
3527 CreateNative("MyJailShop_IsBuyTime", Native_BuyTime);
3528
3529
3530 if (GetEngineVersion() != Engine_CSGO)
3531 {
3532 SetFailState("Game is not supported. CS:GO ONLY");
3533 }
3534
3535 RegPluginLibrary("myjailshop");
3536
3537 return APLRes_Success;
3538}
3539
3540
3541public int Native_GetCredits(Handle plugin, int argc)
3542{
3543 int client = GetNativeCell(1);
3544 if (!IsValidClient(client, false, true))
3545 {
3546 return -1;
3547 }
3548
3549 return Forward_OnGetCredits(client);
3550}
3551
3552public int Native_BuyTime(Handle plugin, int argc)
3553{
3554 return g_bAllowBuy;
3555}
3556
3557
3558public int Native_SetCredits(Handle plugin, int argc)
3559{
3560 int client = GetNativeCell(1);
3561 if (!IsValidClient(client, false, true))
3562 {
3563 return;
3564 }
3565
3566 int iCredits = GetNativeCell(2);
3567 if (0 > iCredits)
3568 {
3569 iCredits = 0;
3570 }
3571
3572 if (iCredits > gc_iCreditsMax.IntValue)
3573 {
3574 iCredits = gc_iCreditsMax.IntValue;
3575 }
3576
3577 Forward_OnSetCredits(client, iCredits);
3578 Forward_OnPlayerGetCredits(client, iCredits);
3579}
3580
3581
3582/******************************************************************************
3583 FORWARDS CALL
3584******************************************************************************/
3585
3586
3587void Forward_OnPlayerGetCredits(int client, int extraCredits)
3588{
3589 Call_StartForward(gF_hOnPlayerGetCredits);
3590 Call_PushCell(client);
3591 Call_PushCell(extraCredits);
3592 Call_Finish();
3593}
3594
3595
3596void Forward_OnResetPlayer(int client)
3597{
3598 Call_StartForward(gF_hOnResetPlayer);
3599 Call_PushCell(client);
3600 Call_Finish();
3601}
3602
3603
3604void Forward_OnPlayerBuyItem(int client, char[] item)
3605{
3606 Call_StartForward(gF_hOnPlayerBuyItem);
3607 Call_PushCell(client);
3608 Call_PushString(item);
3609 Call_Finish();
3610}
3611
3612
3613int Forward_OnGetCredits(int client)
3614{
3615 int credits = 0;
3616 if (!gc_bCreditSystem.BoolValue)
3617 {
3618 Call_StartForward(gF_hOnGetCredits);
3619 Call_PushCell(client);
3620 Call_Finish(credits);
3621 }
3622 else credits = g_iCredits[client];
3623 return credits;
3624}
3625
3626void Forward_OnSetCredits(int client, int credits)
3627{
3628 if (!gc_bCreditSystem.BoolValue)
3629 {
3630 Call_StartForward(gF_hOnSetCredits);
3631 Call_PushCell(client);
3632 Call_PushCell(credits);
3633 Call_Finish();
3634 }
3635 else g_iCredits[client] = credits;
3636}