· 6 years ago · Sep 15, 2019, 12:00 AM
1/* Copyright (C) 2019 Mesharsky
2 This program is free software: you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation, either version 3 of the License, or
5 (at your option) any later version.
6 This program is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 GNU General Public License for more details.
10
11 You should have received a copy of the GNU General Public License
12 along with this program. If not, see <http://www.gnu.org/licenses/>.
13*/
14
15/*================ Aktualizacje ================
16
17~ Wersja "0.1" » Pierwsze wydanie pluginu.
18~ Wersja "0.2" » Przepisanie pluginy na nowy syntax.
19~ Wersja "0.3" » Dodano wiadomości na czacie przy danych eventach.
20~ Wersja "0.4" » Poprawa wszelkich bugów oraz błędów.
21~ Wersja "0.5" » Dodano translacje oraz poprawiono wygląd kodu.
22~ Wersja "0.6" » Dodano Panel Administracyjny, poprawiono wiele błędów, usunięto pare zbędnych menu oraz usunięto translacje.
23~ Wersja "0.7" » Zmieniono 3/4 kodu, poprawiono wygląd kodu oraz naprawiono wiele błędów i bugów.
24~ Wersja "0.8" » Usunięto informacje na czacie pod !ranga, teraz !ranga wyświetla menu z wszystkimi potrzebnymi informacjami dla użytkownika.
25~ Wersja "0.9" » Plugin został przepisany na zapis MYSQL.
26~ Wersja "1.0" » Wszystko.
27~ 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. //Special credits for xBonio for his coins code.
28~ Wersja "1.2" » Dodanie topki w menu, dodanie kilku cvarów, poprawiono kod, oraz mała optymalizacja.
29~ Wersja "1.3" » Dodanie punktów za zabójstwo z noża.
30~ Wersja "1.4" » Naprawiono nativy, dodano nowe cvary, zoptymalizowano kod.
31~ Wersja "1.5" » Dodano overlaye + dodatkowo została dodana opcja, by włączyć/wyłączyć overlay'e.
32~ Wersja "1.6" » Dodano prefixy na czat dla danej rangi serwerowej i rangi gracza.
33~ Wersja "1.7" » Dodano opcje wyłączenia overlay dla danego gracza (Zapis ciasteczka).
34~ Wersja "1.8" » Dodano możliwość dodawania punktów graczowi komendą.
35~ Wersja "1.9" » Poprawki MySQL, optymalizacja kodu, więcej opcji, przebudowa funkcji.
36~ Wersja "2.0" » Optymalizacja kodu, naprawa kilku błędów.
37~ Wersja "2.1" » Dodano dźwięk oraz poprawiono funkcję spadku rangi, poprawiono funkcję wyświetlania rang w tabeli.
38~ Wersja "2.2" » Dodano możliwość tracenia punktów oraz funkcja ArenaMode, co pozwala przystosować plugin pod arenki.
39~ Wersja "2.3" » Dodano HUD_Mode, czyli dwie pozycję HUD, zapis MYSQL, oraz menu gdzie możesz sobię wyłączyć/włączyć HUD.
40~ Wersja "2.4" » Dodano konfigurację punktacji przez KeyValues.
41~ Wersja "2.5" » Dodano możliwość odblokowania odznak poprzez wymaganą rangę, flagę vip'a teraz można ustawić poprzez CVAR.
42~ Wersja "2.6" » Some code upgrade.
43~ Wersja "2.7" » [NOWOŚĆ] Dodano zabawę matematyczne quizy czasowe!, do wygrania punkty.
44~ Wersja "2.8" » [NOWOŚĆ] Dodano zabawę HAZARD!, każdy gracz może losować sobie szansę na wygranie punktów!.
45~ Wersja "2.9" » Wyjebanie matmy bo jest chujowa.
46~ Wersja "3.0" » Dodanie typ wyświetlania rang w tabeli.
47~ Wersja "3.1" » Hud text przerobiony, dodanie więcej opcji, optyma lizacja itd.
48~ Wersja "3.2" » Przepisanie kodu MySQL pod nowe standardy, przepisanie całego kodu pod topkę, poprawienie estetyki kodu, poprawnienie funkcji w on_player_death, optymalzacja kodu, naprawienie zapisywania kodu podczas końca rundy, usunięto cvar czy plugin jest włączony bądź nie włączony, poprawiono cvar dla modułu Hazard, poprawiono w SQL zapisywanie, poprawiono kodowanie znaków przy tworzeniu tabel, poprawiono w chuj więcej.
49~ Wersja "3.3" » Szybka integracja ze store by zephyrus.
50~ Wersja "3.4" » Dodano WEB PANEL ADMIN, nowa tabela w bazie.
51~ Wersja "3.5" » Dodano integrację ze sklepem by Donaciak.
52~ Wersja "3.6" » Poprawiono integrację ze sklepem by donaciak i zephyrus jako osobne pluginy, dodatkowo dodano 2 nativy.
53
54============================================== */
55
56/* << compiller definitions >> */
57#pragma semicolon 1
58#pragma newdecls required
59
60/* << includes >> */
61#include <sourcemod>
62#include <sdktools>
63#include <sdkhooks>
64#include <cstrike>
65#include <clientprefs>
66#include <multicolors>
67#include <ranks>
68
69/* << Macro >> */
70#define LoopItemCount(%1) for(int %1 = 0; %1 < menu.ItemCount; %1++)
71#define LoopRanks(%1) for(int %1 = 1; %1 < sizeof g_iPointsTable; %1++)
72#define LoopClients(%1) for(int %1 = 1; %1 <= MaxClients; %1++)\
73if(IsClientInGame(%1))
74
75/* << Defines >> */
76#define NAZWA_PLUGINU "[CSGO] Rank system + coins"
77#define OPIS_PLUGINU "[CSGO] Same as the name."
78#define AUTOR_PLUGINU "Mesharsky"
79#define WERSJA_PLUGINU "3.6 - Stable at the moment"
80#define URL_PLUGINU "http://steamcommunity.com/id/mesharskyH2K"
81
82#define ILOSC_MONET 200
83
84/* << ConVars >> */
85ConVar g_Cvar_VipFlag,
86g_Cvar_ForumName,
87g_Cvar_PanelAdministracyjnyEnabled,
88g_Cvar_PunktyWarmupEnabled,
89g_Cvar_MinimalnaIloscGraczy,
90g_Cvar_PunktyKill,
91g_Cvar_PunktyKillVip,
92g_Cvar_PunktyHs,
93g_Cvar_PunktyHsVip,
94g_Cvar_PunktyBombEnabled,
95g_Cvar_PunktyBombPlanted,
96g_Cvar_PunktyBombPlantedVip,
97g_Cvar_PunktyBombDefused,
98g_Cvar_PunktyBombDefusedVip,
99g_Cvar_PunktyWygranaRunda,
100g_Cvar_PunktyWygranaRundaVip,
101g_Cvar_PunktyMvpEnabled,
102g_Cvar_PunktyMvpPlayer,
103g_Cvar_PunktyMvpPlayerVip,
104g_Cvar_PunktyKnifeEnabled,
105g_Cvar_PunktyKnifeKill,
106g_Cvar_PunktyKnifeKillVip,
107g_Cvar_HudEnabled,
108g_Cvar_TraceniePKTEnabled,
109g_Cvar_PunktyPrzegranaRunda,
110g_Cvar_PunktyPrzegranaRundaVip,
111g_Cvar_PunktyDeath,
112g_Cvar_PunktyDeathVip,
113g_Cvar_WygranaRundaEnabled,
114g_Cvar_PrzegranaRundaEnabled,
115
116/* ================== COIN MODULE ================== */
117g_Cvar_CoinEnable,
118g_Cvar_CoinRequiredRanks,
119
120/* ================== ZABAWA HAZARD ================== */
121
122g_Cvar_ModulHazard,
123g_Cvar_PokazZmianyHazard,
124g_Cvar_MinimalnyBet,
125g_Cvar_MaksymalnyBet,
126g_Cvar_SzansaNaWin;
127
128
129bool g_bHUD[MAXPLAYERS + 1];
130
131Database DB;
132
133/* << Handles >> */
134Handle g_hClientCookieOverlays = INVALID_HANDLE;
135
136/* << KeyValues >> */
137KeyValues g_hRanks;
138
139/* << Chars >> */
140char PlayerName[MAXPLAYERS + 1][MAX_NAME_LENGTH];
141
142/* << Integers >> */
143int g_iPoints[MAXPLAYERS + 1];
144int g_iRank[MAXPLAYERS + 1];
145int iCoin[65];
146int iCoin_Enable[65];
147int Hud_Mode[65];
148
149int g_bClientPrefOverlays[MAXPLAYERS + 1];
150int g_iType;
151
152int g_iPointsTable[] =
153{
154 10,
155 25,
156 50,
157 100,
158 250,
159 500,
160 750,
161 1000,
162 1250,
163 1500,
164 2000,
165 2500,
166 5000,
167 7500,
168 10000,
169 12500,
170 15000,
171 24000,
172 27000
173};
174
175char g_iRankTable[][128] =
176{
177 "Unranked",
178 "Silver 1",
179 "Silver 2",
180 "Silver 3",
181 "Silver 4",
182 "Silver Elite",
183 "Silver Elite Master",
184 "Gold Nova 1",
185 "Gold Nova 2",
186 "Gold Nova 3",
187 "Gold Nova Master",
188 "Master Guardian 1",
189 "Master Guardian 2",
190 "Master Guardian Elite",
191 "DMG",
192 "Legendary Eagle",
193 "Legendary Eagle Master",
194 "Supreme",
195 "The Global Elite"
196};
197
198/* << Includy Pluginu >> */
199#include "h2k_rangi/h2k_keyvalues.sp"
200#include "h2k_rangi/h2k_coins.sp"
201#include "h2k_rangi/h2k_hazard.sp"
202
203/* << Informacje o pluginie >> */
204public Plugin myinfo =
205{
206 name = NAZWA_PLUGINU,
207 author = AUTOR_PLUGINU,
208 description = OPIS_PLUGINU,
209 version = WERSJA_PLUGINU,
210 url = URL_PLUGINU
211}
212
213public void OnPluginStart()
214{
215 CreateTimer(0.1, Timer_UpdateHUD, INVALID_HANDLE, TIMER_REPEAT);
216
217 // <<- Eventy ->>
218 HookEvent("round_start", Event_RoundStart);
219 HookEvent("round_end", Event_RoundEnd);
220 HookEvent("round_mvp", Event_RoundMvp);
221 HookEvent("player_death", Event_PlayerDeath);
222 HookEvent("bomb_planted", Event_BombPlanted);
223 HookEvent("bomb_defused", Event_BombDefused);
224
225 // <<- Komendy Gracza ->>
226 RegConsoleCmd("sm_hud", CMD_HUD);
227 RegConsoleCmd("sm_hudm", CMD_HUDMode);
228 RegConsoleCmd("sm_hudmode", CMD_HUDMode);
229 RegConsoleCmd("sm_ranga", CMD_MenuGlowne);
230 RegConsoleCmd("sm_lvl", CMD_MenuGlowne);
231 RegConsoleCmd("sm_coin", Command_CoinMenu);
232 RegConsoleCmd("sm_coins", Command_CoinMenu);
233
234 // <<- Zabawa Hazard - Moduł ->>
235 RegConsoleCmd("sm_hazard", Cmd_Hazard);
236 RegConsoleCmd("sm_gamble", Cmd_Hazard);
237
238 // <<- Komendy Admina ->>
239 RegAdminCmd("sm_panel", CMD_PanelRangi, ADMFLAG_ROOT);
240 RegAdminCmd("sm_dodajpkt", CMD_DodajPkt, ADMFLAG_ROOT);
241 RegAdminCmd("sm_ref", Cmd_GetRanksKv, ADMFLAG_BAN);
242
243 // <<- ConVary ->>
244 g_Cvar_ForumName = CreateConVar("rangi_forum", "Katujemy.eu", "Nazwa twojej sieci / forum");
245 g_Cvar_VipFlag = CreateConVar("vip_flag", "o", "Flaga dla gracza VIP, pozostaw puste by każdy miał Vipa.");
246 g_Cvar_PanelAdministracyjnyEnabled = CreateConVar("rangi_panel_enabled", "1", "Panel administracyjny ma być włączony czy wyłączony?", _, true, 0.0, true, 1.0);
247 g_Cvar_PunktyWarmupEnabled = CreateConVar("rangi_Warmup", "0", "Czy naliczać punkty podczas rozgrzewki?", _, true, 0.0, true, 1.0);
248 g_Cvar_PunktyBombEnabled = CreateConVar("rangi_bomb_enabled", "0", "Czy włączyć naliczanie punktów za podłożenie/rozbrojenie bomby?", _, true, 0.0, true, 1.0);
249 g_Cvar_PunktyMvpEnabled = CreateConVar("rangi_mvp_enabled", "0", "Czy włączyć naliczanie punktów za bycie graczem MVP?", _, true, 0.0, true, 1.0);
250 g_Cvar_PunktyKnifeEnabled = CreateConVar("rangi_knife_enabled", "1", "Czy włączyć naliczanie punktów za zabójstwo z noża?", _, true, 0.0, true, 1.0);
251 g_Cvar_HudEnabled = CreateConVar("rangi_hud_enabled", "1", "Hud ma być włączony czy wyłączony?", _, true, 0.0, true, 1.0);
252 g_Cvar_TraceniePKTEnabled = CreateConVar("rangi_tracenie_pkt", "1", "Czy włączyć możliwość tracenia punktów?", _, true, 0.0, true, 1.0);
253 g_Cvar_WygranaRundaEnabled = CreateConVar("rangi_win_round", "0", "Czy naliczać punkty za wygraną rundę?", _, true, 0.0, true, 1.0);
254 g_Cvar_PrzegranaRundaEnabled = CreateConVar("rangi_lost_round", "0", "Czy odejmować punkty za przegraną rundę?", _, true, 0.0, true, 1.0);
255 g_Cvar_MinimalnaIloscGraczy = CreateConVar("rangi_ilosc_graczy", "2", "Od ilu graczy włączyć naliczanie punktów.", _, true, 0.0, true, 10.0);
256 g_Cvar_PunktyKill = CreateConVar("rangi_kill", "1", "Ile dodawać punktów za zabójstwo", _, true, 1.0, true, 20.0);
257 g_Cvar_PunktyKillVip = CreateConVar("rangi_kill_vip", "2", "Ile dodawać punktów za zabójstwo (VIP)", _, true, 1.0, true, 20.0);
258 g_Cvar_PunktyDeath = CreateConVar("rangi_death", "2", "Ile tracisz punktów za to że ktoś cię zabije", _, true, 1.0, true, 20.0);
259 g_Cvar_PunktyDeathVip = CreateConVar("rangi_death_vip", "1", "Ile tracisz punktów za to że ktoś cię zabije (VIP)", _, true, 1.0, true, 20.0);
260 g_Cvar_PunktyHs = CreateConVar("rangi_kill_hs", "3", "Ile dodawać punktów za headshot'a?", _, true, 1.0, true, 20.0);
261 g_Cvar_PunktyHsVip = CreateConVar("rangi_kill_hs_vip", "5", "Ile dodawać punktów za headshot'a (VIP)", _, true, 1.0, true, 20.0);
262 g_Cvar_PunktyBombPlanted = CreateConVar("rangi_bomb_planted", "2", "Ile dodawać punktów za podłożenie bomby", _, true, 1.0, true, 20.0);
263 g_Cvar_PunktyBombPlantedVip = CreateConVar("rangi_bomb_planted_vip", "5", "Ile dodawać pkt za podłożenie bomby (VIP)", _, true, 1.0, true, 20.0);
264 g_Cvar_PunktyBombDefused = CreateConVar("rangi_bomb_defused", "2", "Ile dodawać punktów za rozbrojenie bomby", _, true, 1.0, true, 20.0);
265 g_Cvar_PunktyBombDefusedVip = CreateConVar("rangi_bomb_defused_vip", "5", "Ile dodawać pkt za rozbrojenie bomby (VIP)", _, true, 1.0, true, 20.0);
266 g_Cvar_PunktyWygranaRunda = CreateConVar("wygrana_runda", "2", "Ile dodawać punktów za wygranie rundy", _, true, 1.0, true, 20.0);
267 g_Cvar_PunktyWygranaRundaVip = CreateConVar("wygrana_runda_vip", "4", "Ile dodawać punktów za wygranie rundy (VIP)", _, true, 1.0, true, 20.0);
268 g_Cvar_PunktyPrzegranaRunda = CreateConVar("przegrana_runda", "4", "Ile gracz traci punktów za przegranie rundy", _, true, 1.0, true, 20.0);
269 g_Cvar_PunktyPrzegranaRundaVip = CreateConVar("przegrana_runda_vip", "2", "Ile gracz traci punktów za przegranie rundy (VIP)", _, true, 1.0, true, 20.0);
270 g_Cvar_PunktyMvpPlayer = CreateConVar("mvp_player", "3", "Ile dostanie punktów gracz MVP?", _, true, 1.0, true, 20.0);
271 g_Cvar_PunktyMvpPlayerVip = CreateConVar("mvp_player_vip", "5", "Ile dostanie punktów gracz MVP (VIP)?", _, true, 1.0, true, 20.0);
272 g_Cvar_PunktyKnifeKill = CreateConVar("rangi_kill_knife", "4", "Ile dostanie punktów gracz za zabójstwo z noża?", _, true, 1.0, true, 20.0);
273 g_Cvar_PunktyKnifeKillVip = CreateConVar("rangi_kill_knife_vip", "7", "Ile dostanie punktów gracz za zabójstwo z noża (VIP)?", _, true, 1.0, true, 20.0);
274
275 /* ================== COIN MODULE ================== */
276
277 g_Cvar_CoinEnable = CreateConVar("coin_enable", "1", "[MODUŁ - ODZNAKI] 1 - System odznak włączony | 0 - System odznak wyłączony", _, true, 0.0, true, 1.0);
278 g_Cvar_CoinRequiredRanks = CreateConVar("coin_needrank", "1", "[MODUŁ - ODZNAKI] Czy coinsy mają działać na zasadzie im większa ranga tym więcej coinsów odblokowanych czy odblokowane wszystkie dla wszystkich graczy (1 - Wymagana ranga | 0 - Wszyscy mają dostęp)");
279
280 /* ================== ZABAWA HAZARD ================== */
281
282 g_Cvar_ModulHazard = CreateConVar("ranks_hazard_enable", "1", "[MODUŁ - HAZARD] Włączyć/Wyłączyć moduł hazardu?", _, true, 0.0, true, 1.0);
283 g_Cvar_PokazZmianyHazard = CreateConVar("ranks_hazard_showmess", "1", "[MODUŁ - HAZARD] Pokazywać ogólnie na czacie czy ktoś wygrał bądź przegrał?", _, true, 0.0, true, 1.0);
284 g_Cvar_MinimalnyBet = CreateConVar("ranks_hazard_minbet", "25", "[MODUŁ - HAZARD] Minimalna ilość punktów do wygrania");
285 g_Cvar_MaksymalnyBet = CreateConVar("ranks_hazard_maxbet", "1000", "[MODUŁ - HAZARD] Maksymalna ilość punktów do wygrania");
286 g_Cvar_SzansaNaWin = CreateConVar("ranks_hazard_szansa_na_wygranie", "40", "[MODUŁ - HAZARD] Ile gracz ma procent szansy na wygranie");
287
288 // <<- Konfiguracja ->>
289 AutoExecConfig(true, "RankSystem_Config_3.1");
290
291 // <<- Ciach ciach ->>
292 g_hClientCookieOverlays = RegClientCookie("H2K_Overlays", "set overlays on / off", CookieAccess_Private);
293 SetCookieMenuItem(OVPrefSelected, 0, "H2K_Overlays");
294
295 // <<- MySQL ->>
296 DB_Connect();
297
298 // ta.... i tak to usuniesz :)
299}
300
301public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
302{
303 CreateNative("H2K_GetClientPoints", Native_GetClientPoints);
304 CreateNative("H2K_SetClientPoints", Native_GivePoints);
305
306 RegPluginLibrary("ranks");
307
308 return APLRes_Success;
309}
310
311/* << Na starcie mapy >> */
312public void OnMapStart()
313{
314 GetRanksKv();
315 SDKHook(FindEntityByClassname(MAXPLAYERS + 1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
316
317 char sBuffer[64];
318 static const char sPath[] = "materials/panorama/images/icons/skillgroups/skillgroup%i.svg";
319 LoopRanks(i)
320 {
321 Format(sBuffer, sizeof(sBuffer), "materials/h2k_overlays/rank_%d.vmt", i);
322 AddFileToDownloadsTable(sBuffer);
323 Format(sBuffer, sizeof(sBuffer), "materials/h2k_overlays/rank_%d.vtf", i);
324 AddFileToDownloadsTable(sBuffer);
325 Format(sBuffer, sizeof(sBuffer), "h2k_overlays/rank_%d.vmt", i);
326 PrecacheDecal(sBuffer, true);
327 Format(sBuffer, sizeof(sBuffer), "h2k_overlays/rank_%d.vmt", i);
328 PrecacheDecal(sBuffer, true);
329 }
330
331 for (int i = 1; i < 19; i++)
332 {
333 FormatEx(sBuffer, sizeof(sBuffer), sPath, i + 50);
334 AddFileToDownloadsTable(sBuffer);
335 }
336
337 AddFileToDownloadsTable("sound/h2k/rangi/awans.mp3");
338 PrecacheSound("*/h2k/rangi/awans.mp3", true);
339}
340
341public void OnClientPutInServer(int client)
342{
343 DB_LoadInfo(client);
344 LoadClientCookiesFor(client);
345
346 if (g_Cvar_HudEnabled.BoolValue)
347 {
348 g_bHUD[client] = true;
349 }
350 else
351 {
352 g_bHUD[client] = false;
353 }
354}
355
356public void OnClientDisconnect(int client)
357{
358 DB_SaveInfo(client);
359}
360
361public Action DB_Connect()
362{
363 char gB_Error[512];
364 char query[512];
365
366 if (SQL_CheckConfig("h2k_rangi"))
367 {
368 DB = SQL_Connect("h2k_rangi", true, gB_Error, 255);
369
370 if (DB == null)
371 SetFailState("[ERROR ON START] LOGS: %s", gB_Error);
372 }
373 else
374 SetFailState("[BŁĄD W KONFIGURACJI] Nie znaleziono configu h2k_rangi w databases.cfg");
375
376 DB.SetCharset("utf8");
377 Format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `h2k_ranks` ( `id` INT NOT NULL AUTO_INCREMENT , `steamid` VARCHAR(64) NOT NULL , `name` VARCHAR(128) NOT NULL , `points` INT NOT NULL, `rank` INT NOT NULL, `coin` INT(6), `ma_coina` INT(1), `hud_mode` INT(1), `rank_name` VARCHAR(64) NOT NULL , PRIMARY KEY (`id`)) ENGINE = MyISAM CHARSET=utf8 COLLATE=utf8_general_ci");
378
379 DB.Query(SQLT_Error, query);
380}
381
382public void SQLT_Error(Database db, DBResultSet results, const char[] error, any data)
383{
384 if (results == null)
385 LogError("[ERROR] Error: %s", error);
386}
387
388public void DB_LoadInfo(int client)
389{
390 char authid[64];
391 char query[512];
392
393 GetClientAuthId(client, AuthId_SteamID64, authid, sizeof(authid));
394
395 Format(query, sizeof(query), "SELECT `name`, points, rank, coin, ma_coina, hud_mode FROM h2k_ranks WHERE steamid = '%s'", authid);
396
397 DB.Query(DB_LoadInfoCallback, query, client);
398}
399
400public void DB_LoadInfoCallback(Database db, DBResultSet results, const char[] error, int client)
401{
402 if (results == null)
403 {
404 LogError("Error: %s", error);
405 return;
406 }
407
408 if (results.FetchRow())
409 {
410 results.FetchString(0, PlayerName[client], MAX_NAME_LENGTH);
411 g_iPoints[client] = results.FetchInt(1);
412 g_iRank[client] = results.FetchInt(2);
413 iCoin[client] = results.FetchInt(3);
414 iCoin_Enable[client] = results.FetchInt(4);
415 Hud_Mode[client] = results.FetchInt(5);
416
417 }
418 else
419 {
420 GetClientName(client, PlayerName[client], MAX_NAME_LENGTH);
421 g_iPoints[client] = 0;
422 g_iRank[client] = 0;
423 iCoin[client] = 0;
424 iCoin_Enable[client] = 0;
425 Hud_Mode[client] = 0;
426 }
427}
428
429public void DB_SaveInfo(int client)
430{
431 if (IsFakeClient(client))
432 return;
433
434 char authid[64];
435 char query[512];
436
437 char gB_PlayerName[MAX_NAME_LENGTH];
438 GetClientName(client, gB_PlayerName, MAX_NAME_LENGTH);
439 int iLength = ((strlen(gB_PlayerName) * 2) + 1);
440 char[] gB_EscapedName = new char[iLength];
441 DB.Escape(gB_PlayerName, gB_EscapedName, iLength);
442
443 if (GetClientAuthId(client, AuthId_SteamID64, authid, sizeof(authid)))
444 {
445 DataPack pack = new DataPack();
446 pack.WriteString(authid);
447 pack.WriteString(gB_EscapedName);
448 pack.WriteCell(g_iPoints[client]);
449 pack.WriteCell(g_iRank[client]);
450 pack.WriteCell(iCoin[client]);
451 pack.WriteCell(iCoin_Enable[client]);
452 pack.WriteCell(Hud_Mode[client]);
453
454
455 Format(query, sizeof(query), "SELECT `id` FROM h2k_ranks WHERE `steamid`='%s'", authid);
456 DB.Query(SaveInfoCallB, query, pack);
457 }
458}
459
460public void SaveInfoCallB(Database db, DBResultSet results, const char[] error, DataPack pack)
461{
462 if (results == null)
463 {
464 LogError(error);
465 return;
466 }
467
468 char query[256];
469 char steamid[64];
470 char eName[512];
471
472 int iPunkty = 0;
473 int iRanga = 0;
474 int Moneta = 0;
475 int Moneta_Wlaczona = 0;
476 int Hud_Pozycja = 0;
477
478 pack.Reset();
479
480 pack.ReadString(steamid, sizeof(steamid));
481 pack.ReadString(eName, sizeof(eName));
482
483 iPunkty = pack.ReadCell();
484 iRanga = pack.ReadCell();
485 Moneta = pack.ReadCell();
486 Moneta_Wlaczona = pack.ReadCell();
487 Hud_Pozycja = pack.ReadCell();
488
489 if (results.FetchRow())
490 {
491 int id = results.FetchInt(0);
492
493 Format(query, sizeof(query), "UPDATE h2k_ranks SET name = '%s', points='%d', rank='%d', coin='%i', ma_coina='%i', hud_mode='%i', rank_name='%s' WHERE id = %i", eName, iPunkty, iRanga, Moneta, Moneta_Wlaczona, Hud_Pozycja, g_iRankTable[iRanga], id);
494 DB.Query(SQLT_Error, query);
495 }
496 else
497 {
498 Format(query, sizeof(query), "INSERT INTO `h2k_ranks` (`id`, `steamid`, `name`, `points`, `rank`, `coin`, `ma_coina`, `hud_mode`, `rank_name`) VALUES (NULL, '%s', '%s', '%d', '%d', '%i', '%i', '%i', '%s')", steamid, eName, iPunkty, iRanga, Moneta, Moneta_Wlaczona, Hud_Pozycja, g_iRankTable[iRanga]);
499 DB.Query(SQLT_Error, query);
500 }
501}
502
503public Action PokazTopke(int client, int args)
504{
505 char query[2000];
506
507 DataPack pack = new DataPack();
508 pack.WriteCell(client);
509
510 Format(query, sizeof(query), "SELECT name, points, rank FROM h2k_ranks WHERE 1 ORDER BY points DESC");
511 DB.Query(DB_TopCallback, query, pack);
512
513 return Plugin_Handled;
514}
515
516public void DB_TopCallback(Database db, DBResultSet results, const char[] error, DataPack pack)
517{
518 if (results == null)
519 {
520 LogError("[ERROR] Error: %s", error);
521 return;
522 }
523
524 pack.Reset();
525 int client = pack.ReadCell();
526
527 if (client == 0 || !IsClientInGame(client))
528 return;
529
530 delete pack;
531
532 int i;
533
534 if (client == 0 || !IsClientInGame(client))
535 return;
536
537 Menu menu = new Menu(TOP_Handler, MENU_ACTIONS_ALL);
538 menu.SetTitle("[#TOP] Nick - Ranga - Punkty");
539
540 char menu_item[256];
541
542 while (results.FetchRow())
543 {
544 i++;
545 results.FetchString(0, menu_item, sizeof(menu_item));
546
547 Format(menu_item, sizeof(menu_item), "#%d - %s - %s - [ %d ]", i, menu_item, g_iRankTable[results.FetchInt(2)], results.FetchInt(1));
548 menu.AddItem("", menu_item);
549 }
550
551 if (i == 0)
552 menu.AddItem("no_records", "Wygląda na to, że ranking jest czysty.");
553
554 menu.ExitButton = true;
555 menu.Display(client, 0);
556}
557
558public int TOP_Handler(Menu menu, MenuAction action, int param1, int param2)
559{
560 return 0;
561}
562
563/* << Na końcu mapy >> */
564public void OnMapEnd()
565{
566 LoopClients(i)
567 DB_SaveInfo(i);
568 SDKUnhook(FindEntityByClassname(MAXPLAYERS + 1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
569}
570
571public void LoadClientCookiesFor(int client)
572{
573 char buffer[5];
574 GetClientCookie(client, g_hClientCookieOverlays, buffer, 5);
575 if (!StrEqual(buffer, ""))
576 {
577 g_bClientPrefOverlays[client] = StringToInt(buffer);
578 }
579 if (StrEqual(buffer, "")) {
580 g_bClientPrefOverlays[client] = 1;
581 }
582}
583
584/* << Eventy >> */
585public Action Event_PlayerDeath(Event hEvent, const char[] chName, bool bDontBroadcast)
586{
587 if (GetCurrentPlayers() < g_Cvar_MinimalnaIloscGraczy.IntValue)
588 return;
589
590 bool headshot = GetEventBool(hEvent, "headshot");
591 int attacker = GetClientOfUserId(hEvent.GetInt("attacker"));
592 int client = GetClientOfUserId(hEvent.GetInt("userid"));
593 int iPoints;
594
595 char weapon[64];
596 GetEventString(hEvent, "weapon", weapon, sizeof(weapon));
597 ReplaceString(weapon, sizeof(weapon), "weapon_", "");
598
599 // kys., mogę to zrobić w 1 linijce, ale mi się nie chce ;)
600 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")) {
601 weapon = "knife";
602 }
603
604 if (Warmup() && !g_Cvar_PunktyWarmupEnabled.BoolValue)
605 {
606 return;
607 }
608
609 if (!attacker)
610 return;
611
612 if (attacker == client)
613 return;
614
615 if (!IsValidClient(attacker))
616 return;
617
618 if (VipPlayer(attacker))
619 {
620 iPoints = headshot ? g_Cvar_PunktyHsVip.IntValue:g_Cvar_PunktyKillVip.IntValue;
621 GivePoints(attacker, iPoints);
622 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");
623
624 if (StrEqual(weapon, "knife"))
625 {
626 if (!g_Cvar_PunktyKnifeEnabled.BoolValue)
627 {
628 return;
629 }
630
631 iPoints = g_Cvar_PunktyKnifeKillVip.IntValue;
632 GivePoints(attacker, iPoints);
633 CPrintToChat(attacker, "★ {lightred}[Rangi -> Vip]{yellow} Jako {green}VIP {yellow}otrzymałeś {green}%i {yellow}punktów za zabójstwo z noża", iPoints);
634 }
635 }
636 else
637 {
638 iPoints = headshot ? g_Cvar_PunktyHs.IntValue:g_Cvar_PunktyKill.IntValue;
639 GivePoints(attacker, iPoints);
640 CPrintToChat(attacker, "★ {lightred}[Rangi]{yellow} Otrzymałeś {green}%i {yellow}punkty za {darkred}%s.", iPoints, headshot ? "HeadShota":"zabójstwo");
641
642 if (StrEqual(weapon, "knife"))
643 {
644 if (!g_Cvar_PunktyKnifeEnabled.BoolValue)
645 {
646 return;
647 }
648
649 iPoints = g_Cvar_PunktyKnifeKill.IntValue;
650 GivePoints(attacker, iPoints);
651 CPrintToChat(attacker, "★ {lightred}[Rangi]{yellow} Otrzymałeś {green}%i {yellow}punktów za zabójstwo z noża", iPoints);
652 }
653 }
654
655 if (g_Cvar_TraceniePKTEnabled.BoolValue)
656 {
657 if (VipPlayer(client))
658 {
659 iPoints = g_Cvar_PunktyDeathVip.IntValue;
660 if (g_iPoints[client] < g_Cvar_PunktyDeathVip.IntValue)
661 {
662 return;
663 }
664 else
665 {
666 TakePoints(client, iPoints);
667 CPrintToChat(client, "★ {lightred}[Rangi -> Death_Vip]{yellow} Jako {green}VIP {yellow}straciłeś tylko {green}%i {yellow}punktów za {darkred}Śmierć.", iPoints);
668 }
669 }
670 else
671 {
672 iPoints = g_Cvar_PunktyDeath.IntValue;
673 if (g_iPoints[client] < g_Cvar_PunktyDeath.IntValue)
674 {
675 return;
676 }
677 else
678 {
679 TakePoints(client, iPoints);
680 CPrintToChat(client, "★ {lightred}[Rangi -> Death]{yellow} Straciłeś właśnie {green}%i {yellow}punktów za {darkred}Śmierć", iPoints);
681 }
682 }
683 }
684}
685
686public Action Event_BombPlanted(Handle hEvent, const char[] chName, bool bDontBroadcast)
687{
688 if (!g_Cvar_PunktyBombEnabled.BoolValue)
689 return;
690
691
692 if (GetCurrentPlayers() < g_Cvar_MinimalnaIloscGraczy.IntValue)
693 return;
694
695 int client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
696
697 if (!IsValidClient(client))
698 return;
699
700 int iPoints = VipPlayer(client) ? g_Cvar_PunktyBombPlantedVip.IntValue:g_Cvar_PunktyBombPlanted.IntValue;
701 GivePoints(client, iPoints);
702 CPrintToChat(client, "★ {lightred}%s{green}%i {yellow}punktów za {darkred}Podłożenie Bomby", VipPlayer(client) ? "[Rangi -> Vip]{yellow} Jako {green}VIP {yellow}otrzymałeś ":"[Rangi]{yellow} Otrzymałeś ", iPoints);
703}
704
705public Action Event_BombDefused(Handle hEvent, const char[] chName, bool bDontBroadcast)
706{
707 if (!g_Cvar_PunktyBombEnabled.BoolValue)
708 return;
709
710
711 if (GetCurrentPlayers() < g_Cvar_MinimalnaIloscGraczy.IntValue)
712 return;
713
714 int client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
715
716 if (!IsValidClient(client))
717 return;
718
719 int iPoints = VipPlayer(client) ? g_Cvar_PunktyBombDefusedVip.IntValue:g_Cvar_PunktyBombDefused.IntValue;
720 GivePoints(client, iPoints);
721 CPrintToChat(client, "★ {lightred}%s{green}%i {yellow}punktów za {darkred}Rozbrojenie Bomby", VipPlayer(client) ? "[Rangi -> Vip]{yellow} Jako {green}VIP {yellow}otrzymałeś ":"[Rangi]{yellow} Otrzymałeś ", iPoints);
722}
723
724public Action Event_RoundMvp(Event event, char[] chName, bool bDontBroadcast)
725{
726 if (!g_Cvar_PunktyMvpEnabled.BoolValue)
727 return;
728
729 if (GetCurrentPlayers() < g_Cvar_MinimalnaIloscGraczy.IntValue)
730 return;
731
732 int client = GetClientOfUserId(GetEventInt(event, "userid"));
733
734 if (!IsValidClient(client))
735 return;
736
737 int iPoints = VipPlayer(client) ? g_Cvar_PunktyMvpPlayerVip.IntValue:g_Cvar_PunktyMvpPlayer.IntValue;
738 GivePoints(client, iPoints);
739 CPrintToChat(client, "★ {lightred}%s{green}%i {yellow}punktów za {darkred}bycie graczem MVP", VipPlayer(client) ? "[Rangi -> Vip]{yellow} Jako {green}VIP {yellow}otrzymałeś ":"[Rangi]{yellow} Otrzymałeś ", iPoints);
740}
741
742public Action Event_RoundStart(Event event, char[] chName, bool bDontBroadcast)
743{
744 if (GetCurrentPlayers() < g_Cvar_MinimalnaIloscGraczy.IntValue)
745 {
746 CPrintToChatAll("{yellow}============= ★ {olive}Rank System {yellow}★ =============");
747 CPrintToChatAll("★ {lightred}[Rangi]{yellow} Na serwerze jest {darkred}zbyt mało{yellow} graczy by system rang naliczał punkty, potrzeba minimum {lightred}%i{yellow}, graczy.", g_Cvar_MinimalnaIloscGraczy.IntValue);
748 CPrintToChatAll("{yellow}============= ★ {olive}Rank System {yellow}★ =============");
749 }
750}
751
752public Action Event_RoundEnd(Event event, char[] chName, bool bDontBroadcast)
753{
754 if (GetCurrentPlayers() < g_Cvar_MinimalnaIloscGraczy.IntValue)
755 return;
756
757 int winnerTeam = GetEventInt(event, "winner");
758
759 if (Warmup() && !g_Cvar_PunktyWarmupEnabled.BoolValue)
760
761 LoopClients(i)
762 {
763 if (GetClientTeam(i) == winnerTeam)
764 {
765 if (g_Cvar_WygranaRundaEnabled.BoolValue)
766 {
767 int iPoints = VipPlayer(i) ? g_Cvar_PunktyPrzegranaRundaVip.IntValue:g_Cvar_PunktyPrzegranaRunda.IntValue;
768 GivePoints(i, iPoints);
769 CPrintToChat(i, "★ {lightred}%s{green}%i {yellow}punkty za {darkred}Wygranie Rundy", VipPlayer(i) ? "[Rangi -> Vip]{yellow} Jako {green}VIP {yellow}Otrzymałeś ":"[Rangi]{yellow} Otrzymałeś ", iPoints);
770 }
771 else
772 {
773 return;
774 }
775 }
776 else
777 {
778 if (g_Cvar_TraceniePKTEnabled.BoolValue)
779 {
780 if (g_Cvar_PrzegranaRundaEnabled.BoolValue)
781 {
782 int iPoints = VipPlayer(i) ? g_Cvar_PunktyPrzegranaRundaVip.IntValue:g_Cvar_PunktyPrzegranaRunda.IntValue;
783 if (g_iPoints[i] < g_Cvar_PunktyPrzegranaRundaVip.IntValue || g_Cvar_PunktyPrzegranaRunda.IntValue)
784 {
785 return;
786 }
787 else
788 {
789 TakePoints(i, iPoints);
790 CPrintToChat(i, "★ {lightred}%s{green}%i {yellow}punktów za {darkred}Przegranie Rundy", VipPlayer(i) ? "[Rangi -> Vip]{yellow} Jako {green}VIP {yellow}Tracisz tylko ":"[Rangi]{yellow} Tracisz ", iPoints);
791 }
792 }
793 else
794 {
795 return;
796 }
797 }
798 }
799 DB_SaveInfo(i);
800 }
801}
802
803/* << Cmds >>*/
804public Action CMD_MenuGlowne(int client, int args)
805{
806 Menu menuglowne = new Menu(Menu_menuglowne);
807
808 if (g_iRank[client] == sizeof(g_iPointsTable) - 1)
809 menuglowne.SetTitle("Witaj, [ %N ]\nPosiadasz aktualnie: [ %d ] punktów\nTwoja ranga to: [ %s ]\nTwoja odznaka to: [ %s ]", client, g_iPoints[client], g_iRankTable[g_iRank[client]], g_TablicaOdznak[iCoin[client]]);
810 else
811 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_iRankTable[g_iRank[client]], g_TablicaOdznak[iCoin[client]], g_iRankTable[g_iRank[client] + 1], g_iPointsTable[g_iRank[client]]);
812 menuglowne.AddItem("1", "", ITEMDRAW_SPACER);
813 menuglowne.AddItem("option1", "» Menu Gracza");
814 menuglowne.AddItem("option2", "» Pokaż top graczy na serwerze!");
815 menuglowne.AddItem("option3", "» Zarządzanie HUD!");
816
817 if (GetAdminFlag(GetUserAdmin(client), Admin_Root))
818 menuglowne.AddItem("option5", "» Panel Administratora");
819
820 menuglowne.ExitButton = true;
821 menuglowne.Display(client, 0);
822
823 return Plugin_Handled;
824}
825
826public int Menu_menuglowne(Handle menuglowne, MenuAction action, int client, int itemNum)
827{
828 if (action == MenuAction_Select)
829 {
830 char info[32];
831 GetMenuItem(menuglowne, itemNum, info, sizeof(info));
832
833 if (StrEqual(info, "option1"))
834 CreateMenu_Glowne(client);
835 else if (StrEqual(info, "option2"))
836 PokazTopke(client, 0);
837 else if (StrEqual(info, "option5"))
838 CMD_PanelRangi(client, 0);
839 else if (StrEqual(info, "option3"))
840 CMD_HUDMode(client, 0);
841 }
842 else if (action == MenuAction_End)
843 CloseHandle(menuglowne);
844}
845
846public Action CMD_PanelRangi(int client, int args)
847{
848 if (!g_Cvar_PanelAdministracyjnyEnabled.BoolValue)
849 {
850 CPrintToChat(client, "★ {lightred}[✖] {yellow}Ta opcja została wyłączona przez administratora serwera.");
851 return Plugin_Handled;
852 }
853
854 Menu menu = new Menu(Rangi_MenuHandler);
855 menu.SetTitle("[Rangi] Panel Administratora");
856
857 menu.AddItem("addpts", "Dodaj Punkty");
858 menu.AddItem("rempts", "Zabierz Punkty");
859 menu.AddItem("setrank", "Ustaw Range");
860 menu.AddItem("removeall", "Zresetuj wszystkim graczom rangi/punkty");
861 menu.AddItem("showpoints", "Pokaz Punkty Graczy Online");
862
863 menu.ExitButton = true;
864 menu.Display(client, 60);
865
866 return Plugin_Handled;
867}
868
869public int Rangi_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
870{
871 if (action == MenuAction_Select)
872 {
873 char item[32];
874 bool found = menu.GetItem(param2, item, sizeof(item));
875 if (found)
876 {
877 if (StrEqual(item, "addpts"))
878 {
879 CreateMenu_AdminSelect(param1, 1);
880 }
881 else if (StrEqual(item, "rempts"))
882 {
883 CreateMenu_AdminSelect(param1, 2);
884 }
885 else if (StrEqual(item, "setrank"))
886 {
887 CreateMenu_AdminSelect(param1, 3);
888 }
889 else if (StrEqual(item, "removeall"))
890 {
891 Potwierdz_Reset(param1, 4);
892 }
893 else if (StrEqual(item, "showpoints"))
894 {
895 Menu next = new Menu(Empty_MenuHandler);
896 next.SetTitle("Rangi -> Punkty");
897
898 LoopClients(i)
899 {
900 char format[128];
901 char cid[16];
902 IntToString(i, cid, sizeof cid);
903 char name[MAX_NAME_LENGTH + 1];
904 GetClientName(i, name, sizeof name);
905 Format(format, sizeof format, "%s - %d punktow", name, g_iPoints[i]);
906 next.AddItem(cid, format);
907 }
908
909 next.ExitButton = true;
910 next.Display(param1, 60);
911 }
912 }
913 }
914 else if (action == MenuAction_End)
915 delete menu;
916}
917
918public Action Potwierdz_Reset(int client, int args)
919{
920 Menu menureset = new Menu(Menu_ResetRang);
921 menureset.SetTitle("Czy na pewno chcesz wyczyścyć wszystkie rangi & punkty & odznaki graczy?\nPamiętaj że tej akcji nie możesz cofnąć!");
922 menureset.AddItem("opcja1", "» NIE!");
923 menureset.AddItem("opcja1", "» NIE!");
924 menureset.AddItem("opcja2", "» TAK!!!");
925 menureset.AddItem("opcja1", "» NIE!");
926 menureset.ExitButton = true;
927 menureset.Display(client, 0);
928}
929
930public int Menu_ResetRang(Menu menureset, MenuAction action, int client, int itemNum)
931{
932 if (action == MenuAction_Select)
933 {
934 char info[32];
935 GetMenuItem(menureset, itemNum, info, sizeof(info));
936
937 if (strcmp(info, "opcja1") == 0) {
938 CMD_PanelRangi(client, 0);
939 }
940 else if (strcmp(info, "opcja2") == 0) {
941 Wyczysc_Wszystko(client, 0);
942 }
943 }
944
945 else if (action == MenuAction_End) {
946 CloseHandle(menureset);
947 }
948}
949
950public Action Wyczysc_Wszystko(int client, int args)
951{
952 char query[512];
953 Format(query, sizeof(query), "DELETE FROM `h2k_ranks` WHERE 1=1");
954 DB.Query(DB_LoadInfoCallback, query, client);
955
956 LoopClients(i) {
957 if (IsClientInGame(i))
958 OnClientPutInServer(i);
959 }
960
961 CPrintToChat(client, "★ {lightred}[Rangi]{yellow} Baza została wyczyszczona.");
962 CPrintToChat(client, "★ {lightred}[Rangi]{yellow} .");
963 CPrintToChat(client, "★ {lightred}[Rangi]{yellow} .");
964 CPrintToChat(client, "★ {lightred}[Rangi]{yellow} .");
965 CPrintToChat(client, "★ {lightred}[Rangi]{yellow} Zmień mapę bądź zrestartuj serwer by baza mogła dokładnie wczytywać wszystko na nowo.");
966 return Plugin_Handled;
967}
968
969public Action CreateMenu_Glowne(int client)
970{
971 Menu menu = new Menu(Menu_Glowne);
972 menu.SetTitle("Rangi -> Menu Gracza");
973 menu.AddItem("option1", "» System Punktow");
974 menu.AddItem("option2", "» Ile PKT trzeba na range?");
975 menu.AddItem("option3", "» Zresetuj swoje punkty!");
976 menu.AddItem("option5", "» Wybierz odznake");
977 menu.ExitButton = true;
978 menu.Display(client, 0);
979}
980
981public int Menu_Glowne(Handle menu, MenuAction action, int client, int itemNum)
982{
983 if (action == MenuAction_Select)
984 {
985 char info[32];
986 GetMenuItem(menu, itemNum, info, sizeof(info));
987
988 if (StrEqual(info, "option1"))
989 CreateMenu_PokazPunkty(client);
990 else if (StrEqual(info, "option2"))
991 CreateMenu_PokazMenuRang(client);
992 else if (StrEqual(info, "option3"))
993 CreateMenu_Potwierdzenie(client);
994 else if (StrEqual(info, "option5"))
995 ClientCommand(client, "sm_coin");
996 }
997 else if (action == MenuAction_End)
998 CloseHandle(menu);
999}
1000
1001public Action CreateMenu_Potwierdzenie(int client)
1002{
1003 Menu menu = new Menu(Menu_Potwierdzenie);
1004 menu.SetTitle("Rangi -> Czy jesteś pewien że chcesz zresetować swoje statystyki?");
1005 menu.AddItem("option1", "» Tak");
1006 menu.AddItem("option2", "» Nie");
1007 menu.ExitButton = true;
1008 menu.Display(client, 0);
1009}
1010
1011public Action CreateMenu_PokazPunkty(int client)
1012{
1013 Menu punkty = new Menu(Menu_Punkty);
1014 punkty.SetTitle("[Rangi -> Menu Punktów] Wybierz jedną z opcji");
1015 punkty.AddItem("option1", "» Zwykły gracz");
1016 punkty.AddItem("option2", "» Gracz VIP");
1017 punkty.AddItem("option3", "Powrót do menu");
1018 punkty.ExitButton = false;
1019 punkty.Display(client, 0);
1020}
1021
1022public Action CreateMenu_PokazMenuRang(int client)
1023{
1024 char sItem[64];
1025 Menu menurang = new Menu(Menu_MenuRang);
1026 menurang.SetTitle("[Rangi -> PKT na daną range]\n");
1027 LoopRanks(i)
1028 {
1029 Format(sItem, sizeof(sItem), "%s - %d punktów\n", g_iRankTable[i], g_iPointsTable[i - 1]);
1030 menurang.AddItem("", sItem);
1031 }
1032 menurang.AddItem("option2", "Wroc do menu");
1033 menurang.ExitButton = false;
1034 menurang.Display(client, 0);
1035}
1036
1037public Action CreateMenu_Punkty(int client)
1038{
1039 Menu punktygracz = new Menu(Menu_PunktyInfo);
1040 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", g_Cvar_PunktyKill.IntValue, g_Cvar_PunktyHs.IntValue, g_Cvar_PunktyBombPlanted.IntValue, g_Cvar_PunktyBombDefused.IntValue, g_Cvar_PunktyWygranaRunda.IntValue);
1041 punktygracz.AddItem("option1", "Wroc");
1042 punktygracz.ExitButton = false;
1043 punktygracz.Display(client, 0);
1044}
1045
1046public Action CreateMenu_PunktyVip(int client)
1047{
1048 Menu punktyvip = new Menu(Menu_PunktyInfo);
1049 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", g_Cvar_PunktyKillVip.IntValue, g_Cvar_PunktyHsVip.IntValue, g_Cvar_PunktyBombPlantedVip.IntValue, g_Cvar_PunktyBombDefusedVip.IntValue, g_Cvar_PunktyWygranaRundaVip.IntValue);
1050 punktyvip.AddItem("option1", "Wroc");
1051 punktyvip.ExitButton = false;
1052 punktyvip.Display(client, 0);
1053}
1054
1055public Action CreateMenu_AdminSelect(int client, int iSelect)
1056{
1057 Menu next = new Menu(SelectPlayer_MenuHandler);
1058 next.SetTitle("Rangi -> Wybor Gracza");
1059
1060 LoopClients(i)
1061 {
1062 char format[64];
1063 Format(format, sizeof format, "%d", i);
1064 char name[MAX_NAME_LENGTH + 1];
1065 GetClientName(i, name, sizeof name);
1066 next.AddItem(format, name);
1067 }
1068
1069 char sInfo[12];
1070 Format(sInfo, sizeof(sInfo), "%d", iSelect);
1071 next.AddItem("-SELECT-", sInfo, ITEMDRAW_IGNORE);
1072 next.ExitButton = true;
1073 next.Display(client, 60);
1074}
1075
1076public Action CreateMenu_AddRemovePoints(int admin, int client, int iSelect)
1077{
1078 Menu next = new Menu(PointAct_MenuHandler);
1079 char frm[128];
1080 char pname[MAX_NAME_LENGTH + 1];
1081 GetClientName(client, pname, sizeof pname);
1082 Format(frm, sizeof frm, "Rangi - %s", pname);
1083 next.SetTitle(frm);
1084
1085 next.AddItem("1", "1 Punkt");
1086 next.AddItem("5", "5 Punktow");
1087 next.AddItem("10", "10 Punktow");
1088 next.AddItem("20", "20 Punktow");
1089 next.AddItem("50", "50 Punktow");
1090 next.AddItem("100", "100 Punktow");
1091 next.AddItem("200", "200 Punktow");
1092 next.AddItem("500", "500 Punktow");
1093 next.AddItem("1000", "1000 Punktow");
1094 next.AddItem("2500", "2500 Punktow");
1095 next.AddItem("5000", "5000 Punktow");
1096
1097 char sInfo[12];
1098
1099 Format(sInfo, sizeof(sInfo), "%d", iSelect);
1100 next.AddItem("-SELECT-", sInfo, ITEMDRAW_IGNORE);
1101 Format(sInfo, sizeof(sInfo), "%d", client);
1102 next.AddItem("-CLIENT-", sInfo, ITEMDRAW_IGNORE);
1103
1104 next.ExitButton = true;
1105 next.Display(admin, 60);
1106}
1107
1108public int PointAct_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
1109{
1110 char sInfo[12], sDane[12];
1111 int iSelect, client;
1112 LoopItemCount(i)
1113 {
1114 menu.GetItem(i, sInfo, sizeof(sInfo), _, sDane, sizeof(sDane));
1115
1116 if (StrEqual(sInfo, "-SELECT-"))
1117 iSelect = StringToInt(sDane);
1118
1119 if (StrEqual(sInfo, "-CLIENT-"))
1120 client = StringToInt(sDane);
1121 }
1122 if (action == MenuAction_Select)
1123 {
1124 char item[32];
1125 menu.GetItem(param2, item, sizeof(item));
1126 if (IsValidClient(client))
1127 {
1128 if (iSelect == 1)
1129 {
1130 g_iPoints[client] += StringToInt(item);
1131 }
1132
1133 else if (iSelect == 2)
1134 {
1135 if (g_iPoints[client] < StringToInt(item))
1136 {
1137 CPrintToChat(client, "{darkred}[✖] {yellow}Nie możesz wybrać tej opcji z tego powodu że gracz wtedy będzie mieć punkty na minusie.", g_iPoints[client]);
1138 }
1139 }
1140 else
1141 {
1142 g_iPoints[client] -= StringToInt(item);
1143 }
1144
1145 CreateMenu_AddRemovePoints(param1, client, iSelect);
1146 CheckRank(client);
1147 }
1148 }
1149 else if (action == MenuAction_End)
1150 delete menu;
1151}
1152
1153public int Menu_Potwierdzenie(Handle menu, MenuAction action, int client, int itemNum)
1154{
1155 if (action == MenuAction_Select)
1156 {
1157 char info[32];
1158 GetMenuItem(menu, itemNum, info, sizeof(info));
1159
1160 if (StrEqual(info, "option1"))
1161 {
1162 g_iPoints[client] = 0;
1163 CheckRank(client);
1164 CPrintToChat(client, "★ {lightred}[Rangi -> Reset] {yellow}Twoje punkty zostały {green}Pomyślnie {yellow}wyzerowane!");
1165 }
1166 else if (StrEqual(info, "option2"))
1167 CreateMenu_Glowne(client);
1168 }
1169 else if (action == MenuAction_End)
1170 CloseHandle(menu);
1171}
1172
1173public int Menu_Punkty(Handle punkty, MenuAction action, int client, int itemNum)
1174{
1175 if (action == MenuAction_Select)
1176 {
1177 char info[32];
1178 GetMenuItem(punkty, itemNum, info, sizeof(info));
1179
1180 if (StrEqual(info, "option1"))
1181 CreateMenu_Punkty(client);
1182 else if (StrEqual(info, "option2"))
1183 CreateMenu_PunktyVip(client);
1184 else if (StrEqual(info, "option3"))
1185 CreateMenu_Glowne(client);
1186 }
1187 else if (action == MenuAction_End)
1188 CloseHandle(punkty);
1189}
1190
1191public int Menu_PunktyInfo(Handle punktyvip, MenuAction action, int client, int itemNum)
1192{
1193 if (action == MenuAction_Select)
1194 {
1195 char info[32];
1196 GetMenuItem(punktyvip, itemNum, info, sizeof(info));
1197
1198 if (StrEqual(info, "option1"))
1199 CreateMenu_PokazPunkty(client);
1200 }
1201 else if (action == MenuAction_End)
1202 CloseHandle(punktyvip);
1203}
1204
1205public int Menu_MenuRang(Handle menurang, MenuAction action, int client, int itemNum)
1206{
1207 if (action == MenuAction_Select)
1208 {
1209 char info[32];
1210 GetMenuItem(menurang, itemNum, info, sizeof(info));
1211
1212 if (StrEqual(info, "option2"))
1213 CreateMenu_Glowne(client);
1214 }
1215 else if (action == MenuAction_End)
1216 CloseHandle(menurang);
1217}
1218
1219public int SelectPlayer_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
1220{
1221 char sInfo[12], sDane[12];
1222 int iSelect;
1223 LoopItemCount(i)
1224 {
1225 menu.GetItem(i, sInfo, sizeof(sInfo), _, sDane, sizeof(sDane));
1226 if (StrEqual(sInfo, "-SELECT-"))
1227 iSelect = StringToInt(sDane);
1228 }
1229 if (action == MenuAction_Select)
1230 {
1231 char item[32];
1232 bool found = menu.GetItem(param2, item, sizeof(item));
1233 if (found)
1234 {
1235 int client = StringToInt(item);
1236 if (IsValidClient(client))
1237 {
1238 if (iSelect != 3)
1239 CreateMenu_AddRemovePoints(param1, client, iSelect);
1240 else
1241 {
1242 Menu next = new Menu(SetRank_MenuHandler);
1243 char frm[128];
1244 char pname[MAX_NAME_LENGTH + 1];
1245 GetClientName(client, pname, sizeof pname);
1246 Format(frm, sizeof frm, "Rangi - %s", pname);
1247 next.SetTitle(frm);
1248
1249 char sNum[12];
1250 LoopRanks(i)
1251 {
1252 Format(sNum, sizeof(sNum), "%d", i);
1253 next.AddItem(sNum, g_iRankTable[i]);
1254 }
1255 Format(sNum, sizeof(sNum), "%d", client);
1256 next.AddItem("-CLIENT-", sNum, ITEMDRAW_IGNORE);
1257 next.ExitButton = true;
1258 next.Display(param1, 60);
1259 }
1260 }
1261 }
1262 }
1263 else if (action == MenuAction_End)
1264 delete menu;
1265}
1266
1267public int Empty_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
1268{
1269 if (action == MenuAction_End)delete menu;
1270}
1271
1272public int SetRank_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
1273{
1274 char sInfo[32], sDane[32];
1275 int client;
1276 LoopItemCount(i)
1277 {
1278 menu.GetItem(i, sInfo, sizeof(sInfo), _, sDane, sizeof(sDane));
1279 if (StrEqual(sInfo, "-CLIENT-"))
1280 client = StringToInt(sDane);
1281 }
1282 if (action == MenuAction_Select)
1283 {
1284 char item[32];
1285 menu.GetItem(param2, item, sizeof(item));
1286 if (IsValidClient(client))
1287 {
1288 int iNewRank = StringToInt(item);
1289 CPrintToChat(client, "★ {lightred}[ADMIN]{yellow} Admin zmienił twoją rangę na {lightred}%s", g_iRankTable[iNewRank]);
1290 CPrintToChat(param1, "★ {lightred}[ADMIN]{yellow} Zmieniłeś rangę graczowi {green}%N {yellow}na {lightred}%s", client, g_iRankTable[iNewRank]);
1291 g_iPoints[client] = g_iPointsTable[iNewRank - 1];
1292 CheckRank(client);
1293 }
1294 }
1295 else if (action == MenuAction_End)
1296 delete menu;
1297}
1298
1299public Action Hook_OnThinkPost(int iEnt)
1300{
1301 static int iCoinOffset = -1;
1302 if (iCoinOffset == -1)
1303 iCoinOffset = FindSendPropInfo("CCSPlayerResource", "m_nActiveCoinRank");
1304
1305 int tempCoin[65];
1306 GetEntDataArray(iEnt, iCoinOffset, tempCoin, 65);
1307 for (int i = 1; i <= MaxClients; i++)
1308 {
1309 if (!IsValidClient(i))continue;
1310 if (iCoin_Enable[i])
1311 tempCoin[i] = g_TablicaID[iCoin[i]];
1312 }
1313
1314 for (int i = 1; i <= MaxClients; i++)
1315 SetEntData(iEnt, FindSendPropInfo("CCSPlayerResource", "m_iCompetitiveRanking") + i * 4, (g_iRank[i] + g_iType) == 50 ? 0 : (g_iRank[i] + g_iType)); //array ma problem z obsługą tej zmiany.
1316
1317 SetEntDataArray(iEnt, iCoinOffset, tempCoin, 65, 4, true);
1318 Handle hBuffer = StartMessageAll("ServerRankRevealAll");
1319 if (hBuffer == null)
1320 PrintToServer("ServerRankRevealAll = INVALID_HANDLE");
1321 else
1322 EndMessage();
1323}
1324
1325public Action CMD_DodajPkt(int client, int args)
1326{
1327 if (args < 2)
1328 {
1329 ReplyToCommand(client, "★ [ADMIN] Uzycie: sm_dodajpkt <#userid|Nick> [Ilosc]");
1330 return Plugin_Handled;
1331 }
1332
1333 char arg2[10];
1334 GetCmdArg(2, arg2, sizeof(arg2));
1335 int ilosc = StringToInt(arg2);
1336 char strTarget[32]; GetCmdArg(1, strTarget, sizeof(strTarget));
1337
1338 char strTargetName[MAX_TARGET_LENGTH];
1339 int TargetList[MAXPLAYERS], TargetCount;
1340 bool TargetTranslate;
1341
1342 if ((TargetCount = ProcessTargetString(strTarget, client, TargetList, MAXPLAYERS, COMMAND_FILTER_CONNECTED,
1343 strTargetName, sizeof(strTargetName), TargetTranslate)) <= 0)
1344 {
1345 ReplyToTargetError(client, TargetCount);
1346 return Plugin_Handled;
1347 }
1348
1349 for (int i = 0; i < TargetCount; i++)
1350 {
1351 int iClient = TargetList[i];
1352 if (IsClientInGame(iClient))
1353 {
1354 char name[32];
1355 char Admin_Name[32];
1356 GetClientName(iClient, name, sizeof(name));
1357 GetClientName(client, Admin_Name, sizeof(Admin_Name));
1358
1359 if (ilosc == 0)
1360 {
1361 CPrintToChat(client, "★ {lightred}[ADMIN]{yellow} Liczba punktów rangi musi być większa od{darkred} 0.");
1362 g_iPoints[iClient] += ilosc;
1363 }
1364
1365 if (ilosc > 0)
1366 {
1367 CPrintToChat(client, "★ {lightred}[ADMIN]{yellow} Dales {green}%i{yellow} punktów rangi graczowi {lightred}%s", ilosc, name);
1368 g_iPoints[iClient] += ilosc;
1369 CheckRank(client);
1370 }
1371 }
1372 }
1373 return Plugin_Continue;
1374}
1375
1376public Action CMD_HUD(int client, int args)
1377{
1378 if (!IsValidClient(client))
1379 return Plugin_Handled;
1380
1381 g_bHUD[client] = !g_bHUD[client];
1382 CPrintToChat(client, "HUD \x04%s\x01.", g_bHUD[client] ? "{green}[✔] {yellow}Wlaczony" : "{darkred}[✖] {yellow}Wylaczony");
1383
1384 return Plugin_Handled;
1385}
1386
1387public Action CMD_HUDMode(int client, int args)
1388{
1389 Menu menu = new Menu(Menu_HUDMode);
1390 menu.SetTitle("[HUD] Wybierz jedną z opcji, jak chciałbyś mieć wyświetlany HUD!");
1391 menu.AddItem("option1", "[ OLD ] Standardowy czyli na środku ekranu w hintbox");
1392 menu.AddItem("option2", "[ NEW ] Pod radarem, różne kolory.");
1393 menu.AddItem("option3", "[ ON/OFF ] Wyłącz/Włącz HUD");
1394 menu.Display(client, MENU_TIME_FOREVER);
1395}
1396
1397public int Menu_HUDMode(Handle menu, MenuAction action, int client, int itemNum)
1398{
1399 if (action == MenuAction_Select)
1400 {
1401 char info[32];
1402 GetMenuItem(menu, itemNum, info, sizeof(info));
1403
1404 if (strcmp(info, "option1") == 0) {
1405 Hud_Mode[client] = 0;
1406 CPrintToChat(client, "★ {lightred}[Katujemy -> HudMode] {yellow}Ustawiłeś pozycję swojego HUD jako: {darkred}STANDARDOWE");
1407 DB_SaveInfo(client);
1408 }
1409
1410 else if (strcmp(info, "option2") == 0) {
1411 Hud_Mode[client] = 1;
1412 CPrintToChat(client, "★ {lightred}[Katujemy -> HudMode] {yellow}Ustawiłeś pozycję swojego HUD jako: {darkred}NOWY!");
1413 DB_SaveInfo(client);
1414 }
1415
1416 else if (strcmp(info, "option3") == 0) {
1417 CMD_HUD(client, 0);
1418 }
1419
1420 else if (action == MenuAction_End) {
1421 CloseHandle(menu);
1422 }
1423 }
1424}
1425
1426public Action Timer_UpdateHUD(Handle Timer)
1427{
1428 LoopClients(i)
1429 {
1430 if (!g_bHUD[i])
1431 continue;
1432 UpdateHUD(i);
1433 }
1434 return Plugin_Continue;
1435}
1436
1437public void UpdateHUD(int client)
1438{
1439 if (Hud_Mode[client] == 0)
1440 {
1441 char sHintText[512];
1442
1443 char forum[32];
1444 g_Cvar_ForumName.GetString(forum, sizeof(forum));
1445
1446 if (IsPlayerAlive(client))
1447 {
1448 Format(sHintText, sizeof(sHintText), "%s<font color='#FFF'>Forum: <font color='#CA351B'>%s\n", sHintText, forum);
1449 Format(sHintText, sizeof(sHintText), "%s<font color='#FFF'>Ranga: <font color='#C9AE28'>%s\n", sHintText, g_iRankTable[g_iRank[client]]);
1450 Format(sHintText, sizeof(sHintText), "%s<font color='#FFF'>Coin: <font color='#C9AE28'>%s\n", sHintText, g_TablicaOdznak[iCoin[client]]);
1451 Format(sHintText, sizeof(sHintText), "%s<font color='#FFF'>VIP: <font color='#C9AE28'>%s</font>\n", sHintText, VipPlayer(client) ? "TAK" : "BRAK");
1452 }
1453 else
1454 {
1455 int spect = GetEntProp(client, Prop_Send, "m_iObserverMode");
1456 if (spect == 4 || spect == 5)
1457 {
1458 int target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
1459 if (target != -1 && IsValidClient(target))
1460 {
1461 Format(sHintText, sizeof(sHintText), "<font size='16'><font color='#C9AE28'>Statystyki gracza</font> \nRanga: [ %s ]\nPunkty: [ %d ]", g_iRankTable[g_iRank[target]], g_iPoints[target]);
1462 }
1463 }
1464 }
1465 PrintHintText(client, sHintText);
1466 }
1467 else if (Hud_Mode[client] == 1)
1468 {
1469 if (IsPlayerAlive(client))
1470 {
1471 SetHudTextParams(0.02, 0.37, 1.0, 255, 0, 0, 255, 0, 10.0, 0.0, 0.0);
1472 ShowHudText(client, 6, "(- [ Twoje Statystyki ] -)");
1473 SetHudTextParams(0.02, 0.40, 1.0, 0, 162, 232, 255, 0, 10.0, 0.0, 0.0);
1474 ShowHudText(client, 7, "(- Aktualna ranga: [ %s ] -)", g_iRankTable[g_iRank[client]]);
1475 SetHudTextParams(0.02, 0.43, 1.0, 6, 231, 1, 255, 0, 10.0, 0.0, 0.0);
1476 ShowHudText(client, 8, "(- Ilość punktów [ %d ] -)\n(- Odznaka [ %s ] -)", g_iPoints[client], g_TablicaOdznak[iCoin[client]]);
1477 }
1478 else
1479 {
1480 int spect = GetEntProp(client, Prop_Send, "m_iObserverMode");
1481 if (spect == 4 || spect == 5)
1482 {
1483 int target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
1484 if (target != -1 && IsValidClient(target))
1485 {
1486 SetHudTextParams(0.02, 0.37, 1.0, 255, 0, 0, 255, 0, 10.0, 0.0, 0.0);
1487 ShowHudText(client, 6, "(- Statystyki Gracza -)");
1488 SetHudTextParams(0.02, 0.40, 1.0, 0, 162, 232, 255, 0, 10.0, 0.0, 0.0);
1489 ShowHudText(client, 7, "(- Aktualna ranga: [ %s ] -)", g_iRankTable[g_iRank[target]]);
1490 SetHudTextParams(0.02, 0.43, 1.0, 6, 231, 1, 255, 0, 10.0, 0.0, 0.0);
1491 ShowHudText(client, 8, "(- Ilość punktów [ %d ] -)\n(- Odznaka [ %s ] -)", g_iPoints[target], g_TablicaOdznak[iCoin[target]]);
1492 }
1493 }
1494 }
1495 }
1496}
1497
1498public Action Timer_DeleteOverlay(Handle timer, any client)
1499{
1500 if (IsValidClient(client))
1501 ClientCommand(client, "r_screenoverlay \"%s\"", "");
1502}
1503
1504public Action CMD_ShowOverlayPrefs(int client, int args)
1505{
1506 ShowOVMenu(client);
1507 return Plugin_Handled;
1508}
1509
1510public ShowOVMenu(client)
1511{
1512 Menu menu = new Menu(MenuHandlerOverlays);
1513 menu.SetTitle("Katujemy_Rangi - OV EDITION");
1514 menu.AddItem("g_bClientPrefOverlays[client] == 1", "Wyłącz/Włącz overlaye.");
1515 menu.ExitButton = true;
1516 menu.Display(client, MENU_TIME_FOREVER);
1517}
1518
1519public int OVPrefSelected(int client, CookieMenuAction action, any info, char[] buffer, int maxlen)
1520{
1521 if (action == CookieMenuAction_SelectOption)
1522 {
1523 ShowOVMenu(client);
1524 }
1525}
1526
1527public int MenuHandlerOverlays(Handle menu, MenuAction action, int param1, int param2)
1528{
1529 if (action == MenuAction_Select)
1530 {
1531 if (param2 == 0)
1532 {
1533 if (g_bClientPrefOverlays[param1] == 0)
1534 {
1535 g_bClientPrefOverlays[param1] = 1;
1536 CPrintToChat(param1, "{green}[✔] {yellow}Pomyślnie włączyłeś Overlaye!");
1537 }
1538 else
1539 {
1540 g_bClientPrefOverlays[param1] = 0;
1541 CPrintToChat(param1, "{green}[✔] {yellow}Pomyślnie wyłączyłeś Overlaye!");
1542 }
1543 }
1544 char buffer[5];
1545 SetClientCookie(param1, g_hClientCookieOverlays, buffer);
1546 IntToString(g_bClientPrefOverlays[param1], buffer, 5);
1547 CMD_ShowOverlayPrefs(param1, 0);
1548 }
1549 else if (action == MenuAction_End)
1550 {
1551 CloseHandle(menu);
1552 }
1553}
1554
1555/* << Check for ranks>> */
1556void CheckRank(int client)
1557{
1558 bool bRankUp = false;
1559 bool bRankDown = false;
1560
1561 if (!IsValidClient(client))
1562 return;
1563
1564 while (g_iPoints[client] >= g_iPointsTable[g_iRank[client]] && g_iRank[client] < sizeof(g_iPointsTable) - 1)
1565 {
1566 g_iRank[client]++;
1567 bRankUp = true;
1568 }
1569
1570 if (g_iRank[client] > 0)
1571 {
1572 while (g_iRank[client] > 0 && g_iPoints[client] < g_iPointsTable[g_iRank[client] - 1]) // i wasted fucking, 3 days on you...
1573 {
1574 g_iRank[client]--;
1575 bRankDown = true;
1576 }
1577 }
1578
1579 if (bRankUp)
1580 {
1581 CPrintToChat(client, "★ {lightred}[Awans]{yellow} Gratulacje! właśnie awansowałeś na range: {green}%s", g_iRankTable[g_iRank[client]]);
1582 EmitSoundToClient(client, "*/h2k/rangi/awans.mp3");
1583
1584 if (g_bClientPrefOverlays[client])
1585 {
1586 char sBuffer[32];
1587 Format(sBuffer, sizeof(sBuffer), "h2k_overlays/rank_%d", g_iRank[client]);
1588 ClientCommand(client, "r_screenoverlay \"%s\"", sBuffer);
1589 CreateTimer(2.5, Timer_DeleteOverlay, client);
1590 }
1591 }
1592
1593 if (bRankDown)
1594 {
1595 CPrintToChat(client, "★ {lightred}[[Spadek]]{yellow} UPS! Właśnie spadłeś do rangi: {green}%s", g_iRankTable[g_iRank[client]]);
1596
1597 if (g_bClientPrefOverlays[client])
1598 {
1599 char sBuffer[32];
1600 Format(sBuffer, sizeof(sBuffer), "h2k_overlays/rank_%d", g_iRank[client]);
1601 ClientCommand(client, "r_screenoverlay \"%s\"", sBuffer);
1602 CreateTimer(2.5, Timer_DeleteOverlay, client);
1603 }
1604 }
1605}
1606
1607
1608/* << Stocks / Bolls >> */
1609stock int GetCurrentPlayers() {
1610 int count;
1611 LoopClients(i) {
1612 if (!IsFakeClient(i)) {
1613 count++;
1614 }
1615 }
1616 return count;
1617}
1618
1619stock void GivePoints(int client, int value)
1620{
1621 g_iPoints[client] += value;
1622 CheckRank(client);
1623}
1624
1625stock void TakePoints(int client, int value)
1626{
1627 if (g_iPoints[client] < value)
1628 {
1629 return;
1630 }
1631 else
1632 {
1633 g_iPoints[client] -= value;
1634 CheckRank(client);
1635 }
1636}
1637
1638stock bool CzyNumerekJestNumerkiem(char[] arg)
1639{
1640 int argl = strlen(arg);
1641 for (int i = 0; i < argl; i++)
1642 {
1643 if (!IsCharNumeric(arg[i]))
1644 {
1645 return false;
1646 }
1647 }
1648 return true;
1649}
1650
1651stock bool VipPlayer(int client)
1652{
1653 int flag = GetFlag();
1654
1655 if (GetUserFlagBits(client) & flag || GetAdminFlag(GetUserAdmin(client), Admin_Root)) {
1656 return true;
1657 } else {
1658 return false;
1659 }
1660}
1661
1662int GetFlag()
1663{
1664 char flag[10];
1665 g_Cvar_VipFlag.GetString(flag, sizeof(flag));
1666
1667 return ReadFlagString(flag);
1668}
1669
1670stock bool Warmup()
1671{
1672 return GameRules_GetProp("m_bWarmupPeriod") != 0;
1673}
1674
1675stock bool IsValidClient(int client)
1676{
1677 if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || IsFakeClient(client))
1678 return false;
1679 return true;
1680}
1681
1682public int Native_GetClientPoints(Handle plugin, int numParams)
1683{
1684 int client = GetNativeCell(1);
1685 return g_iPoints[client];
1686}
1687
1688public int Native_GivePoints(Handle plugin, int numParams)
1689{
1690 int client = GetNativeCell(1);
1691 int points = GetNativeCell(2);
1692
1693 g_iPoints[client] = points;
1694
1695}
1696
1697/* © 2019 Coded with ❤ */