· 6 years ago · Aug 04, 2019, 12:28 AM
1#include <sourcemod>
2#include <cstrike>
3#include <sdktools>
4#include <sdkhooks>
5#include <csgocolors>
6#include <sourcecomms>
7#include <clientprefs>
8//#include <nox_ashop>
9
10Database DB;
11
12int offsetHe;
13int offsetFlash;
14int offsetSmoke;
15int offsetInc;
16int offsetMol;
17
18int g_iAddHealth[MAXPLAYERS + 1];
19int g_iRegernAddHealth[MAXPLAYERS + 1];
20int g_iRegernHsAddHealth[MAXPLAYERS + 1];
21int g_iNadeTaken[MAXPLAYERS + 1];
22
23bool g_bDoubleJump[MAXPLAYERS + 1];
24bool g_bFallDMG[MAXPLAYERS + 1];
25bool g_bKevlar[MAXPLAYERS + 1];
26bool g_bHelmet[MAXPLAYERS + 1];
27bool g_bDefuser[MAXPLAYERS + 1];
28bool g_bMoneyKill[MAXPLAYERS + 1];
29bool g_bMoneyHsKill[MAXPLAYERS + 1];
30bool g_bMoneyBomb[MAXPLAYERS + 1];
31bool g_bHEGrenade[MAXPLAYERS + 1];
32bool g_bFirstFlash[MAXPLAYERS + 1];
33bool g_bSecondFlash[MAXPLAYERS + 1];
34bool g_bSmokeGrenade[MAXPLAYERS + 1];
35bool g_bFlameGrenade[MAXPLAYERS + 1];
36
37char g_sFilepath[PLATFORM_MAX_PATH];
38char g_cTag[16] = "[VIP]";
39
40ConVar g_cvEnabled;
41
42#pragma semicolon 1
43#pragma newdecls required
44
45public Plugin myinfo =
46{
47 name = "VIP",
48 author = "Charlie W.",
49 description = "",
50 version = "1.1",
51 url = ""
52};
53
54public void OnPluginStart()
55{
56 DbConnect();
57
58 g_cvEnabled = CreateConVar("vip_enablenormal", "1", "... my fucking private cvar. so fuck off you asshole.");
59
60 HookEvent("bomb_planted", EventBombPlanted);
61 HookEvent("bomb_defused", EventBombDefused);
62 HookEvent("player_spawn", EventPlayerSpawn);
63 HookEvent("player_death", EventPlayerDeath);
64
65 RegConsoleCmd("sm_vip", CmdMainMenu);
66 RegConsoleCmd("sm_vipinfo", CmdVipInfo);
67
68 AddCommandListener(SayHook, "say");
69
70 BuildPath(Path_SM, g_sFilepath, sizeof(g_sFilepath), "configs/vipinfo.ini");
71
72}
73
74public void OnClientPutInServer(int client)
75{
76 SDKHook(client, SDKHook_OnTakeDamage, FallDmg);
77}
78
79public void OnClientDisonnect(int client)
80{
81 SDKUnhook(client, SDKHook_OnTakeDamage, FallDmg);
82}
83
84public void DbConnect()
85{
86 char gB_Error[255];
87 if (SQL_CheckConfig("vip_settings"))
88 {
89 DB = SQL_Connect("vip_settings", true, gB_Error, 255);
90
91 if (DB == null)
92 SetFailState("[SS] Error on start. Reason: %s", gB_Error);
93 }
94 else
95 SetFailState("[SS] Cant find `vip_settings` on database.cfg");
96
97 char query[512];
98 Format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `settings` ( `id` INT NOT NULL AUTO_INCREMENT, `steamid` TEXT NOT NULL, `dj` BOOLEAN NOT NULL, `fd` BOOLEAN NOT NULL, `kv` BOOLEAN NOT NULL, `hkv` BOOLEAN NOT NULL, `def` BOOLEAN NOT NULL, `money` BOOLEAN NOT NULL, `moneyhs` BOOLEAN NOT NULL, `moneybomb` BOOLEAN NOT NULL, `nade` BOOLEAN NOT NULL, `flash_f` BOOLEAN NOT NULL, `flash_s` BOOLEAN NOT NULL, `smoke` BOOLEAN NOT NULL, `flame` BOOLEAN NOT NULL, `ah` INT NOT NULL, `rah` INT NOT NULL, `rhah` INT NOT NULL, PRIMARY KEY (`id`));");
99 DB.Query(SQLT_Error, query);
100}
101
102public void SQLT_Error(Database db, DBResultSet results, const char[] error, any data)
103{
104 if (results == null)
105 LogError("Error: %s", error);
106}
107
108public void GetPlayerSettings(int client)
109{
110 if (IsValidClient(client))
111 return;
112
113 if (IsClientVip(client))
114 return;
115
116 char sAuth[64];
117 char query[512];
118
119 if(GetClientAuthId(client, AuthId_SteamID64, sAuth, sizeof(sAuth)))
120 {
121 DataPack pack = new DataPack();
122 pack.WriteCell(client);
123 pack.WriteString(sAuth);
124
125 Format(query, sizeof(query), "SELECT `dj`, `fd`, `kv`, `hkv`, `def`, `money`, `moneyhs`, `moneybomb`, `nade`, `flash_f`, `flash_s`, `smoke`, `flame`, `ah`, `rah`, `rhah` FROM settings WHERE `steamid`='%s'", sAuth);
126 DB.Query(GetCallback, query, pack);
127 }
128}
129
130public void GetCallback(Database db, DBResultSet results, const char[] error, DataPack pack)
131{
132 if(results == null)
133 {
134 LogError(error);
135 return;
136 }
137
138 char sAuth[64];
139
140 pack.Reset();
141 int client = pack.ReadCell();
142 pack.ReadString(sAuth, sizeof(sAuth));
143
144 if(results.FetchRow())
145 {
146 g_bDoubleJump[client] = view_as<bool>(results.FetchInt(0));
147 g_bFallDMG[client] = view_as<bool>(results.FetchInt(1));
148 g_bKevlar[client] = view_as<bool>(results.FetchInt(2));
149 g_bHelmet[client] = view_as<bool>(results.FetchInt(3));
150 g_bDefuser[client] = view_as<bool>(results.FetchInt(4));
151 g_bMoneyKill[client] = view_as<bool>(results.FetchInt(5));
152 g_bMoneyHsKill[client] = view_as<bool>(results.FetchInt(6));
153 g_bMoneyBomb[client] = view_as<bool>(results.FetchInt(7));
154 g_bHEGrenade[client] = view_as<bool>(results.FetchInt(8));
155 g_bFirstFlash[client] = view_as<bool>(results.FetchInt(9));
156 g_bSecondFlash[client] = view_as<bool>(results.FetchInt(10));
157 g_bSmokeGrenade[client] = view_as<bool>(results.FetchInt(11));
158 g_bFlameGrenade[client] = view_as<bool>(results.FetchInt(12));
159 g_iAddHealth[client] = results.FetchInt(13);
160 g_iRegernAddHealth[client] = results.FetchInt(14);
161 g_iRegernHsAddHealth[client] = results.FetchInt(15);
162 g_iNadeTaken[client] = results.FetchInt(8) + results.FetchInt(9) + results.FetchInt(10) + results.FetchInt(11) + results.FetchInt(12);
163 }
164 else
165 {
166 char query[256];
167
168 g_bDoubleJump[client] = true;
169 g_bFallDMG[client] = true;
170 g_bKevlar[client] = true;
171 g_bHelmet[client] = true;
172 g_bDefuser[client] = true;
173 g_bMoneyKill[client] = true;
174 g_bMoneyHsKill[client] = true;
175 g_bMoneyBomb[client] = true;
176 g_bHEGrenade[client] = true;
177 g_bFirstFlash[client] = true;
178 g_bSecondFlash[client] = false;
179 g_bSmokeGrenade[client] = true;
180 g_bFlameGrenade[client] = true;
181 g_iAddHealth[client] = 10;
182 g_iRegernAddHealth[client] = 3;
183 g_iRegernHsAddHealth[client] = 2;
184 g_iNadeTaken[client] = 4;
185
186 Format(query, sizeof(query), "INSERT INTO `settings` (`id`, `steamid`, `dj`, `fd`, `kv`, `hkv`, `def`, `money`, `moneyhs`, `moneybomb`, `nade`, `flash_f`, `flash_s`, `smoke`, `flame`, `ah`, `rah`, `rhah`) VALUES (NULL, '%s', true, true, true, true, true, true, true, true, true, true, true, true, true, 10, 3, 2)", sAuth);
187 DB.Query(SQLT_Error, query);
188 }
189}
190
191public void OnClientDisconnect(int client)
192{
193 if (IsValidClient(client))
194 return;
195
196 if (IsClientVip(client))
197 return;
198
199 char sAuth[64];
200 char query[512];
201
202 if(GetClientAuthId(client, AuthId_SteamID64, sAuth, sizeof(sAuth)))
203 {
204 Format(query, sizeof(query), "UPDATE `settings` SET `dj` = %b, `fd` = %b, `kv` = %b, `hkv` = %b, `def` = %b, `money` = %b, `moneyhs` = %b, `moneybomb` = %b, `nade` = %b, `flash_f` = %b, `flash_s` = %b, `smoke` = %b, `flame` = %b, `ah` = %i, `rah` = %i, `rhah` = %i WHERE `steamid`='%s'", g_bDoubleJump[client], g_bFallDMG[client], g_bKevlar[client], g_bHelmet[client], g_bDefuser[client], g_bMoneyKill[client], g_bMoneyHsKill[client], g_bMoneyBomb[client], g_bHEGrenade[client], g_bFirstFlash[client], g_bSecondFlash[client], g_bSmokeGrenade[client], g_bFlameGrenade[client], g_iAddHealth[client], g_iRegernAddHealth[client], g_iRegernHsAddHealth[client], g_iNadeTaken[client], sAuth);
205 DB.Query(SQLT_Error, query);
206 }
207}
208
209public void OnMapStart()
210{
211 int entindex;
212
213 entindex = CreateEntityByName("weapon_hegrenade");
214 DispatchSpawn(entindex);
215 offsetHe = GetEntProp(entindex, Prop_Send, "m_iPrimaryAmmoType");
216 AcceptEntityInput(entindex, "Kill");
217
218 entindex = CreateEntityByName("weapon_flashbang");
219 DispatchSpawn(entindex);
220 offsetFlash = GetEntProp(entindex, Prop_Send, "m_iPrimaryAmmoType");
221 AcceptEntityInput(entindex, "Kill");
222
223 entindex = CreateEntityByName("weapon_smokegrenade");
224 DispatchSpawn(entindex);
225 offsetSmoke = GetEntProp(entindex, Prop_Send, "m_iPrimaryAmmoType");
226 AcceptEntityInput(entindex, "Kill");
227
228 entindex = CreateEntityByName("weapon_incgrenade");
229 DispatchSpawn(entindex);
230 offsetInc = GetEntProp(entindex, Prop_Send, "m_iPrimaryAmmoType");
231 AcceptEntityInput(entindex, "Kill");
232
233 entindex = CreateEntityByName("weapon_molotov");
234 DispatchSpawn(entindex);
235 offsetMol = GetEntProp(entindex, Prop_Send, "m_iPrimaryAmmoType");
236 AcceptEntityInput(entindex, "Kill");
237}
238
239public void OnClientConnected(int client)
240{
241 if(IsValidClient(client))
242 GetPlayerSettings(client);
243}
244
245public Action EventPlayerSpawn(Event event, const char[] name, bool dontBroadcast)
246{
247 int client = GetClientOfUserId(GetEventInt(event, "userid"));
248
249 if(!IsValidClient(client))
250 return;
251
252 if(IsClientVip(client))
253 {
254 if(IsPlayerAlive(client))
255 CreateTimer(0.1, GiveEquipment, client, TIMER_FLAG_NO_MAPCHANGE);
256 }
257}
258
259public Action GiveEquipment(Handle timer, int client)
260{
261 if(!IsValidClient(client))
262 return;
263
264 if(!IsClientVip(client))
265 return;
266
267 if(GetTeamScore(CS_TEAM_CT) + GetTeamScore(CS_TEAM_T) != 0 && GetTeamScore(CS_TEAM_CT) + GetTeamScore(CS_TEAM_T) != 15)
268 {
269 if(g_bKevlar[client])
270 SetEntProp(client, Prop_Send, "m_ArmorValue", 100);
271
272 if(g_bKevlar[client] && g_bHelmet[client])
273 SetEntProp(client, Prop_Send, "m_bHasHelmet", 1);
274
275 if(GetEntProp(client, Prop_Send, "m_iAmmo", _, offsetHe) < 1 && g_bHEGrenade[client])
276 GivePlayerItem(client, "weapon_hegrenade");
277
278 if((g_bFirstFlash[client] && g_bSecondFlash[client]))
279 {
280 for(int i = 0; i < 2; i++)
281 if(GetEntProp(client, Prop_Send, "m_iAmmo", _, offsetFlash) < 2) GivePlayerItem(client, "weapon_flashbang");
282 }
283 else if(g_bFirstFlash[client] || g_bSecondFlash[client])
284 if(GetEntProp(client, Prop_Send, "m_iAmmo", _, offsetFlash) < 1) GivePlayerItem(client, "weapon_flashbang");
285
286
287 if(GetEntProp(client, Prop_Send, "m_iAmmo", _, offsetSmoke) < 1 && g_bSmokeGrenade[client])
288 GivePlayerItem(client, "weapon_smokegrenade");
289
290 if(GetClientTeam(client) == CS_TEAM_CT && g_bFlameGrenade[client])
291 if(GetEntProp(client, Prop_Send, "m_iAmmo", _, offsetInc) < 1)
292 GivePlayerItem(client, "weapon_incgrenade");
293
294 if(GetClientTeam(client) == CS_TEAM_T && g_bFlameGrenade[client])
295 if(GetEntProp(client, Prop_Send, "m_iAmmo", _, offsetMol) < 1)
296 GivePlayerItem(client, "weapon_molotov");
297
298 if(!IsClientVip(client) || g_cvEnabled.IntValue == 1)
299 SetEntityHealth(client, 100 +g_iAddHealth[client]);
300 }
301
302 CS_SetClientClanTag(client, g_cTag);
303
304 if(GetClientTeam(client) == CS_TEAM_CT)
305 {
306 if (GetEntProp(client, Prop_Send, "m_bHasDefuser") == 0 && g_bDefuser[client])
307 GivePlayerItem(client, "item_defuser");
308 }
309}
310
311public Action EventPlayerDeath(Handle event, const char[] name, bool dontBroadcast)
312{
313 int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
314
315 if(!IsValidClient(attacker))
316 return;
317
318 if(!IsClientVip(attacker))
319 return;
320
321 int iHealth = GetClientHealth(attacker);
322 int iMoney = GetEntProp(attacker, Prop_Send, "m_iAccount");
323 bool bHeadshot = GetEventBool(event, "headshot", false);
324
325 SetEntityHealth(attacker, iHealth + g_iRegernAddHealth[attacker]);
326
327 if(g_bMoneyKill[attacker])
328 SetEntProp(attacker, Prop_Send, "m_iAccount", iMoney + 200);
329
330 if(bHeadshot)
331 {
332 iHealth = GetClientHealth(attacker);
333 SetEntityHealth(attacker, iHealth + g_iRegernHsAddHealth[attacker]);
334 iMoney = GetEntProp(attacker, Prop_Send, "m_iAccount");
335
336 if(g_bMoneyHsKill[attacker])
337 SetEntProp(attacker, Prop_Send, "m_iAccount", iMoney + 100);
338 }
339
340 if(GetClientHealth(attacker) > 100 + g_iAddHealth[attacker])
341 SetEntityHealth(attacker, 100 + g_iAddHealth[attacker]);
342}
343
344public Action EventBombPlanted(Event event, const char[] name, bool dontBroadcast)
345{
346 int client = GetClientOfUserId(GetEventInt(event, "userid"));
347 int iMoney = GetEntProp(client, Prop_Send, "m_iAccount");
348
349 if(IsClientVip(client))
350 SetEntProp(client, Prop_Send, "m_iAccount", iMoney + 200);
351}
352
353public Action EventBombDefused(Event event, const char[] name, bool dontBroadcast)
354{
355 int client = GetClientOfUserId(GetEventInt(event, "userid"));
356 int iMoney = GetEntProp(client, Prop_Send, "m_iAccount");
357
358 if(IsClientVip(client))
359 SetEntProp(client, Prop_Send, "m_iAccount", iMoney + 200);
360}
361
362public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float[3] vel, float[3] angles, int &weapon)
363{
364 if(!IsValidClient(client) || !IsPlayerAlive(client))
365 return;
366
367 if(!IsClientVip(client) || g_cvEnabled.IntValue != 1 || !g_bDoubleJump[client])
368 return;
369
370 static int fLastButtons[MAXPLAYERS+1];
371 static int fLastFlags[MAXPLAYERS+1];
372 static int iJumps[MAXPLAYERS+1];
373 static int fCurFlags;
374 static int fCurButtons;
375
376 fCurFlags = GetEntityFlags(client);
377 fCurButtons = GetClientButtons(client);
378
379 if (fLastFlags[client] & FL_ONGROUND && !(fCurFlags & FL_ONGROUND) && !(fLastButtons[client] & IN_JUMP) && fCurButtons & IN_JUMP)
380 iJumps[client]++;
381 else if(fCurFlags & FL_ONGROUND)
382 iJumps[client] = 0;
383 else if(!(fLastButtons[client] & IN_JUMP) && fCurButtons & IN_JUMP && iJumps[client] <= 1)
384 {
385 iJumps[client]++;
386 float vVel[3];
387 GetEntPropVector(client, Prop_Data, "m_vecVelocity", vVel);
388 vVel[2] = 250.0;
389 TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vVel);
390 }
391
392 fLastFlags[client] = fCurFlags;
393 fLastButtons[client] = fCurButtons;
394
395}
396
397public Action FallDmg(int client, int &attacker, int &inflictor, float &damage, int &damagetype)
398{
399 if(!IsValidClient(client))
400 return Plugin_Continue;
401
402 if(!IsClientVip(client))
403 return Plugin_Continue;
404
405 if(damagetype & DMG_FALL && g_bFallDMG[client])
406 return Plugin_Handled;
407 return Plugin_Continue;
408}
409
410public Action SayHook(int client, const char[] command, int args)
411{
412 if(!IsValidClient(client))
413 return Plugin_Continue;
414
415 if(!IsClientVip(client))
416 return Plugin_Continue;
417
418 char Msg[256];
419 char Ch[256];
420
421 if(StrEqual(Msg[1], ""))
422 return Plugin_Handled;
423
424 SplitString(Msg[1], Msg[2], Ch, sizeof Ch);
425 if(!StrEqual(Ch, "/") && !StrEqual(Ch, "@") && !StrEqual(Ch, "!") /*&& SourceComms_GetClientGagType(client) == bNot*/)
426 {
427 for(int i = 1; i <= MaxClients; i++)
428 {
429 if(IsValidClient(i))
430 {
431 if(!IsPlayerAlive(client) && GetClientTeam(client) != 1 && !IsPlayerAlive(i))
432 CPrintToChat(i, "{default}*NIE ŻYJE* {DEFAULT}[{GREEN}%s{DEFAULT}] {RED}%N: {DEFAULT}%s", g_cTag, client, Msg[1]);
433 else if(GetClientTeam(client) == 1 && !IsPlayerAlive(i))
434 CPrintToChat(i, "{default}*SPEC* {DEFAULT}[{GREEN}%s{DEFAULT}] {RED}%N: {DEFAULT}%s", g_cTag, client, Msg[1]);
435 else if (IsPlayerAlive(client))
436 CPrintToChat(i, "{DEFAULT}[{GREEN}%s{DEFAULT}] {RED}%N: {DEFAULT}%s", g_cTag, client, Msg[1]);
437 }
438 }
439 }
440
441 return Plugin_Handled;
442}
443
444public Action CmdVipInfo(int client, int args)
445{
446 File file = OpenFile(g_sFilepath, "rt");
447 char vippart[255];
448
449 if (file == null)
450 return Plugin_Handled;
451
452 CPrintToChat(client, "{GREEN} VIP POSIADA NASTĘPUJĄCE RZECZY:");
453 while (!file.EndOfFile() && file.ReadLine(vippart, sizeof(vippart)))
454 {
455 if (vippart[0] == ';' || !IsCharAlpha(vippart[0]))
456 continue;
457
458 CPrintToChat(client, "{GREEN} - {DEFAULT}%s", vippart);
459 }
460
461 if(!(GetUserFlagBits(client) & ADMFLAG_CUSTOM3))
462 CPrintToChat(client, "{DEFAULT}[{GREEN}VIP{DEFAULT}] Aby zakupić VIP'a wpisz: {GREEN}!vip{DEFAULT}.", vippart);
463
464 file.Close();
465 return Plugin_Handled;
466}
467
468stock bool RemoveWeaponBySlot(int client,int slot)
469{
470 int iEntity = GetPlayerWeaponSlot(client, slot);
471 if(IsValidEdict(iEntity))
472 {
473 RemovePlayerItem(client, iEntity);
474 AcceptEntityInput(iEntity, "Kill");
475 return true;
476 }
477 return false;
478}
479
480public bool IsValidClient(int client)
481{
482 if(client >= 1 && client <= MaxClients && IsClientInGame(client) && IsClientConnected(client) && !IsFakeClient(client) && !IsClientReplay(client) && !IsClientSourceTV(client))
483 return true;
484 return false;
485}
486
487public bool IsClientVip(int client)
488{
489 if(GetUserFlagBits(client) & ADMFLAG_CUSTOM3)
490 return true;
491 return false;
492}
493
494public Action CmdMainMenu(int client, int args)
495{
496 if (!IsValidClient(client))
497 return Plugin_Handled;
498
499 MainMenu(client).Display(client, MENU_TIME_FOREVER);
500
501 return Plugin_Handled;
502}
503
504Menu MainMenu(int client)
505{
506 Menu menu = new Menu(MainMenuHandler);
507
508 menu.SetTitle("VIP:");
509
510 menu.AddItem("cmenu", "Personalizacja VIP'a", IsClientVip(client) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED);
511 menu.AddItem("ichat", "O VIP'ie");
512 menu.AddItem("buy", "Kup VIP'a");
513
514 menu.ExitBackButton = true;
515
516 return menu;
517}
518
519public int MainMenuHandler(Menu menu, MenuAction action, int client, int selection)
520{
521 switch(action)
522 {
523 case MenuAction_Select:
524 {
525 if(IsClientInGame(client))
526 {
527 char buffer[30];
528 menu.GetItem(selection, buffer, sizeof(buffer));
529 if(StrEqual(buffer, "cmenu"))
530 VipMenu(client, 1);
531 if(StrEqual(buffer, "ichat"))
532 CmdVipInfo(client, 1);
533 else if(StrEqual(buffer, "buy"))
534 FakeClientCommand(client, "sm_sklep");
535 }
536 }
537 case MenuAction_Cancel:
538 {
539 if(IsClientInGame(client) && selection == MenuCancel_ExitBack)
540 CmdMainMenu(client, 1);
541 }
542 case MenuAction_End:
543 {
544 delete menu;
545 }
546 }
547}
548
549public Action VipMenu(int client, int args)
550{
551 if (!IsValidClient(client))
552 return Plugin_Handled;
553
554 if (!IsClientVip(client))
555 {
556 CPrintToChat(client, "{DEFAULT}[{GREEN}VIP{DEFAULT}] Nie masz dostępu do tej komendy. Aby kupić VIP'a wpisz: {GREEN}!sklep{DEFAULT}.");
557 return Plugin_Handled;
558 }
559
560 Menu menu = CreateMenu(VipMenuHandler);
561
562 SetMenuTitle(menu, "Menu Personalizacji VIP'a:");
563
564 if (!g_bDoubleJump[client])
565 AddMenuItem(menu, "", "[Wył] Podwójny Skok");
566 else
567 AddMenuItem(menu, "", "[Wł] Podwójny Skok");
568
569 if (!g_bFallDMG[client])
570 AddMenuItem(menu, "", "[Wył] Podwójny Skok");
571 else
572 AddMenuItem(menu, "", "[Wł] Podwójny Skok");
573
574 AddMenuItem(menu, "", "HP");
575 AddMenuItem(menu, "", "Ekwipunek");
576 AddMenuItem(menu, "", "Dodatkowe Pieniądze");
577 AddMenuItem(menu, "", "Granaty");
578
579 SetMenuExitButton(menu, true);
580 DisplayMenu(menu, client, MENU_TIME_FOREVER);
581 return Plugin_Handled;
582}
583
584public int VipMenuHandler(Menu tMenu, MenuAction action, int client, int item)
585{
586 switch (action)
587 {
588 case MenuAction_Select:
589 {
590 switch (item)
591 {
592 case 0:
593 {
594 if (!g_bDoubleJump[client])
595 g_bDoubleJump[client] = true;
596 else
597 g_bDoubleJump[client] = false;
598
599 CreateTimer(0.1, RefreshVIPMenu, client, TIMER_FLAG_NO_MAPCHANGE);
600 }
601 case 1:
602 {
603 if (!g_bFallDMG[client])
604 g_bFallDMG[client] = true;
605 else
606 g_bFallDMG[client] = false;
607
608 CreateTimer(0.1, RefreshVIPMenu, client, TIMER_FLAG_NO_MAPCHANGE);
609 }
610 case 2:
611 {
612 HPMainMenu().Display(client, MENU_TIME_FOREVER);
613 }
614 case 3:
615 {
616 EqMenu(client).Display(client, MENU_TIME_FOREVER);
617 }
618 case 4:
619 {
620 MoneyMenu(client).Display(client, MENU_TIME_FOREVER);
621 }
622 case 5:
623 {
624 NadesMenu(client).Display(client, MENU_TIME_FOREVER);
625 }
626 }
627 }
628 case MenuAction_Cancel:
629 {
630 if(IsClientInGame(client) && item == MenuCancel_ExitBack)
631 CmdMainMenu(client, 1);
632 }
633 case MenuAction_End:
634 {
635 CloseHandle(tMenu);
636 }
637 }
638}
639
640Menu HPMainMenu()
641{
642 Menu menu = new Menu(HPMainMenuHandler);
643
644 menu.SetTitle("Menu HP:");
645
646 menu.AddItem("hp", "HP w nowej rundzie");
647 menu.AddItem("normal", "HP za zabicie");
648 menu.AddItem("hs", "HP za zabicie w głowę");
649
650 menu.ExitBackButton = true;
651
652 return menu;
653}
654
655public int HPMainMenuHandler(Menu menu, MenuAction action, int client, int selection)
656{
657 switch(action)
658 {
659 case MenuAction_Select:
660 {
661 if(IsClientInGame(client))
662 {
663 char buffer[30];
664 menu.GetItem(selection, buffer, sizeof(buffer));
665 if(StrEqual(buffer, "hp"))
666 HPMenu(client).Display(client, MENU_TIME_FOREVER);
667 if(StrEqual(buffer, "normal"))
668 RegenerationMenu(client).Display(client, MENU_TIME_FOREVER);
669 else if(StrEqual(buffer, "hs"))
670 RegenerationHsMenu(client).Display(client, MENU_TIME_FOREVER);
671 }
672 }
673 case MenuAction_Cancel:
674 {
675 if(IsClientInGame(client) && selection == MenuCancel_ExitBack)
676 VipMenu(client, 1);
677 }
678 case MenuAction_End:
679 {
680 delete menu;
681 }
682 }
683}
684
685Menu HPMenu(int client)
686{
687 Menu menu = new Menu(HPMenuHandler);
688
689 menu.SetTitle("HP w nowej rundzie: %d", 100 + g_iAddHealth[client]);
690
691 menu.AddItem("increase", "Zwiększ o 1", g_iAddHealth[client] == 10 ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
692 menu.AddItem("decrease", "Zmniejsz o 1", g_iAddHealth[client] == 0 ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
693
694 menu.ExitBackButton = true;
695
696 return menu;
697}
698
699public int HPMenuHandler(Menu menu, MenuAction action, int client, int selection)
700{
701 switch(action)
702 {
703 case MenuAction_Select:
704 {
705 if(IsClientInGame(client))
706 {
707 char buffer[30];
708 menu.GetItem(selection, buffer, sizeof(buffer));
709
710 if(StrEqual(buffer, "increase"))
711 {
712 g_iAddHealth[client]++;
713 HPMenu(client).Display(client, MENU_TIME_FOREVER);
714 }
715 else if(StrEqual(buffer, "decrease"))
716 {
717 g_iAddHealth[client]--;
718 HPMenu(client).Display(client, MENU_TIME_FOREVER);
719 }
720 }
721 }
722 case MenuAction_Cancel:
723 {
724 if(IsClientInGame(client) && selection == MenuCancel_ExitBack)
725 HPMainMenu().Display(client, MENU_TIME_FOREVER);
726 }
727 case MenuAction_End:
728 {
729 delete menu;
730 }
731 }
732}
733
734Menu RegenerationMenu(int client)
735{
736 Menu menu = new Menu(RegenerationMenuHandler);
737
738 menu.SetTitle("HP za zabicie: %d", g_iRegernAddHealth[client]);
739
740 menu.AddItem("increase", "Zwiększ o 1", g_iRegernAddHealth[client] == 3 ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
741 menu.AddItem("decrease", "Zmniejsz o 1", g_iRegernAddHealth[client] == 0 ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
742
743 menu.ExitBackButton = true;
744
745 return menu;
746}
747
748public int RegenerationMenuHandler(Menu menu, MenuAction action, int client, int selection)
749{
750 switch(action)
751 {
752 case MenuAction_Select:
753 {
754 if(IsClientInGame(client))
755 {
756 char buffer[30];
757 menu.GetItem(selection, buffer, sizeof(buffer));
758
759 if(StrEqual(buffer, "increase"))
760 {
761 g_iRegernAddHealth[client]++;
762 RegenerationMenu(client).Display(client, MENU_TIME_FOREVER);
763 }
764 else if(StrEqual(buffer, "decrease"))
765 {
766 g_iRegernAddHealth[client]--;
767 RegenerationMenu(client).Display(client, MENU_TIME_FOREVER);
768 }
769 }
770 }
771 case MenuAction_Cancel:
772 {
773 if(IsClientInGame(client) && selection == MenuCancel_ExitBack)
774 HPMainMenu().Display(client, MENU_TIME_FOREVER);
775 }
776 case MenuAction_End:
777 {
778 delete menu;
779 }
780 }
781}
782
783Menu RegenerationHsMenu(int client)
784{
785 Menu menu = new Menu(RegenerationHsMenuHandler);
786
787
788 menu.SetTitle("HP za zabicie w głowę: %d", g_iRegernHsAddHealth[client]);
789
790 menu.AddItem("increase", "Zwiększ o 1", g_iRegernHsAddHealth[client] == 3 ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
791 menu.AddItem("decrease", "Zmniejsz o 1", g_iRegernHsAddHealth[client] == 0 ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
792
793 menu.ExitBackButton = true;
794
795 return menu;
796}
797
798public int RegenerationHsMenuHandler(Menu menu, MenuAction action, int client, int selection)
799{
800 switch(action)
801 {
802 case MenuAction_Select:
803 {
804 if(IsClientInGame(client))
805 {
806 char buffer[30];
807 menu.GetItem(selection, buffer, sizeof(buffer));
808
809 if(StrEqual(buffer, "increase"))
810 {
811 g_iRegernHsAddHealth[client]++;
812 RegenerationHsMenu(client).Display(client, MENU_TIME_FOREVER);
813 }
814 else if(StrEqual(buffer, "decrease"))
815 {
816 g_iRegernHsAddHealth[client]--;
817 RegenerationHsMenu(client).Display(client, MENU_TIME_FOREVER);
818 }
819 }
820 }
821 case MenuAction_Cancel:
822 {
823 if(IsClientInGame(client) && selection == MenuCancel_ExitBack)
824 HPMainMenu().Display(client, MENU_TIME_FOREVER);
825 }
826 case MenuAction_End:
827 {
828 delete menu;
829 }
830 }
831}
832
833Menu EqMenu(int client)
834{
835 Menu menu = new Menu(EqMenuHandler);
836
837 menu.SetTitle("Ekwipunek:");
838
839 if (!g_bKevlar[client])
840 menu.AddItem("kevlar", "[Wył] Kamizelka");
841 else
842 menu.AddItem("kevlar", "[Wł] Kamizelka");
843
844 if (!g_iHelmet[client])
845 menu.AddItem("helm", "[Wył] Hełm", !g_bKevlar[client] ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
846 else
847 menu.AddItem("helm", "[Wł] Hełm", !g_bKevlar[client] ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
848
849 if (!g_bDefuser[client])
850 menu.AddItem("defuser", "[Wył] Defuser");
851 else
852 menu.AddItem("defuser", "[Wł] Defuser");
853
854 menu.ExitBackButton = true;
855
856 return menu;
857}
858
859public int EqMenuHandler(Menu menu, MenuAction action, int client, int selection)
860{
861 switch(action)
862 {
863 case MenuAction_Select:
864 {
865 if(IsClientInGame(client))
866 {
867 char buffer[30];
868 menu.GetItem(selection, buffer, sizeof(buffer));
869 if(StrEqual(buffer, "kevlar"))
870 {
871 if (!g_bKevlar[client])
872 g_bKevlar[client] = true;
873 else
874 {
875 g_bKevlar[client] = false;
876 g_bHelmet[client] = false;
877 }
878
879 EqMenu(client).Display(client, MENU_TIME_FOREVER);
880 }
881 else if(StrEqual(buffer, "helm"))
882 {
883 if (!g_bHelmet[client])
884 g_bHelmet[client] = true;
885 else
886 g_bHelmet[client] = false;
887
888 EqMenu(client).Display(client, MENU_TIME_FOREVER);
889 }
890 else if(StrEqual(buffer, "defuser"))
891 {
892 if (!g_bDefuser[client])
893 g_bDefuser[client] = true;
894 else
895 g_bDefuser[client] = false;
896
897 EqMenu(client).Display(client, MENU_TIME_FOREVER);
898 }
899 }
900 }
901 case MenuAction_Cancel:
902 {
903 if(IsClientInGame(client) && selection == MenuCancel_ExitBack)
904 VipMenu(client, 1);
905 }
906 case MenuAction_End:
907 {
908 delete menu;
909 }
910 }
911}
912
913Menu MoneyMenu(int client)
914{
915 Menu menu = new Menu(MoneyMenuHandler);
916
917 menu.SetTitle("Dodatkowe Pieniądze:");
918
919 if (!g_bMoneyKill[client])
920 menu.AddItem("moneykill", "[Wył] Za zabicie: 200$");
921 else
922 menu.AddItem("moneykill", "[Wł] Za zabicie: 200$");
923
924 if (!g_bMoneyHsKill[client])
925 menu.AddItem("moneyhskill", "[Wył] Za zabicie strzałem w głowę: 100$");
926 else
927 menu.AddItem("moneyhskill", "[Wł] Za zabicie strzałem w głowę: 100$");
928
929 if (!g_bMoneyBomb[client])
930 menu.AddItem("moneybomb", "[Wył] Za podłożenie/rozbrojenie bomby: 200$");
931 else
932 menu.AddItem("moneybomb", "[Wł] Za podłożenie/rozbrojenie bomby: 200$");
933
934 menu.ExitBackButton = true;
935
936 return menu;
937}
938
939public int MoneyMenuHandler(Menu menu, MenuAction action, int client, int selection)
940{
941 switch(action)
942 {
943 case MenuAction_Select:
944 {
945 if(IsClientInGame(client))
946 {
947 char buffer[30];
948 menu.GetItem(selection, buffer, sizeof(buffer));
949 if(StrEqual(buffer, "moneykill"))
950 {
951 if (!g_bMoneyKill[client])
952 g_bMoneyKill[client] = true;
953 else
954 g_bMoneyKill[client] = false;
955
956 MoneyMenu(client).Display(client, MENU_TIME_FOREVER);
957 }
958 else if(StrEqual(buffer, "moneyhskill"))
959 {
960 if (!g_bMoneyHsKill[client])
961 g_bMoneyHsKill[client] = true;
962 else
963 g_bMoneyHsKill[client] = false;
964
965 MoneyMenu(client).Display(client, MENU_TIME_FOREVER);
966 }
967 else if(StrEqual(buffer, "moneybomb"))
968 {
969 if (!g_bMoneyBomb[client])
970 g_bMoneyBomb[client] = true;
971 else
972 g_bMoneyBomb[client] = false;
973
974 MoneyMenu(client).Display(client, MENU_TIME_FOREVER);
975 }
976 }
977 }
978 case MenuAction_Cancel:
979 {
980 if(IsClientInGame(client) && selection == MenuCancel_ExitBack)
981 VipMenu(client, 1);
982 }
983 case MenuAction_End:
984 {
985 delete menu;
986 }
987 }
988}
989
990Menu NadesMenu(int client)
991{
992 char buffer[60];
993 g_iNadeTaken[client] = view_as<int>(g_bHEGrenade[client]) + view_as<int>(g_bFirstFlash[client]) + view_as<int>(g_bSecondFlash[client]) + view_as<int>(g_bSmokeGrenade[client]) + view_as<int>(g_bFlameGrenade[client]);
994
995 Menu menu = new Menu(NadesMenuHandler);
996
997 menu.SetTitle("Granaty: %d/4", g_iNadeTaken[client]);
998
999 if (!g_bHEGrenade[client])
1000 menu.AddItem("he", "HE", (g_iNadeTaken[client] == 4 && !g_bHEGrenade[client]) ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
1001 else
1002 menu.AddItem("he", "[Wyb] HE", (g_iNadeTaken[client] == 4 && !g_bHEGrenade[client]) ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
1003
1004 if(!g_bFirstFlash[client])
1005 menu.AddItem("flash1", "Flash", (g_iNadeTaken[client] == 4 && !g_bFirstFlash[client]) ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
1006 else
1007 menu.AddItem("flash1", "[Wyb] Flash", (g_iNadeTaken[client] == 4 && !g_bFirstFlash[client]) ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
1008
1009 if(!g_bSecondFlash[client])
1010 menu.AddItem("flash1", "Flash", (g_iNadeTaken[client] == 4 && !g_bSecondFlash[client]) ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
1011 else
1012 menu.AddItem("flash1", "[Wyb] Flash", (g_iNadeTaken[client] == 4 && !g_bSecondFlash[client]) ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
1013
1014 if (!g_bSmokeGrenade[client])
1015 menu.AddItem("smoke", "Smoke", (g_iNadeTaken[client] == 4 && !g_bSmokeGrenade[client]) ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
1016 else
1017 menu.AddItem("smoke", "[Wyb] Smoke", (g_iNadeTaken[client] == 4 && !g_bSmokeGrenade[client]) ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
1018
1019 if (!g_bFlameGrenade[client])
1020 menu.AddItem("molo", "Molo", (g_iNadeTaken[client] == 4 && !g_bFlameGrenade[client]) ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
1021 else
1022 menu.AddItem("molo", "[Wyb] Molo", (g_iNadeTaken[client] == 4 && !g_bFlameGrenade[client]) ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
1023
1024
1025
1026 menu.ExitBackButton = true;
1027
1028 return menu;
1029}
1030
1031public int NadesMenuHandler(Menu menu, MenuAction action, int client, int selection)
1032{
1033 switch(action)
1034 {
1035 case MenuAction_Select:
1036 {
1037 if(IsClientInGame(client))
1038 {
1039 char buffer[30];
1040
1041 menu.GetItem(selection, buffer, sizeof(buffer));
1042 if(StrEqual(buffer, "he"))
1043 {
1044 if(!g_bHEGrenade[client])
1045 g_bHEGrenade[client] = true;
1046 else
1047 g_bHEGrenade[client] = true;
1048
1049 NadesMenu(client).Display(client, MENU_TIME_FOREVER);
1050 }
1051 else if(StrEqual(buffer, "flash1"))
1052 {
1053 if(!g_bFirstFlash[client])
1054 g_bFirstFlash[client] = true;
1055 else
1056 g_bFirstFlash[client] = false;
1057
1058 NadesMenu(client).Display(client, MENU_TIME_FOREVER);
1059 }
1060 else if(StrEqual(buffer, "flash2"))
1061 {
1062 if(!g_bSecondFlash[client])
1063 g_bSecondFlash[client] = true;
1064 else
1065 g_bSecondFlash[client] = false;
1066
1067 NadesMenu(client).Display(client, MENU_TIME_FOREVER);
1068 }
1069 else if(StrEqual(buffer, "smoke"))
1070 {
1071 if(!g_bSmokeGrenade[client])
1072 g_bSmokeGrenade[client] = true;
1073 else
1074 g_bSmokeGrenade[client] = false;
1075
1076 NadesMenu(client).Display(client, MENU_TIME_FOREVER);
1077 }
1078 else if(StrEqual(buffer, "molo"))
1079 {
1080 if(!g_bFlameGrenade[client])
1081 g_bFlameGrenade[client] = true;
1082 else
1083 g_bFlameGrenade[client] = false;
1084
1085 NadesMenu(client).Display(client, MENU_TIME_FOREVER);
1086 }
1087 }
1088 }
1089 case MenuAction_Cancel:
1090 {
1091 if(IsClientInGame(client) && selection == MenuCancel_ExitBack)
1092 VipMenu(client, 1);
1093 }
1094 case MenuAction_End:
1095 {
1096 delete menu;
1097 }
1098 }
1099}
1100
1101public Action RefreshVIPMenu(Handle timer, any client)
1102{
1103 if (IsValidEntity(client) && !IsFakeClient(client) && !IsVoteInProgress())
1104 VipMenu(client, 1);
1105
1106 return Plugin_Handled;
1107}