· 8 years ago · May 23, 2018, 11:54 AM
1/*================ Aktualizacje ================
2
3~ Wersja "0.1" >> Pierwsze wydanie pluginu.
4~ Wersja "0.2" >> Przepisanie pluginy na nowy syntax.
5~ Wersja "0.3" >> Dodano wiadomości na czacie przy danych eventach.
6~ Wersja "0.4" >> Poprawa wszelkich bugów oraz błędów.
7~ Wersja "0.5" >> Dodano translacje oraz poprawiono wyglÄ…d kodu.
8~ Wersja "0.6" >> Dodano Panel Administracyjny, poprawiono wiele błędów, usunięto pare zbędnych menu oraz usunięto translacje.
9~ Wersja "0.7" >> Zmieniono 3/4 kodu, poprawiono wygląd kodu oraz naprawiono wiele błędów i bugów.
10~ Wersja "0.8" >> Usunięto informacje na czacie pod !ranga, teraz !ranga wyświetla menu z wszystkimi potrzebnymi informacjami dla użytkownika.
11~ Wersja "0.9" >> Plugin został przepisany na zapis MYSQL.
12~ Wersja "1.0" >> Wszystko.
13~ Wersja "1.1" >> Dodanie odznak by xBonio, poprawiono kod na mysql, optymalizacja pluginu, dodanie nowych opcji do panelu administratora. //Zezwolenie by xBonio na użycie kodu z jego pluginu.
14~ Wersja "1.2" >> Dodanie topki w menu, dodanie kilku cvarów, poprawiono kod, oraz mała optymalizacja.
15~ Wersja "1.3" >> Dodanie punktów za zabójstwo z noża.
16~ Wersja "1.4" >> Naprawiono nativy, dodano nowe cvary, zoptymalizowano kod.
17~ Wersja "1.5" >> Dodano overlaye + dodatkowo została dodana opcja by włączyć/wyłączyć overlay'e.
18
19//Special credits for n.o.x, helped me a lot with mysql, and some other stuff, big love <3.
20//Special credits for xBonio, for his coins code.
21
22==============================================*/
23
24/* << compiller definitions >> */
25#pragma semicolon 1
26#pragma newdecls required
27
28/* << includes >> */
29#include <sourcemod>
30#include <sdktools>
31#include <sdkhooks>
32#include <cstrike>
33#include <clientprefs>
34#include <multicolors>
35#include <h2k_rangi>
36
37// ----------------------------- Macro ---------------------------
38#define LoopItemCount(%1) for(int %1 = 0; %1 < menu.ItemCount; %1++)
39#define LoopRanks(%1) for(int %1 = 1; %1 < sizeof g_iRankTable; %1++)
40#define LoopClients(%1) for(int %1 = 1; %1 <= MaxClients; %1++)\
41if(IsClientInGame(%1))
42
43#define ILOSC_COIN 200
44
45/* << ConVars >> */
46ConVar g_Cvar_PluginEnabled;
47ConVar g_Cvar_PunktyRozgrzewka;
48ConVar g_Cvar_MinimalnaIloscGraczy;
49ConVar g_Cvar_PunktyKill;
50ConVar g_Cvar_PunktyKillVip;
51ConVar g_Cvar_PunktyHs;
52ConVar g_Cvar_PunktyHsVip;
53ConVar g_Cvar_PunktyBombEnabled;
54ConVar g_Cvar_PunktyBombPlanted;
55ConVar g_Cvar_PunktyBombPlantedVip;
56ConVar g_Cvar_PunktyBombDefused;
57ConVar g_Cvar_PunktyBombDefusedVip;
58ConVar g_Cvar_PunktyWygranaRundaVip;
59ConVar g_Cvar_PunktyWygranaRunda;
60ConVar g_Cvar_PunktyMvpEnabled;
61ConVar g_Cvar_PunktyMvpPlayerVip;
62ConVar g_Cvar_PunktyMvpPlayer;
63ConVar g_Cvar_PunktyKnifeEnabled;
64ConVar g_Cvar_PunktyKnifeKill;
65ConVar g_Cvar_PunktyKnifeKillVip;
66ConVar g_Cvar_HudEnabled;
67
68bool g_bHUD[MAXPLAYERS+1];
69
70/* << Handles >> */
71Handle g_hSql;
72Handle g_hClientOverlaysCookies = INVALID_HANDLE;
73
74/* << Integers >> */
75int g_MinimalnaIloscGraczy; //taken from kento_rankme
76int g_iPoints[MAXPLAYERS+1];
77int g_iRank[MAXPLAYERS+1];
78int iCoin[65];
79int iCoin_Enable[65];
80int g_bClientPrefOverlays[MAXPLAYERS+1];
81
82int g_iRankTable[] =
83{
84 25,
85 50,
86 100,
87 250,
88 500,
89 750,
90 1000,
91 1250,
92 1500,
93 2000,
94 2500,
95 5000,
96 7500,
97 10000,
98 12500,
99 15000,
100 17000,
101 24000,
102 32000
103};
104
105char g_sRanksNames[][] =
106{
107 "Unranked",
108 "Silver 1",
109 "Silver 2",
110 "Silver 3",
111 "Silver 4",
112 "Silver Elite",
113 "Silver Elite Master",
114 "Gold Nova 1",
115 "Gold Nova 2",
116 "Gold Nova 3",
117 "Gold Nova Master",
118 "Master Guardian 1",
119 "Master Guardian 2",
120 "Master Guardian Elite",
121 "DMG",
122 "Legendary Eagle",
123 "Legendary Eagle Master",
124 "Supreme Master First Class",
125 "The Global Elite"
126};
127
128char nazwa_coina[ILOSC_COIN+1][300] = {
129 "Brak odznaki",
130 "Five Year Service Coin",
131
132 /*** Major ***/
133 "DH.SS 2013 Champion",
134 "DH.SS 2013 Finalist",
135 "DH.SS 2013 Semifinalist",
136 "DH.SS 2013 Quarterfinalist",
137
138 "EMS.O.K 2014 Champion",
139 "EMS.O.K 2014 Finalist",
140 "EMS.O.K 2014 Semifinalist",
141 "EMS.O.K 2014 Quarterfinalist",
142
143 "ESL.O.C 2014 Champion",
144 "ESL.O.C 2014 Finalist",
145 "ESL.O.C 2014 Semifinalist",
146 "ESL.O.C 2014 Quarterfinalist",
147 "ESL.O.C 2014 PEC Bronze",
148 "ESL.O.C 2014 PEC Silver",
149 "ESL.O.C 2014 PEC Gold",
150
151 "DH.W 2014 Champion",
152 "DH.W 2014 Finalist",
153 "DH.W 2014 Semifinalist",
154 "DH.W 2014 Quarterfinalist",
155 "DH.W 2014 PEC Bronze",
156 "DH.W 2014 PEC Silver",
157 "DH.W 2014 PEC Gold",
158
159 "ESL.O.K 2015 Champion",
160 "ESL.O.K 2015 Finalist",
161 "ESL.O.K 2015 Semifinalist",
162 "ESL.O.K 2015 Quarterfinalist",
163 "ESL.O.K 2015 PEC Bronze",
164 "ESL.O.K 2015 PEC Silver",
165 "ESL.O.K 2015 PEC Gold",
166
167 "ESL.O.C 2015 Champion",
168 "ESL.O.C 2015 Finalist",
169 "ESL.O.C 2015 Semifinalist",
170 "ESL.O.C 2015 Quarterfinalist",
171 "ESL.O.C 2015 PEC Bronze",
172 "ESL.O.C 2015 PEC Silver",
173 "ESL.O.C 2015 PEC Gold",
174
175 "DH.C-N 2015 PEC Bronze",
176 "DH.C-N 2015 PEC Silver",
177 "DH.C-N 2015 PEC Gold",
178 "DH.C-N 2015 FT Bronze",
179 "DH.C-N 2015 FT Silver",
180 "DH.C-N 2015 FT Gold",
181 "DH.C-N 2015 Champion",
182 "DH.C-N 2015 Finalist",
183 "DH.C-N 2015 Semifinalist",
184 "DH.C-N 2015 Quarterfinalist",
185
186 "MLG.C 2016 PEC Bronze",
187 "MLG.C 2016 PEC Silver",
188 "MLG.C 2016 PEC Gold",
189 "MLG.C 2016 FT Bronze",
190 "MLG.C 2016 FT Silver",
191 "MLG.C 2016 FT Gold",
192 "MLG.C 2016 Champion",
193 "MLG.C 2016 Finalist",
194 "MLG.C 2016 Semifinalist",
195 "MLG.C 2016 Quarterfinalist",
196
197 "ESL.O.C 2016 Champion",
198 "ESL.O.C 2016 Finalist",
199 "ESL.O.C 2016 Semifinalist",
200 "ESL.O.C 2016 Quarterfinalist",
201 "ESL.O.C 2016 PEC Bronze",
202 "ESL.O.C 2016 PEC Silver",
203 "ESL.O.C 2016 PEC Gold",
204 "ESL.O.C 2016 FT Bronze",
205 "ESL.O.C 2016 FT Silver",
206 "ESL.O.C 2016 FT Gold",
207
208 "E.Atlanta 2017 Champion",
209 "E.Atlanta 2017 Finalist",
210 "E.Atlanta 2017 Semifinalist",
211 "E.Atlanta 2017 Quarterfinalist",
212 "E.Atlanta 2017 PEC Bronze",
213 "E.Atlanta 2017 PEC Silver",
214 "E.Atlanta 2017 PEC Gold",
215
216 "PGL.K 2017 Champion",
217 "PGL.K 2017 Finalist",
218 "PGL.K 2017 Semifinalist",
219 "PGL.K 2017 Quarterfinalist",
220 "PGL.K 2017 PEC Bronze",
221 "PGL.K 2017 PEC Silver",
222 "PGL.K 2017 PEC Gold",
223
224 "E.Boston 2018 Champion",
225 "E.Boston 2018 Finalist",
226 "E.Boston 2018 Semifinalist",
227 "E.Boston 2018 Quarterfinalist",
228 "E.Boston 2018 PEC Bronze",
229 "E.Boston 2018 PEC Silver",
230 "E.Boston 2018 PEC Gold",
231
232 /*** Operation ***/
233 "Op.Payback Challenge",
234 "Op.Payback Silver",
235 "Op.Payback Gold",
236 "Op.Bravo Challenge",
237 "Op.Bravo Silver",
238 "Op.Bravo Gold",
239 "Op.Pheonix Challenge",
240 "Op.Pheonix Silver",
241 "Op.Pheonix Gold",
242 "Op.Breakout Challenge",
243 "Op.Breakout Silver",
244 "Op.Breakout Gold",
245 "Op.Vanguard Challenge",
246 "Op.Vanguard Silver",
247 "Op.Vanguard Gold",
248 "Op.Bloodhound Challenge",
249 "Op.Bloodhound Silver",
250 "Op.Bloodhound Gold",
251 "Op.Wildfire Challenge",
252 "Op.Wildfire Silver",
253 "Op.Wildfire Gold",
254 "Op.Hydra Challenge",
255 "Op.Hydra Silver",
256 "Op.Hydra Gold",
257 "Op.Hydra Diamond",
258
259 /*** Collectible Pin ***/
260 "C-Pin.O > Dust II",
261 "C-Pin.O > Guardian Elite",
262 "C-Pin.O > Mirage",
263 "C-Pin.O > Inferno",
264 "C-Pin.O > Italy",
265 "C-Pin.O > Victory",
266 "C-Pin.O > Militia",
267 "C-Pin.O > Nuke",
268 "C-Pin.O > Train",
269 "C-Pin.O > Guardian",
270 "C-Pin.O > Tactics",
271 "C-Pin.O > Guardian 2",
272 "C-Pin.O > Bravo",
273 "C-Pin.O > Baggage",
274 "C-Pin.O > Phoenix",
275 "C-Pin.O > Office",
276 "C-Pin.O > Cobblestone",
277 "C-Pin.O > Overpass",
278 "C-Pin.O > Bloodhound",
279 "C-Pin.O > Cache",
280 "C-Pin.O > Valeria Phoenix",
281 "C-Pin.O > Chrome",
282 "C-Pin.O > Guardian 3",
283 "C-Pin.O > Canals",
284 "C-Pin.O > Welcome to the Clutch",
285 "C-Pin.O > Death Sentence",
286 "C-Pin.O > Inferno 2",
287 "C-Pin.O > Wildfire",
288 "C-Pin.O > Easy Peasy",
289 "C-Pin.O > Aces High",
290 "C-Pin.O > Hydra",
291 "C-Pin.O > Howl",
292 "C-Pin.O > Brigadier General",
293
294 "C-Pin > Dust II",
295 "C-Pin > Guardian Elite",
296 "C-Pin > Mirage",
297 "C-Pin > Inferno",
298 "C-Pin > Italy",
299 "C-Pin > Victory",
300 "C-Pin > Militia",
301 "C-Pin > Nuke",
302 "C-Pin > Train",
303 "C-Pin > Guardian",
304 "C-Pin > Tactics",
305 "C-Pin > Guardian 2",
306 "C-Pin > Bravo",
307 "C-Pin > Baggage",
308 "C-Pin > Pheonix",
309 "C-Pin > Office",
310 "C-Pin > Cobblestone",
311 "C-Pin > Overpass",
312 "C-Pin > Bloodhound",
313 "C-Pin > Cache",
314 "C-Pin > Valeria Phoenix",
315 "C-Pin > Chrome",
316 "C-Pin > Guardian 3",
317 "C-Pin > Canals",
318 "C-Pin > Welcome to the Clutch",
319 "C-Pin > Death Sentence",
320 "C-Pin > Inferno 2",
321 "C-Pin > Wildfire",
322 "C-Pin > Easy Peasy",
323 "C-Pin > Aces High",
324 "C-Pin > Hydra",
325 "C-Pin > Howl",
326 "C-Pin > Brigadier General",
327
328 /*** Community ***/
329 "CCoin 2015 - 1",
330 "CCoin 2015 - 2",
331 "CCoin 2016 - 1",
332 "CCoin 2016 - 2",
333 "CCoin 2016 - 3",
334 "CCoin 2016 - 4",
335 "CCoin 2016 - 5",
336 "CCoin 2016 - 6",
337 "CCoin 2017 - 1",
338 "CCoin 2017 - 2",
339 "CCoin 2017 - 3",
340 "CCoin 2017 - 4",
341 "CCoin 2017 - 5",
342 "CCoin 2017 - 6",
343 "CCoin 2017 - 7",
344 "CCoin 2018 - 1",
345 "CCoin 2018 - 2",
346 "CCoin 2018 - 3",
347 "CCoin 2018 - 4",
348 "CCoin 2018 - 5",
349 "CCoin 2018 - 6"
350};
351
352int id_coina[ILOSC_COIN+1] = {
353 0, 874,
354 /*** Major ***/
355 875, 876, 877, 878, //DreamHack SteelSeries 2013
356 879, 880, 881, 882, //ESL One Katowice 2014
357 883, 884, 885, 886, 887, 888, 889, //ESL One Cologne 2014
358 890, 891, 892, 893, 894, 895, 896, //DreamHack Winter 2014
359 897, 898, 899, 900, 901, 902, 903, //ESL One Katowice 2015
360 904, 905, 906, 907, 908, 909, 910, //ESL One Cologne 2015
361 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, //DreamHack Cluj-Napoca 2015
362 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, //MLG Columbus 2016
363 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, //ESL One Cologne 2017
364 941, 942, 943, 944, 945, 946, 947, //ELEAGUE Atlanta 2017
365 948, 949, 950, 951, 952, 953, 954, //PGL Krakow 2017
366 955, 956, 957, 958, 959, 960, 961, //ELEAGUE Boston 2018
367 /*** Operation ***/
368 1001, 1002, 1003, //Payback
369 1013, 1014, 1015, //Bravo
370 1024, 1025, 1026, //Pheonix
371 1028, 1029, 1030, //Breakout
372 1316, 1317, 1318, //Vanguard
373 1327, 1328, 1329, //Bloodhound
374 1336, 1337, 1338, //Wildfire
375 4353, 4534, 4535, 4536, //Hydra
376 /*** Collectible ***/
377 6001, 6002, 6003, 6004, 6005, 6006, 6007, 6008, 6009, 6010,
378 6011, 6012, 6013, 6014, 6015, 6016, 6017, 6018, 6019, 6020,
379 6021, 6022,
380 6023, 6024, 6025, 6026, 6027, 6028, 6029, 6030, 6031, 6032, 6033, //Original
381 6101, 6102, 6103, 6104, 6105, 6106, 6107, 6108, 6109, 6110,
382 6111, 6112, 6113, 6114, 6115, 6116, 6117, 6118, 6119, 6120,
383 6121, 6122,
384 6123, 6124, 6125, 6126, 6127, 6128, 6129, 6130, 6131, 6132, 6133, //No Original
385 /*** Community ***/
386 1331, 1332, //2015
387 1339, 1340, 1341, 1342, 1343, 1344, //2016
388 1357, 1358, 1359, 1360, 1361, 1362, 1363, //2017
389 1367, 1368, 1369, 1370, 1371, 1372 //2018
390};
391
392/* << Informacje o pluginie >> */
393public Plugin myinfo =
394{
395 name = "[CS:GO] Rangi",
396 author = "Mesharsky & n.o.x",
397 description = "[CS:GO] Rangi & Odznaki + System punktów",
398 version = "1.4",
399 url = "http://steamcommunity.com/id/mesharskyH2K"
400};
401
402public void OnPluginStart()
403{
404 CreateTimer(0.1, Timer_UpdateHUD, INVALID_HANDLE, TIMER_REPEAT);
405
406 // <<- Eventy ->>
407 HookEvent("round_start", Event_RoundStart);
408 HookEvent("round_end", Event_RoundEnd);
409 HookEvent("round_mvp", Event_RoundMvp);
410 HookEvent("player_death", Event_PlayerDeath);
411 HookEvent("bomb_planted", Event_BombPlanted);
412 HookEvent("bomb_defused", Event_BombDefused);
413
414 // <<- Komendy Gracza ->>
415 RegConsoleCmd("sm_hud", CMD_HUD);
416 RegConsoleCmd("sm_ranga", CMD_MenuGlowne);
417 RegConsoleCmd("sm_lvl", CMD_MenuGlowne);
418 RegConsoleCmd("sm_coin", Command_CoinMenu);
419 RegConsoleCmd("sm_coins", Command_CoinMenu);
420
421 // <<- Komendy Admina ->>
422 RegAdminCmd("sm_panel", CMD_PanelRangi, ADMFLAG_ROOT); //Panel na flage "z"
423
424 // <<- ConVary ->>
425 g_Cvar_PluginEnabled = CreateConVar("rangi_enabled", "1", "Włączyć czy wyłączyć rangi?");
426 g_Cvar_PunktyRozgrzewka = CreateConVar("rangi_rozgrzewka", "0", "Czy naliczać punkty podczas rozgrzewki?");
427 g_Cvar_PunktyBombEnabled = CreateConVar("rangi_bomb_enabled", "1", "Czy włączyć naliczanie punktów za podłożenie/rozbrojenie bomby?");
428 g_Cvar_PunktyMvpEnabled = CreateConVar("rangi_mvp_enabled", "1", "Czy włączyć naliczanie punktów za bycie MVP?");
429 g_Cvar_PunktyKnifeEnabled = CreateConVar("rangi_knife_enabled", "1", "Czy włączyć naliczanie punktów za zabójstwo z noża?");
430 g_Cvar_HudEnabled = CreateConVar("rangi_hud_enabled", "0", "Hud na środku ekranu ma być włączony czy wyłączony?");
431 g_Cvar_MinimalnaIloscGraczy = CreateConVar("rangi_ilosc_graczy", "2", "Ile musi być graczy żeby punkty działały.", _, true, 0.0);
432 g_Cvar_PunktyKill = CreateConVar("rangi_kill", "1", "Ila dodawać punktów za zabójstwo");
433 g_Cvar_PunktyKillVip = CreateConVar("rangi_kill_vip", "2", "Ile dodawać punktów za zabójstwo (VIP)");
434 g_Cvar_PunktyHs = CreateConVar("rangi_kill_hs", "3", "Ile dodawać punktów za headshot'a?");
435 g_Cvar_PunktyHsVip = CreateConVar("rangi_kill_hs_vip", "5", "Ile dodawać punktów za headshot'a (VIP)");
436 g_Cvar_PunktyBombPlanted = CreateConVar("rangi_bomb_planted", "2", "Ile dodawać punktów za podłożenie bomby");
437 g_Cvar_PunktyBombPlantedVip = CreateConVar("rangi_bomb_planted_vip", "5", "Ile dodawać pkt za podłożenie bomby (VIP)");
438 g_Cvar_PunktyBombDefused = CreateConVar("rangi_bomb_defused", "2", "Ile dodawać punktów za rozbrojenie bomby");
439 g_Cvar_PunktyBombDefusedVip = CreateConVar("rangi_bomb_defused_vip", "5", "Ile dodawać pkt za rozbrojenie bomby (VIP)");
440 g_Cvar_PunktyWygranaRunda = CreateConVar("wygrana_runda", "2", "Ile dodawać punktów za wygranie rundy");
441 g_Cvar_PunktyWygranaRundaVip = CreateConVar("wygrana_runda_vip", "4", "Ile dodawać punktów za wygranie rundy (VIP)");
442 g_Cvar_PunktyMvpPlayer = CreateConVar("mvp_player", "3", "Ile dostanie punktów gracz MVP?");
443 g_Cvar_PunktyMvpPlayerVip = CreateConVar("mvp_player_vip", "5", "Ile dostanie punktów gracz MVP (VIP)?");
444 g_Cvar_PunktyKnifeKill = CreateConVar("rangi_kill_knife", "4", "Ile dostanie punktów gracz za zabójstwo z noża?");
445 g_Cvar_PunktyKnifeKillVip = CreateConVar("rangi_kill_knife_vip", "7", "Ile dostanie punktów gracz za zabójstwo z noża (VIP)?");
446
447 // <<- Generowanie pliku do edycji ConVar ->>
448 AutoExecConfig(true, "H2K_RangiCoins_Config");
449
450 // <<- MySQL Shit ->>
451 DB_Connect();
452 g_hClientOverlaysCookies = RegClientCookie("OV Overlays", "set overlays on / off ", CookieAccess_Private);
453 SetCookieMenuItem(OVPrefSelected, 0, "OV Prefs");
454}
455
456public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
457{
458 CreateNative("Rangi_GetPointsAmount", Native_GetPointsAmount);
459 CreateNative("Rangi_GetRank", Native_GetRank);
460 CreateNative("Rangi_GetCoin", Native_GetCoin);
461
462 RegPluginLibrary("h2k_rangi");
463
464 return APLRes_Success;
465}
466
467public void OnConfigsExecuted() {
468 g_MinimalnaIloscGraczy = GetConVarInt(g_Cvar_MinimalnaIloscGraczy);
469}
470
471/* << Na starcie mapy >> */
472public void OnMapStart()
473{
474 SDKHook(FindEntityByClassname(MAXPLAYERS + 1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
475
476 // Download and precache overlays
477 char sBuffer[64];
478 LoopRanks(i)
479 {
480 Format(sBuffer, sizeof(sBuffer), "materials/katujemy_overlays/rank_%d.vmt", i);
481 AddFileToDownloadsTable(sBuffer);
482 Format(sBuffer, sizeof(sBuffer), "materials/katujemy_overlays/rank_%d.vtf", i);
483 AddFileToDownloadsTable(sBuffer);
484 Format(sBuffer, sizeof(sBuffer), "katujemy_overlays/rank_%d.vmt", i);
485 PrecacheDecal(sBuffer, true);
486 Format(sBuffer, sizeof(sBuffer), "katujemy_overlays/rank_%d.vmt", i);
487 PrecacheDecal(sBuffer, true);
488 }
489
490 // <<- Pobieramy nasz dźwięk ->>
491 AddFileToDownloadsTable("sound/katujemy/rangi/awans.mp3");
492 PrecacheSound("*/katujemy/rangi/awans.mp3", true);
493}
494
495/* << Na końcu mapy >> */
496public void OnMapEnd()
497{
498 LoopClients(i)
499 DB_SaveInfo(i); //Zapis pod koniec mapy
500 SDKUnhook(FindEntityByClassname(MAXPLAYERS + 1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
501}
502
503public void OnClientPutInServer(int client)
504{
505 if (!g_Cvar_PluginEnabled.BoolValue)
506 {
507 return;
508 }
509
510 g_iRank[client] = 0;
511 g_iPoints[client] = 0;
512 iCoin[client] = 0;
513 iCoin_Enable[client] = 0;
514
515 if (g_Cvar_HudEnabled.BoolValue)
516 {
517 g_bHUD[client] = true;
518 }
519 else
520 {
521 g_bHUD[client] = false;
522 }
523
524 DB_LoadInfo(client);
525 LoadClientCookiesFor(client);
526}
527
528public void OnClientDisconnect(int client)
529{
530 if (!g_Cvar_PluginEnabled.BoolValue)
531 {
532 return;
533 }
534
535 DB_SaveInfo(client);
536
537 g_iRank[client] = 0;
538 g_iPoints[client] = 0;
539 iCoin[client] = 0;
540 iCoin_Enable[client] = 0;
541}
542
543/* << MySQL Shit >> */
544public Action DB_Connect()
545{
546 if (!g_Cvar_PluginEnabled.BoolValue)
547 {
548 return;
549 }
550
551 if(SQL_CheckConfig("h2k_rangi"))
552 {
553 char DBBuffer[512];
554 g_hSql = SQL_Connect("h2k_rangi", true, DBBuffer, sizeof(DBBuffer));
555 if (g_hSql == INVALID_HANDLE)
556 LogError("[Katujemy.eu] Could not connect: %s", DBBuffer);
557 else
558 {
559 SQL_LockDatabase(g_hSql);
560 SQL_FastQuery(g_hSql, "CREATE TABLE IF NOT EXISTS `h2k_user` (`auth_data` VARCHAR(64) NOT NULL, `name` VARCHAR(64) NOT NULL, `points` INT NOT NULL, `rank` INT NOT NULL, `coin` INT(6), `ma_coina` INT(1), UNIQUE KEY `auth_data` (`auth_data`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;");
561 SQL_UnlockDatabase(g_hSql);
562 }
563 }
564 else
565 SetFailState("Nie mozna odnalezc konfiguracji 'h2k_rangi' w databases.cfg.");
566}
567
568public void DB_LoadInfo(int client)
569{
570 if(g_hSql != INVALID_HANDLE)
571 {
572 char _authid[64];
573 GetClientAuthId(client, AuthId_Steam2, _authid, 63);
574
575 char sQuery[256];
576 Format(sQuery, sizeof(sQuery), "SELECT points, rank, coin, ma_coina FROM h2k_user WHERE auth_data = '%s';", _authid);
577
578 SQL_LockDatabase(g_hSql);
579 Handle hQuery = SQL_Query(g_hSql, sQuery);
580
581 if(hQuery == INVALID_HANDLE)
582 {
583 char blad[255];
584 SQL_GetError(g_hSql, blad, sizeof(blad));
585 LogError("Nie mozna odszukac z tabeli. (blad: %s)", blad);
586 CloseHandle(g_hSql);
587 }
588 else if(SQL_FetchRow(hQuery))
589 {
590 g_iPoints[client] = SQL_FetchInt(hQuery, 0);
591 g_iRank[client] = SQL_FetchInt(hQuery, 1);
592 iCoin[client] = SQL_FetchInt(hQuery, 2);
593 iCoin_Enable[client] = SQL_FetchInt(hQuery, 3);
594 }
595 else
596 {
597 g_iRank[client] = 0;
598 g_iPoints[client] = 0;
599 iCoin[client] = 0;
600 iCoin_Enable[client] = 0;
601 }
602 CloseHandle(hQuery);
603 SQL_UnlockDatabase(g_hSql);
604 }
605}
606
607public void DB_SaveInfo(int client)
608{
609 if(!IsValidClient(client) || IsFakeClient(client))
610 return;
611
612 char authid[64];
613 if(!GetClientAuthId(client, AuthId_Steam2, authid, sizeof(authid)))
614 return;
615
616 char nick[64];
617 char EscapedName[64];
618
619 GetClientName(client, nick, sizeof(nick));
620 SQL_EscapeString(g_hSql, nick, EscapedName, sizeof(nick));
621
622 char sQuery[5000];
623 Format(sQuery, sizeof(sQuery), "INSERT INTO `h2k_user` (auth_data, name, points, rank, coin, ma_coina) VALUES ('%s', '%s', %d, %d, %i, %i) ON DUPLICATE KEY UPDATE name=VALUES(name), points=VALUES(points), rank=VALUES(rank), coin=VALUES(coin), ma_coina=VALUES(ma_coina)", authid, EscapedName, g_iPoints[client], g_iRank[client], iCoin[client], iCoin_Enable[client]);
624 SQL_TQuery(g_hSql, DB_SaveInfoCallback, sQuery);
625}
626
627public void LoadClientCookiesFor(int client)
628{
629 char buffer[5];
630 GetClientCookie(client, g_hClientOverlaysCookies, buffer, 5);
631 if(!StrEqual(buffer,""))
632 {
633 g_bClientPrefOverlays[client] = StringToInt(buffer);
634 }
635 if(StrEqual(buffer,"")){
636 g_bClientPrefOverlays[client] = 1;
637 }
638}
639
640public Action PokazTopke(int client, int args)
641{
642 char query[256];
643
644 DataPack info_pack = new DataPack();
645 info_pack.WriteCell(client); // client
646
647 Format(query,sizeof(query), "SELECT name, points, rank FROM h2k_user WHERE 1 ORDER BY points DESC");
648 SQL_TQuery(g_hSql, DB_TopCallback, query, info_pack);
649 return Plugin_Handled;
650}
651
652public void DB_TopCallback(Handle owner, Handle hndl, const char[] error, DataPack info_pack)
653{
654 if(hndl == INVALID_HANDLE)
655 {
656 LogError("[TOP] Query failed! %s", error);
657 return;
658 }
659
660 info_pack.Reset(); // Get some info !
661 int client = info_pack.ReadCell();
662
663 if(client == 0 || !IsClientInGame(client))
664 return;
665
666 delete info_pack;
667
668 int i;
669
670 Menu menu = new Menu(TOP_Handler, MENU_ACTIONS_ALL);
671 menu.SetTitle("[#TOP] Nick - Ranga - Punkty");
672
673 char menu_item[256];
674
675 while(SQL_FetchRow(hndl))
676 {
677 i++;
678 SQL_FetchString(hndl, 0, menu_item, sizeof(menu_item));
679
680 Format(menu_item, sizeof(menu_item), "#%d - %s - %s - [ %d ]", i, menu_item, g_sRanksNames[SQL_FetchInt(hndl, 2)], SQL_FetchInt(hndl, 1));
681 menu.AddItem("", menu_item);
682 }
683
684 if(i == 0)
685 menu.AddItem("no_records", "Wygląda na to, że ranking jest czysty.");
686
687 menu.ExitButton = true;
688 menu.Display(client, 0);
689}
690
691public int TOP_Handler(Menu menu, MenuAction action, int param1, int param2)
692{
693 return 0;
694}
695
696public Action Potwierdz_Reset(int client, int args)
697{
698 Menu menureset = new Menu(Menu_ResetRang);
699 menureset.SetTitle("Czy na pewno chcesz wyczyścyć wszystkie rangi & punkty & odznaki graczy?\nPamiętaj że tej akcji nie możesz cofnąć!");
700 menureset.AddItem("opcja1", "» NIE!");
701 menureset.AddItem("opcja1", "» NIE!");
702 menureset.AddItem("opcja2", "» TAK!!!");
703 menureset.AddItem("opcja1", "» NIE!");
704 menureset.ExitButton = true;
705 menureset.Display(client, 0);
706}
707
708public int Menu_ResetRang(Menu menureset, MenuAction action, int client, int itemNum)
709{
710 if (action == MenuAction_Select)
711 {
712 char info[32];
713 GetMenuItem(menureset, itemNum, info, sizeof(info));
714
715 if (strcmp(info, "opcja1") == 0) {
716 CMD_PanelRangi(client, 0);
717 }
718 else if (strcmp(info, "opcja2") == 0) {
719 Wyczysc_Wszystko(client, 0);
720 }
721 }
722
723 else if (action == MenuAction_End) {
724 CloseHandle(menureset);
725 }
726}
727
728public Action Wyczysc_Wszystko(int client, int args)
729{
730 char sQuery[1000];
731 Format(sQuery, sizeof(sQuery), "DELETE FROM `h2k_user` WHERE 1=1");
732 SQL_TQuery(g_hSql, DB_SaveInfoCallback, sQuery);
733
734 LoopClients(i){
735 if(IsClientInGame(i))
736 OnClientPutInServer(i);
737 }
738
739 CPrintToChat(client, "★ {lightred}[Katujemy.eu -> Rangi]{yellow} Baza została wyczyszczona.");
740 return Plugin_Handled;
741}
742
743public int DB_SaveInfoCallback(Handle owner, Handle query, const char[] error, any data)
744{
745 if(query == INVALID_HANDLE)
746 {
747 LogError("[RANKS] Failed to save client info (error: %s)", error);
748 return;
749 }
750}
751
752/* << Eventy >> */
753public Action Event_PlayerDeath(Event hEvent, const char[] chName, bool bDontBroadcast)
754{
755 if (!g_Cvar_PluginEnabled.BoolValue)
756 {
757 return;
758 }
759
760 if (GetCurrentPlayers() < g_MinimalnaIloscGraczy)
761 return;
762
763 bool headshot = GetEventBool(hEvent, "headshot");
764 int attacker = GetClientOfUserId(hEvent.GetInt("attacker"));
765 int client = GetClientOfUserId(hEvent.GetInt("userid"));
766 int iPoints;
767
768 char weapon[64];
769 GetEventString(hEvent, "weapon", weapon, sizeof(weapon));
770 ReplaceString(weapon, sizeof(weapon), "weapon_", "");
771
772 if (StrEqual(weapon, "knife_default_ct") || StrEqual(weapon, "knife_default_t") || StrEqual(weapon, "knife_t") || StrEqual(weapon, "knifegg") || StrEqual(weapon, "knife_flip") || StrEqual(weapon, "knife_gut") || StrEqual(weapon, "knife_karambit") || StrEqual(weapon, "bayonet") || StrEqual(weapon, "knife_m9_bayonet") || StrEqual(weapon, "knife_butterfly") || StrEqual(weapon, "knife_tactical") || StrEqual(weapon, "knife_falchion") || StrEqual(weapon, "knife_push") || StrEqual(weapon, "knife_survival_bowie")) {
773 weapon = "knife";
774 }
775
776 if (JestRozgrzewka() && !g_Cvar_PunktyRozgrzewka.BoolValue)
777 {
778 return;
779 }
780
781 if (!attacker)
782 return;
783
784 if (attacker == client)
785 return;
786
787 if (!IsValidClient(attacker))
788 return;
789
790 if (IsPlayerVIP(attacker)) // Zamiast pakować tutaj kupe kodu można użyć operatora warunkowego: warunek ? wyrazenie_true : wyrazenie_false
791 {
792 iPoints = headshot?GetConVarInt(g_Cvar_PunktyHsVip):GetConVarInt(g_Cvar_PunktyKillVip);
793 GivePoints(attacker, iPoints);
794 CPrintToChat(attacker, "★ {lightred}[Rangi -> Vip]{yellow} Jako {green}VIP {yellow}otrzymałeś {green}%i {yellow}punktów za {darkred}%s.", iPoints, headshot?"HeadShota":"zabójstwo");
795
796 if (StrEqual(weapon, "knife"))
797 {
798 if (!g_Cvar_PunktyKnifeEnabled.BoolValue)
799 {
800 return;
801 }
802
803 iPoints = GetConVarInt(g_Cvar_PunktyKnifeKillVip);
804 GivePoints(attacker, iPoints);
805 CPrintToChat(attacker, "★ {lightred}[Rangi -> Vip]{yellow} Jako {green}VIP {yellow}otrzymałeś {green}%i {yellow}punktów za zabójstwo z noża", iPoints);
806 }
807 }
808 else
809 {
810 iPoints = headshot?GetConVarInt(g_Cvar_PunktyHs):GetConVarInt(g_Cvar_PunktyKill);
811 GivePoints(attacker, iPoints);
812 CPrintToChat(attacker, "★ {lightred}[Rangi]{yellow} Otrzymałeś {green}%i {yellow}punkty za {darkred}%s.", iPoints, headshot?"HeadShota":"zabójstwo");
813
814 if (StrEqual(weapon, "knife"))
815 {
816 if (!g_Cvar_PunktyKnifeEnabled.BoolValue)
817 {
818 return;
819 }
820
821 iPoints = GetConVarInt(g_Cvar_PunktyKnifeKill);
822 GivePoints(attacker, iPoints);
823 CPrintToChat(attacker, "★ {lightred}[Rangi]{yellow} Otrzymałeś {green}%i {yellow}punktów za zabójstwo z noża", iPoints);
824 }
825 }
826}
827
828public Action Event_BombPlanted(Handle hEvent, const char[] chName, bool bDontBroadcast)
829{
830 if (!g_Cvar_PluginEnabled.BoolValue)
831 {
832 return;
833 }
834
835 if (!g_Cvar_PunktyBombEnabled.BoolValue)
836 {
837 return;
838 }
839
840 if (GetCurrentPlayers() < g_MinimalnaIloscGraczy)
841 return;
842
843 int client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
844
845 if (!IsValidClient(client))
846 return;
847
848 int iPoints = IsPlayerVIP(client)?GetConVarInt(g_Cvar_PunktyBombPlantedVip):GetConVarInt(g_Cvar_PunktyBombPlanted);
849 GivePoints(client, iPoints);
850 CPrintToChat(client, "★ {lightred}%s{green}%i {yellow}punktów za {darkred}Podłożenie Bomby", IsPlayerVIP(client)?"[Rangi -> Vip]{yellow} Jako {green}VIP {yellow}otrzymałeś ":"[Rangi]{yellow} Otrzymałeś ", iPoints);
851}
852
853public Action Event_BombDefused(Handle hEvent, const char[] chName, bool bDontBroadcast)
854{
855 if (!g_Cvar_PluginEnabled.BoolValue)
856 {
857 return;
858 }
859
860 if (!g_Cvar_PunktyBombEnabled.BoolValue)
861 {
862 return;
863 }
864
865 if (GetCurrentPlayers() < g_MinimalnaIloscGraczy)
866 return;
867
868 int client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
869
870 if (!IsValidClient(client))
871 return;
872
873 int iPoints = IsPlayerVIP(client)?GetConVarInt(g_Cvar_PunktyBombDefusedVip):GetConVarInt(g_Cvar_PunktyBombDefused);
874 GivePoints(client, iPoints);
875 CPrintToChat(client, "★ {lightred}%s{green}%i {yellow}punktów za {darkred}Rozbrojenie Bomby", IsPlayerVIP(client)?"[Rangi -> Vip]{yellow} Jako {green}VIP {yellow}otrzymałeś ":"[Rangi]{yellow} Otrzymałeś ", iPoints);
876}
877
878public Action Event_RoundMvp(Event event, char[] chName, bool bDontBroadcast)
879{
880 if (!g_Cvar_PluginEnabled.BoolValue)
881 {
882 return;
883 }
884
885 if (!g_Cvar_PunktyMvpEnabled.BoolValue)
886 {
887 return;
888 }
889
890 if (GetCurrentPlayers() < g_MinimalnaIloscGraczy)
891 return;
892
893 int client = GetClientOfUserId(GetEventInt(event, "userid"));
894
895 if (!IsValidClient(client))
896 return;
897
898 int iPoints = IsPlayerVIP(client)?GetConVarInt(g_Cvar_PunktyMvpPlayerVip):GetConVarInt(g_Cvar_PunktyMvpPlayer);
899 GivePoints(client, iPoints);
900 CPrintToChat(client, "★ {lightred}%s{green}%i {yellow}punktów za {darkred}bycie graczem MVP", IsPlayerVIP(client)?"[Rangi -> Vip]{yellow} Jako {green}VIP {yellow}otrzymałeś ":"[Rangi]{yellow} Otrzymałeś ", iPoints);
901}
902
903public Action Event_RoundStart(Event event, char[] chName, bool bDontBroadcast)
904{
905 if (!g_Cvar_PluginEnabled.BoolValue)
906 {
907 return;
908 }
909
910 if (GetCurrentPlayers() < g_MinimalnaIloscGraczy)
911 {
912 CPrintToChatAll("{olive}=====================================");
913 CPrintToChatAll("★ {lightred}[Rangi]{yellow} Na serwerze jest {darkred}zbyt mało{yellow} graczy by system rang naliczał punkty, potrzeba minimum {lightred}%i{yellow}, graczy.", GetConVarInt(g_Cvar_MinimalnaIloscGraczy));
914 CPrintToChatAll("{olive}=====================================");
915 }
916}
917
918public Action Event_RoundEnd(Event event, char[] chName, bool bDontBroadcast)
919{
920 if (!g_Cvar_PluginEnabled.BoolValue)
921 {
922 return;
923 }
924
925 if (GetCurrentPlayers() < g_MinimalnaIloscGraczy)
926 return;
927
928 int winnerTeam = GetEventInt(event, "winner");
929
930 if (JestRozgrzewka() && !g_Cvar_PunktyRozgrzewka.BoolValue)
931
932 LoopClients(i)
933 {
934 if(GetClientTeam(i) == winnerTeam)
935 {
936 int iPoints = IsPlayerVIP(i)?GetConVarInt(g_Cvar_PunktyWygranaRundaVip):GetConVarInt(g_Cvar_PunktyWygranaRunda);
937 GivePoints(i, iPoints);
938 CPrintToChat(i, "★ {lightred}%s{green}%i {yellow}punkty za {darkred}Wygranie Rundy", IsPlayerVIP(i)?"[Rangi -> Vip]{yellow} Jako {green}VIP {yellow}Otrzymałeś ":"[Rangi]{yellow} Otrzymałeś ", iPoints);
939 DB_SaveInfo(i); // Zapis tylko i wyłącznie pod koniec rundy, po co zapychać serwer..
940 }
941 }
942}
943
944public Action Command_CoinMenu(int client, int args)
945{
946 if(!IsValidClient(client)) return;
947
948 Handle MenuHandle = CreateMenu(Command_CoinHandler);
949 SetMenuTitle(MenuHandle, "Wybierz odznake:\n- Aktualna: [ %s ]\n", nazwa_coina[iCoin[client]]);
950 if(iCoin[client] == 0)
951 {
952 char text[310];
953 Format(text, sizeof(text), "> %s <", nazwa_coina[0]);
954 AddMenuItem(MenuHandle, "0", text, ITEMDRAW_DISABLED);
955 }
956 else
957 AddMenuItem(MenuHandle, "0", nazwa_coina[0], ITEMDRAW_DEFAULT);
958 if(iCoin[client] == 1)
959 {
960 char text[310];
961 Format(text, sizeof(text), "> %s <", nazwa_coina[1]);
962 AddMenuItem(MenuHandle, "1", text, ITEMDRAW_DISABLED);
963 }
964 else
965 AddMenuItem(MenuHandle, "1", nazwa_coina[1], ITEMDRAW_DEFAULT);
966
967 AddMenuItem(MenuHandle, "2", "Major Pin");
968 AddMenuItem(MenuHandle, "3", "Operation Pin");
969 AddMenuItem(MenuHandle, "4", "Collectible Pin");
970 AddMenuItem(MenuHandle, "5", "Community Coin");
971
972 DisplayMenu(MenuHandle, client, 30);
973}
974public int Command_CoinHandler(Handle menu, MenuAction action, int client, int itemNum)
975{
976 if(action == MenuAction_Select)
977 {
978 char info[10];
979 GetMenuItem(menu, itemNum, info, sizeof(info));
980
981 if(StrEqual(info, "0"))
982 {
983 iCoin[client] = 0;
984 iCoin_Enable[client] = 0;
985 CPrintToChat(client, "★ {lightred}[Katujemy.eu -> Odznaki] {yellow}Wyłączyłeś odznake");
986 }
987 else if(StrEqual(info, "1"))
988 {
989 iCoin[client] = 1;
990 iCoin_Enable[client] = 1;
991 CPrintToChat(client, "★ {lightred}[Katujemy.eu -> Odznaki] {yellow}Ustawiłeś odznake: {darkred}%s", nazwa_coina[1]);
992 }
993 else if(StrEqual(info, "2"))
994 MajorPin(client);
995 else if(StrEqual(info, "3"))
996 OperationPin(client);
997 else if(StrEqual(info, "4"))
998 CollectiblenPin(client);
999 else if(StrEqual(info, "5"))
1000 CommunityPin(client);
1001 }
1002 else if(action == MenuAction_End)
1003 CloseHandle(menu);
1004}
1005
1006public Action MajorPin(int client)
1007{
1008 if(!IsValidClient(client)) return;
1009
1010 Handle MenuHandle = CreateMenu(CoinHandler);
1011 SetMenuTitle(MenuHandle, "Wybierz odznake:\n- Aktualna: [ %s ]\n", nazwa_coina[iCoin[client]]);
1012 char numerek[6];
1013 for(int i = 2; i <= 88; i++)
1014 {
1015 IntToString(i, numerek, sizeof(numerek));
1016 if(i == iCoin[client])
1017 {
1018 char text[310];
1019 Format(text, sizeof(text), "> %s <", nazwa_coina[i]);
1020 AddMenuItem(MenuHandle, numerek, text, ITEMDRAW_DISABLED);
1021 }
1022 else
1023 AddMenuItem(MenuHandle, numerek, nazwa_coina[i], ITEMDRAW_DEFAULT);
1024 }
1025 DisplayMenu(MenuHandle, client, 30);
1026}
1027public Action OperationPin(int client)
1028{
1029 if(!IsValidClient(client)) return;
1030
1031 Handle MenuHandle = CreateMenu(CoinHandler);
1032 SetMenuTitle(MenuHandle, "Wybierz odznake:\n- Aktualna: [ %s ]\n", nazwa_coina[iCoin[client]]);
1033 char numerek[6];
1034 for(int i = 89; i <= 113; i++)
1035 {
1036 IntToString(i, numerek, sizeof(numerek));
1037 if(i == iCoin[client])
1038 {
1039 char text[310];
1040 Format(text, sizeof(text), "> %s <", nazwa_coina[i]);
1041 AddMenuItem(MenuHandle, numerek, text, ITEMDRAW_DISABLED);
1042 }
1043 else
1044 AddMenuItem(MenuHandle, numerek, nazwa_coina[i], ITEMDRAW_DEFAULT);
1045 }
1046 DisplayMenu(MenuHandle, client, 30);
1047}
1048public Action CollectiblenPin(int client)
1049{
1050 if(!IsValidClient(client)) return;
1051
1052 Handle MenuHandle = CreateMenu(CoinHandler);
1053 SetMenuTitle(MenuHandle, "Wybierz odznake:\n- Aktualna: [ %s ]\n", nazwa_coina[iCoin[client]]);
1054 char numerek[6];
1055 for(int i = 114; i <= 179; i++)
1056 {
1057 IntToString(i, numerek, sizeof(numerek));
1058 if(i == iCoin[client])
1059 {
1060 char text[310];
1061 Format(text, sizeof(text), "> %s <", nazwa_coina[i]);
1062 AddMenuItem(MenuHandle, numerek, text, ITEMDRAW_DISABLED);
1063 }
1064 else
1065 AddMenuItem(MenuHandle, numerek, nazwa_coina[i], ITEMDRAW_DEFAULT);
1066 }
1067 DisplayMenu(MenuHandle, client, 30);
1068}
1069
1070public Action CommunityPin(int client)
1071{
1072 if(!IsValidClient(client)) return;
1073
1074 Handle MenuHandle = CreateMenu(CoinHandler);
1075 SetMenuTitle(MenuHandle, "Wybierz odznake:\n- Aktualna: [ %s ]\n", nazwa_coina[iCoin[client]]);
1076 char numerek[6];
1077 for(int i = 180; i <= 200; i++)
1078 {
1079 IntToString(i, numerek, sizeof(numerek));
1080 if(i == iCoin[client])
1081 {
1082 char text[310];
1083 Format(text, sizeof(text), "> %s <", nazwa_coina[i]);
1084 AddMenuItem(MenuHandle, numerek, text, ITEMDRAW_DISABLED);
1085 }
1086 else
1087 AddMenuItem(MenuHandle, numerek, nazwa_coina[i], ITEMDRAW_DEFAULT);
1088 }
1089 DisplayMenu(MenuHandle, client, 30);
1090}
1091
1092public int CoinHandler(Handle menu, MenuAction action, int client, int itemNum)
1093{
1094 if(action == MenuAction_Select)
1095 {
1096 char info[10];
1097 GetMenuItem(menu, itemNum, info, sizeof(info));
1098 iCoin[client] = StringToInt(info);
1099 iCoin_Enable[client] = 1;
1100
1101 DB_SaveInfo(client);
1102
1103 CPrintToChat(client, "★ {lightred}[Katujemy.eu -> Odznaki] {yellow}Ustawiłeś odznake: {darkred}%s", nazwa_coina[iCoin[client]]);
1104 }
1105 else if(action == MenuAction_End)
1106 CloseHandle(menu);
1107}
1108
1109/* << Cmds >>*/
1110public Action CMD_MenuGlowne(int client, int args)
1111{
1112 Menu menuglowne = new Menu(Menu_menuglowne);
1113
1114 if(g_iRank[client] == sizeof(g_iRankTable)-1)
1115 menuglowne.SetTitle("Witaj, [ %N ]\nPosiadasz aktualnie: [ %d ] punktów\nTwoja ranga to: [ %s ]\nTwoja odznaka to: [ %s ]", client, g_iPoints[client], g_sRanksNames[g_iRank[client]], nazwa_coina[iCoin[client]]);
1116 else
1117 menuglowne.SetTitle("Witaj, %N\nPosiadasz aktualnie: [ %d ] punktów\nTwoja ranga to: [ %s ]\nTwoja odznaka to: [ %s ]\nAwans na rangę [ %s ] jak zdobędziesz [ %d ] punktów", client, g_iPoints[client], g_sRanksNames[g_iRank[client]], nazwa_coina[iCoin[client]], g_sRanksNames[g_iRank[client]+1], g_iRankTable[g_iRank[client]+1]);
1118 menuglowne.AddItem("1", "", ITEMDRAW_SPACER);
1119 menuglowne.AddItem("option1", "» Menu Gracza");
1120 menuglowne.AddItem("option2", "» Pokaż top graczy na serwerze!");
1121
1122 if (GetAdminFlag(GetUserAdmin(client), Admin_Root)) //Jeżeli masz flagę "Z" to ta opcja w menu ci się wyświetli
1123 menuglowne.AddItem("option5", "» Panel Administratora");
1124
1125 menuglowne.ExitButton = true;
1126 menuglowne.Display(client, 0);
1127}
1128
1129public Action CMD_ShowOVPrefsMenu(int client, int args)
1130{
1131 ShowOVMenu(client);
1132 return Plugin_Handled;
1133}
1134
1135public Action ShowOVMenu(int client)
1136{
1137 Menu menu = new Menu(MenuHandlerOV);
1138 menu.SetTitle("Katujemy.eu Ranks Overlays Edition");
1139 menu.AddItem("g_bClientPrefOverlays[client] == 1", "Włącz/Wyłącz overlaye");
1140 menu.ExitButton = true;
1141 menu.Display(client, MENU_TIME_FOREVER);
1142}
1143
1144public Action CMD_PanelRangi(int client, int args)
1145{
1146 Menu menu = new Menu(Rangi_MenuHandler);
1147 menu.SetTitle("[Rangi] Panel Administratora");
1148
1149 menu.AddItem("addpts", "Dodaj Punkty");
1150 menu.AddItem("rempts", "Zabierz Punkty");
1151 menu.AddItem("setrank", "Ustaw Range");
1152 menu.AddItem("removeall", "Zresetuj wszystkim graczom rangi/punkty");
1153 menu.AddItem("showpoints", "Pokaz Punkty Graczy Online");
1154
1155 menu.ExitButton = true;
1156 menu.Display(client, 60);
1157
1158 return Plugin_Handled;
1159}
1160
1161public Action CreateMenu_Glowne(int client)
1162{
1163 Menu menu = new Menu(Menu_Glowne);
1164 menu.SetTitle("Rangi -> Menu Gracza");
1165 menu.AddItem("option1", "» System Punktow");
1166 menu.AddItem("option2", "» Ile PKT trzeba na range?");
1167 menu.AddItem("option3", "» Zresetuj swoje punkty!");
1168 menu.AddItem("option4", "» Włącz/Wyłącz HUD na środku ekranu");
1169 menu.AddItem("option5", "» Wybierz odznake");
1170 menu.AddItem("option6", "» Włącz/Wyłącz overlay'e");
1171 menu.ExitButton = true;
1172 menu.Display(client, 0);
1173}
1174
1175public Action CreateMenu_Potwierdzenie(int client)
1176{
1177 Menu menu = new Menu(Menu_Potwierdzenie);
1178 menu.SetTitle("Rangi -> Czy jesteś pewien że chcesz zresetować swoje statystyki?");
1179 menu.AddItem("option1", "» Tak");
1180 menu.AddItem("option2", "» Nie");
1181 menu.ExitButton = true;
1182 menu.Display(client, 0);
1183}
1184
1185public Action CreateMenu_PokazPunkty(int client)
1186{
1187 Menu punkty = new Menu(Menu_Punkty);
1188 punkty.SetTitle("[Rangi -> Menu Punktów] Wybierz jedną z opcji");
1189 punkty.AddItem("option1", "» Zwykły gracz");
1190 punkty.AddItem("option2", "» Gracz VIP");
1191 punkty.AddItem("option3", "Powrót do menu");
1192 punkty.ExitButton = false;
1193 punkty.Display(client, 0);
1194}
1195
1196public Action CreateMenu_PokazMenuRang(int client)
1197{
1198 char sItem[64];
1199 Menu menurang = new Menu(Menu_MenuRang);
1200 menurang.SetTitle("[Rangi -> PKT na danÄ… range]\n");
1201 LoopRanks(i)
1202 {
1203 Format(sItem, sizeof(sItem), "%s - %d punktów\n", g_sRanksNames[i], g_iRankTable[i - 1]);
1204 menurang.AddItem("", sItem);
1205 }
1206 menurang.AddItem("option2", "Wroc do menu");
1207 menurang.ExitButton = false;
1208 menurang.Display(client, 0);
1209}
1210
1211public Action CreateMenu_Punkty(int client)
1212{
1213 Menu punktygracz = new Menu(Menu_PunktyInfo);
1214 punktygracz.SetTitle("[Rangi -> System Punktów Gracz]\n\nZwykłe zabójstwo - %i punkt\nZabójstwo w głowę - %i punkty\nPodłożenie bomby - %i punkty\nRozbrojenie bomby - %i punkty\nWygranie rundy - %i punkty", GetConVarInt(g_Cvar_PunktyKill), GetConVarInt(g_Cvar_PunktyHs), GetConVarInt(g_Cvar_PunktyBombPlanted), GetConVarInt(g_Cvar_PunktyBombDefused), GetConVarInt(g_Cvar_PunktyWygranaRunda));
1215 punktygracz.AddItem("option1", "Wroc");
1216 punktygracz.ExitButton = false;
1217 punktygracz.Display(client, 0);
1218}
1219
1220public Action CreateMenu_PunktyVip(int client)
1221{
1222 Menu punktyvip = new Menu(Menu_PunktyInfo);
1223 punktyvip.SetTitle("[Rangi -> System Punktów Vip]\nZwykłe zabójstwo - %i punkty\nZabójstwo w głowę - %i punktów\nPodłożenie bomby - %i punktów\nRozbrojenie bomby - %i punktów\nWygranie rundy - %i punkty", GetConVarInt(g_Cvar_PunktyKillVip), GetConVarInt(g_Cvar_PunktyHsVip), GetConVarInt(g_Cvar_PunktyBombPlantedVip), GetConVarInt(g_Cvar_PunktyBombDefusedVip), GetConVarInt(g_Cvar_PunktyWygranaRundaVip));
1224 punktyvip.AddItem("option1", "Wroc");
1225 punktyvip.ExitButton = false;
1226 punktyvip.Display(client, 0);
1227}
1228
1229public Action CreateMenu_AdminSelect(int client, int iSelect)
1230{
1231 Menu next = new Menu(SelectPlayer_MenuHandler);
1232 next.SetTitle("Rangi -> Wybor Gracza");
1233
1234 LoopClients(i)
1235 {
1236 char format[64];
1237 Format(format, sizeof format, "%d", i);
1238 char name[MAX_NAME_LENGTH + 1];
1239 GetClientName(i, name, sizeof name);
1240 next.AddItem(format, name);
1241 }
1242
1243 char sInfo[12];
1244 Format(sInfo, sizeof(sInfo), "%d", iSelect);
1245 next.AddItem("-SELECT-", sInfo, ITEMDRAW_IGNORE);
1246 next.ExitButton = true;
1247 next.Display(client, 60);
1248}
1249
1250public Action CreateMenu_AddRemovePoints(int admin, int client, int iSelect)
1251{
1252 Menu next = new Menu(PointAct_MenuHandler);
1253 char frm[128];
1254 char pname[MAX_NAME_LENGTH + 1];
1255 GetClientName(client, pname, sizeof pname);
1256 Format(frm, sizeof frm, "Rangi - %s", pname);
1257 next.SetTitle(frm);
1258
1259 next.AddItem("1", "1 Punkt");
1260 next.AddItem("5", "5 Punktow");
1261 next.AddItem("10", "10 Punktow");
1262 next.AddItem("20", "20 Punktow");
1263 next.AddItem("50", "50 Punktow");
1264 next.AddItem("100", "100 Punktow");
1265 next.AddItem("200", "200 Punktow");
1266 next.AddItem("500", "500 Punktow");
1267 next.AddItem("1000", "1000 Punktow");
1268 next.AddItem("2500", "2500 Punktow");
1269 next.AddItem("5000", "5000 Punktow");
1270
1271 char sInfo[12];
1272 Format(sInfo, sizeof(sInfo), "%d", iSelect);
1273 next.AddItem("-SELECT-", sInfo, ITEMDRAW_IGNORE);
1274 Format(sInfo, sizeof(sInfo), "%d", client);
1275 next.AddItem("-CLIENT-", sInfo, ITEMDRAW_IGNORE);
1276
1277 next.ExitButton = true;
1278 next.Display(admin, 60);
1279}
1280
1281public int MenuHandlerOV(Handle menu, MenuAction action, int param1, int param2)
1282{
1283 if(action == MenuAction_Select)
1284 {
1285 if(param2 == 0)
1286 {
1287 if(g_bClientPrefOverlays[param1] == 0)
1288 {
1289 g_bClientPrefOverlays[param1] = 1;
1290 CPrintToChat(param1, "★ {lightred}[Katujemy.eu -> OV] {yellow}Overlay'e zostały {green}włączone!");
1291 }
1292 else
1293 {
1294 g_bClientPrefOverlays[param1] = 0;
1295 CPrintToChat(param1, "★ {lightred}[Katujemy.eu -> OV] {yellow}Overlay'e zostały {darkred}wyłączone!");
1296 }
1297 }
1298 char buffer[5];
1299 SetClientCookie(param1, g_hClientOverlaysCookies, buffer);
1300 IntToString(g_bClientPrefOverlays[param1], buffer, 5);
1301 CMD_ShowOVPrefsMenu(param1, 0);
1302 }
1303 else if(action == MenuAction_End)
1304 {
1305 CloseHandle(menu);
1306 }
1307}
1308
1309public int OVPrefSelected(int client, CookieMenuAction action, any info, char[] buffer, int maxlen)
1310{
1311 if(action == CookieMenuAction_SelectOption)
1312 {
1313 ShowOVMenu(client);
1314 }
1315}
1316
1317public int Menu_menuglowne(Handle menuglowne, MenuAction action, int client, int itemNum)
1318{
1319 if (action == MenuAction_Select)
1320 {
1321 char info[32];
1322 GetMenuItem(menuglowne, itemNum, info, sizeof(info));
1323
1324 if (StrEqual(info, "option1"))
1325 CreateMenu_Glowne(client);
1326 else if (StrEqual(info, "option2"))
1327 PokazTopke(client, 0);
1328 else if (StrEqual(info, "option5"))
1329 CMD_PanelRangi(client, 0);
1330 }
1331 else if (action == MenuAction_End)
1332 CloseHandle(menuglowne);
1333}
1334
1335public int Menu_Glowne(Handle menu, MenuAction action, int client, int itemNum)
1336{
1337 if (action == MenuAction_Select)
1338 {
1339 char info[32];
1340 GetMenuItem(menu, itemNum, info, sizeof(info));
1341
1342 if (StrEqual(info, "option1"))
1343 CreateMenu_PokazPunkty(client);
1344 else if (StrEqual(info, "option2"))
1345 CreateMenu_PokazMenuRang(client);
1346 else if (StrEqual(info, "option3"))
1347 CreateMenu_Potwierdzenie(client);
1348 else if (StrEqual(info, "option4"))
1349 ClientCommand(client, "sm_hud");
1350 else if (StrEqual(info, "option5"))
1351 ClientCommand(client, "sm_coin");
1352 else if (StrEqual(info, "option6"))
1353 ShowOVMenu(client);
1354 }
1355 else if (action == MenuAction_End)
1356 CloseHandle(menu);
1357}
1358
1359public int Menu_Potwierdzenie(Handle menu, MenuAction action, int client, int itemNum)
1360{
1361 if (action == MenuAction_Select)
1362 {
1363 char info[32];
1364 GetMenuItem(menu, itemNum, info, sizeof(info));
1365
1366 if (StrEqual(info, "option1"))
1367 {
1368 g_iPoints[client] = 0;
1369 CheckRank(client);
1370 CPrintToChat(client, "★ {lightred}[Rangi -> Reset] {yellow}Twoje punkty zostały {green}Pomyślnie {yellow}wyzerowane!");
1371 }
1372 else if (StrEqual(info, "option2"))
1373 CreateMenu_Glowne(client);
1374 }
1375 else if (action == MenuAction_End)
1376 CloseHandle(menu);
1377}
1378
1379public int Menu_Punkty(Handle punkty, MenuAction action, int client, int itemNum)
1380{
1381 if (action == MenuAction_Select)
1382 {
1383 char info[32];
1384 GetMenuItem(punkty, itemNum, info, sizeof(info));
1385
1386 if (StrEqual(info, "option1"))
1387 CreateMenu_Punkty(client);
1388 else if (StrEqual(info, "option2"))
1389 CreateMenu_PunktyVip(client);
1390 else if (StrEqual(info, "option3"))
1391 CreateMenu_Glowne(client);
1392 }
1393 else if (action == MenuAction_End)
1394 CloseHandle(punkty);
1395}
1396
1397public int Menu_PunktyInfo(Handle punktyvip, MenuAction action, int client, int itemNum)
1398{
1399 if (action == MenuAction_Select)
1400 {
1401 char info[32];
1402 GetMenuItem(punktyvip, itemNum, info, sizeof(info));
1403
1404 if (StrEqual(info, "option1"))
1405 CreateMenu_PokazPunkty(client);
1406 }
1407 else if (action == MenuAction_End)
1408 CloseHandle(punktyvip);
1409}
1410
1411public int Menu_MenuRang(Handle menurang, MenuAction action, int client, int itemNum)
1412{
1413 if (action == MenuAction_Select)
1414 {
1415 char info[32];
1416 GetMenuItem(menurang, itemNum, info, sizeof(info));
1417
1418 if (StrEqual(info, "option2"))
1419 CreateMenu_Glowne(client);
1420 }
1421 else if (action == MenuAction_End)
1422 CloseHandle(menurang);
1423}
1424
1425public int Rangi_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
1426{
1427 if (action == MenuAction_Select)
1428 {
1429 char item[32];
1430 bool found = menu.GetItem(param2, item, sizeof(item));
1431 if (found)
1432 {
1433 if (StrEqual(item, "addpts"))
1434 {
1435 CreateMenu_AdminSelect(param1, 1);
1436 }
1437 else if (StrEqual(item, "rempts"))
1438 {
1439 CreateMenu_AdminSelect(param1, 2);
1440 }
1441 else if (StrEqual(item, "setrank"))
1442 {
1443 CreateMenu_AdminSelect(param1, 3);
1444 }
1445 else if (StrEqual(item, "removeall"))
1446 {
1447 Potwierdz_Reset(param1, 4);
1448 }
1449 else if (StrEqual(item, "showpoints"))
1450 {
1451 Menu next = new Menu(Empty_MenuHandler);
1452 next.SetTitle("Rangi -> Punkty");
1453
1454 LoopClients(i)
1455 {
1456 char format[128];
1457 char cid[16];
1458 IntToString(i, cid, sizeof cid);
1459 char name[MAX_NAME_LENGTH + 1];
1460 GetClientName(i, name, sizeof name);
1461 Format(format, sizeof format, "%s - %d punktow", name, g_iPoints[i]);
1462 next.AddItem(cid, format);
1463 }
1464
1465 next.ExitButton = true;
1466 next.Display(param1, 60);
1467 }
1468 }
1469 }
1470 else if (action == MenuAction_End)
1471 delete menu;
1472}
1473
1474public int PointAct_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
1475{
1476 char sInfo[12], sDane[12];
1477 int iSelect, client;
1478 LoopItemCount(i)
1479 {
1480 menu.GetItem(i, sInfo, sizeof(sInfo), _, sDane, sizeof(sDane));
1481 if(StrEqual(sInfo, "-SELECT-"))
1482 iSelect = StringToInt(sDane);
1483
1484 if(StrEqual(sInfo, "-CLIENT-"))
1485 client = StringToInt(sDane);
1486 }
1487 if (action == MenuAction_Select)
1488 {
1489 char item[32];
1490 menu.GetItem(param2, item, sizeof(item));
1491 if (IsValidClient(client))
1492 {
1493 if (iSelect == 1)
1494 g_iPoints[client] += StringToInt(item);
1495 else if (iSelect == 2)
1496 g_iPoints[client] -= StringToInt(item);
1497
1498 CreateMenu_AddRemovePoints(param1, client, iSelect);
1499 CheckRank(client);
1500 }
1501 }
1502 else if (action == MenuAction_End)
1503 delete menu;
1504}
1505
1506public int SelectPlayer_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
1507{
1508 char sInfo[12], sDane[12];
1509 int iSelect;
1510 LoopItemCount(i)
1511 {
1512 menu.GetItem(i, sInfo, sizeof(sInfo), _, sDane, sizeof(sDane));
1513 if(StrEqual(sInfo, "-SELECT-"))
1514 iSelect = StringToInt(sDane);
1515 }
1516 if (action == MenuAction_Select)
1517 {
1518 char item[32];
1519 bool found = menu.GetItem(param2, item, sizeof(item));
1520 if (found)
1521 {
1522 int client = StringToInt(item);
1523 if (IsValidClient(client))
1524 {
1525 if (iSelect != 3)
1526 CreateMenu_AddRemovePoints(param1, client, iSelect);
1527 else
1528 {
1529 Menu next = new Menu(SetRank_MenuHandler);
1530 char frm[128];
1531 char pname[MAX_NAME_LENGTH + 1];
1532 GetClientName(client, pname, sizeof pname);
1533 Format(frm, sizeof frm, "Rangi - %s", pname);
1534 next.SetTitle(frm);
1535
1536 char sNum[12];
1537 LoopRanks(i)
1538 {
1539 Format(sNum, sizeof(sNum), "%d", i);
1540 next.AddItem(sNum, g_sRanksNames[i]);
1541 }
1542 Format(sNum, sizeof(sNum), "%d", client);
1543 next.AddItem("-CLIENT-", sNum, ITEMDRAW_IGNORE);
1544 next.ExitButton = true;
1545 next.Display(param1, 60);
1546 }
1547 }
1548 }
1549 }
1550 else if (action == MenuAction_End)
1551 delete menu;
1552}
1553
1554public int Empty_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
1555{
1556 if (action == MenuAction_End) delete menu;
1557}
1558
1559public int SetRank_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
1560{
1561 char sInfo[32], sDane[32];
1562 int client;
1563 LoopItemCount(i)
1564 {
1565 menu.GetItem(i, sInfo, sizeof(sInfo), _, sDane, sizeof(sDane));
1566 if(StrEqual(sInfo, "-CLIENT-"))
1567 client = StringToInt(sDane);
1568 }
1569 if (action == MenuAction_Select)
1570 {
1571 char item[32];
1572 menu.GetItem(param2, item, sizeof(item));
1573 if (IsValidClient(client))
1574 {
1575 int iNewRank = StringToInt(item);
1576 CPrintToChat(client, "★ {lightred}[ADMIN]{yellow} Admin zmienił twoją rangę na {lightred}%s", g_sRanksNames[iNewRank]);
1577 CPrintToChat(param1, "★ {lightred}[ADMIN]{yellow} Zmieniłeś rangę graczowi {green}%N {yellow}na {lightred}%s", client, g_sRanksNames[iNewRank]);
1578 g_iPoints[client] = g_iRankTable[iNewRank - 1];
1579 CheckRank(client);
1580 }
1581 }
1582 else if (action == MenuAction_End)
1583 delete menu;
1584}
1585
1586public Action Hook_OnThinkPost(int iEnt)
1587{
1588 static int iCoinOffset = -1;
1589 if(iCoinOffset == -1)
1590 iCoinOffset = FindSendPropInfo("CCSPlayerResource", "m_nActiveCoinRank");
1591
1592 int tempCoin[65];
1593 GetEntDataArray(iEnt, iCoinOffset, tempCoin, 65);
1594 for(int i = 1; i <= MaxClients; i++)
1595 {
1596 if(!IsValidClient(i)) continue;
1597 if(iCoin_Enable[i])
1598 tempCoin[i] = id_coina[iCoin[i]];
1599 }
1600
1601 SetEntDataArray(iEnt, FindSendPropInfo("CCSPlayerResource", "m_iCompetitiveRanking"), g_iRank, MAXPLAYERS+1);
1602 SetEntDataArray(iEnt, iCoinOffset, tempCoin, 65, 4, true);
1603 Handle hBuffer = StartMessageAll("ServerRankRevealAll");
1604 if (hBuffer == null)
1605 PrintToServer("ServerRankRevealAll = INVALID_HANDLE");
1606 else
1607 EndMessage();
1608}
1609
1610public Action CMD_HUD(int client, int args)
1611{
1612 if(!IsValidClient(client))
1613 return Plugin_Handled;
1614
1615 g_bHUD[client] = !g_bHUD[client];
1616 PrintToChat(client, "HUD \x04%s\x01.", g_bHUD[client] ? "Wlaczony" : "Wylaczony");
1617
1618 return Plugin_Handled;
1619}
1620
1621public Action Timer_UpdateHUD(Handle Timer)
1622{
1623 LoopClients(i)
1624 {
1625 if(!g_bHUD[i])
1626 continue;
1627 UpdateHUD(i);
1628 }
1629 return Plugin_Continue;
1630}
1631
1632public void UpdateHUD(int client)
1633{
1634 char sHintText[512];
1635
1636 if (IsPlayerAlive(client))
1637 {
1638 Format(sHintText, 512, "<font face='Stratum2'>");
1639 Format(sHintText, 512, "%s<font color='#FF0000'>Katujemy.eu</font>\n", sHintText);
1640 Format(sHintText, 512, "%s<font color='#FFFFFF'>Ranga:</font> <font color='#C9AE28'>[ %s ]</font>\n", sHintText, g_sRanksNames[g_iRank[client]]);
1641 Format(sHintText, 512, "%s<font color='#FFFFFF'>Odznaka:</font> <font color='#C9AE28'>[ %s ]</font>\n", sHintText, nazwa_coina[iCoin[client]]);
1642 }
1643 else
1644 {
1645 int spect = GetEntProp(client, Prop_Send, "m_iObserverMode");
1646 if (spect == 4 || spect == 5)
1647 {
1648 int target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
1649 if (target != -1 && IsValidClient(target))
1650 {
1651 Format(sHintText, 512, "<font size='16'> | <font color='#C9AE28'>Statystyki gracza</font> \n| Ranga: [ %s ] |\n | Punkty: [ %d ] |", g_sRanksNames[g_iRank[target]], g_iPoints[target]);
1652 }
1653 }
1654 }
1655 PrintHintText(client, sHintText);
1656}
1657
1658/* << Check for ranks>> */
1659void CheckRank(int client)
1660{
1661 bool bRankUp = false;
1662 bool bRankDown = false;
1663
1664 if(!IsClientConnected(client))
1665 return;
1666
1667 while(g_iPoints[client] >= g_iRankTable[g_iRank[client]] && g_iRank[client] < sizeof(g_iRankTable)-1) // Jedziemy z pętelką aby po dodaniu pkt mogło awansować np. 3 razy
1668 {
1669 g_iRank[client]++;
1670 bRankUp = true;
1671 }
1672
1673 if(g_iRank[client] > 0)
1674 {
1675 while(g_iPoints[client] < g_iRankTable[g_iRank[client]-1]) // to samo, z tym, że szukamy spadku
1676 {
1677 g_iRank[client]--;
1678 bRankDown = true;
1679 }
1680 }
1681
1682 if(bRankUp)
1683 {
1684 CPrintToChat(client, "★ {lightred}[Rangi -> Awans]{yellow} Gratulacje! właśnie awansowałeś na range: {green}%s", g_sRanksNames[g_iRank[client]]);
1685 EmitSoundToClient(client, "*/katujemy/rangi/awans.mp3");
1686 CPrintToChatAll("★ {lightred}[Rangi -> Awans]{yellow} Gracz {lightred}%N{yellow} właśnie awansował na rangę {green}%s!", client, g_sRanksNames[g_iRank[client]]);
1687
1688 if(g_bClientPrefOverlays[client])
1689 {
1690 char sBuffer[32];
1691 Format(sBuffer, sizeof(sBuffer), "katujemy_overlays/rank_%d", g_iRank[client]);
1692 ClientCommand(client, "r_screenoverlay \"%s\"", sBuffer);
1693 CreateTimer(2.5, Timer_DeleteOverlay, client);
1694 }
1695 }
1696
1697 if(bRankDown)
1698 {
1699 CPrintToChat(client, "★ {lightred}[Rangi -> Spadek]{yellow} UPS! Właśnie spadłeś do rangi: {green}%s", g_sRanksNames[g_iRank[client]]);
1700 EmitSoundToClient(client, "*/katujemy/rangi/awans.mp3");
1701 CPrintToChatAll("★ {lightred}[Rangi -> Awans]{yellow} Gracz {lightred}%N{yellow} właśnie spadł do rangi {green}%s!", client, g_sRanksNames[g_iRank[client]]);
1702
1703 if(g_bClientPrefOverlays[client])
1704 {
1705 char sBuffer[32];
1706 Format(sBuffer, sizeof(sBuffer), "katujemy_overlays/rank_%d", g_iRank[client]);
1707 ClientCommand(client, "r_screenoverlay \"%s\"", sBuffer);
1708 CreateTimer(2.5, Timer_DeleteOverlay, client);
1709 }
1710 }
1711}
1712
1713public Action Timer_DeleteOverlay(Handle timer, any client)
1714{
1715 if(IsValidClient(client))
1716 ClientCommand(client, "r_screenoverlay \"%s\"", "");
1717}
1718
1719/* << Stocks / Bolls >> */
1720stock int GetCurrentPlayers() {
1721 int count;
1722 LoopClients(i) {
1723 if (!IsFakeClient(i)) {
1724 count++;
1725 }
1726 }
1727 return count;
1728}
1729
1730public int Native_GetPointsAmount(Handle handler, int numParams)
1731{
1732 return g_iPoints[GetNativeCell(1)];
1733}
1734
1735public int Native_GetRank(Handle handler, int numParams)
1736{
1737 return g_iRank[GetNativeCell(1)];
1738}
1739
1740public int Native_GetCoin(Handle handler, int numParams)
1741{
1742 return iCoin[GetNativeCell(1)];
1743}
1744
1745stock void GivePoints(int client, int value)
1746{
1747 g_iPoints[client] += value;
1748 CheckRank(client);
1749}
1750
1751stock bool IsPlayerVIP(int client) //Jeżeli gracz jest VIPem
1752{
1753 if(!CheckCommandAccess(client, "sm_Vip", 0, true))
1754 return false;
1755 return true;
1756}
1757
1758stock bool IsValidClient(int client)
1759{
1760 if(!(1 <= client <= MaxClients) || !IsClientInGame(client) || IsFakeClient(client))
1761 return false;
1762 return true;
1763}
1764
1765stock bool JestRozgrzewka()
1766{
1767 return GameRules_GetProp("m_bWarmupPeriod") != 0;
1768}