· 6 years ago · Sep 14, 2019, 11:10 PM
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 CreateTimer(500.0, Timer_AD, _, TIMER_REPEAT);
300}
301
302public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
303{
304 CreateNative("H2K_GetClientPoints", Native_GetClientPoints);
305 CreateNative("H2K_SetClientPoints", Native_GivePoints);
306
307 RegPluginLibrary("ranks");
308
309 return APLRes_Success;
310}
311
312/* << Na starcie mapy >> */
313public void OnMapStart()
314{
315 GetRanksKv();
316 SDKHook(FindEntityByClassname(MAXPLAYERS + 1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
317
318 char sBuffer[64];
319 static const char sPath[] = "materials/panorama/images/icons/skillgroups/skillgroup%i.svg";
320 LoopRanks(i)
321 {
322 Format(sBuffer, sizeof(sBuffer), "materials/h2k_overlays/rank_%d.vmt", i);
323 AddFileToDownloadsTable(sBuffer);
324 Format(sBuffer, sizeof(sBuffer), "materials/h2k_overlays/rank_%d.vtf", i);
325 AddFileToDownloadsTable(sBuffer);
326 Format(sBuffer, sizeof(sBuffer), "h2k_overlays/rank_%d.vmt", i);
327 PrecacheDecal(sBuffer, true);
328 Format(sBuffer, sizeof(sBuffer), "h2k_overlays/rank_%d.vmt", i);
329 PrecacheDecal(sBuffer, true);
330 }
331
332 for (int i = 1; i < 19; i++)
333 {
334 FormatEx(sBuffer, sizeof(sBuffer), sPath, i + 50);
335 AddFileToDownloadsTable(sBuffer);
336 }
337
338 AddFileToDownloadsTable("sound/h2k/rangi/awans.mp3");
339 PrecacheSound("*/h2k/rangi/awans.mp3", true);
340}
341
342public void OnClientPutInServer(int client)
343{
344 DB_LoadInfo(client);
345 LoadClientCookiesFor(client);
346
347 if (g_Cvar_HudEnabled.BoolValue)
348 {
349 g_bHUD[client] = true;
350 }
351 else
352 {
353 g_bHUD[client] = false;
354 }
355}
356
357public void OnClientDisconnect(int client)
358{
359 DB_SaveInfo(client);
360}
361
362public Action DB_Connect()
363{
364 char gB_Error[512];
365 char query[512];
366
367 if (SQL_CheckConfig("h2k_rangi"))
368 {
369 DB = SQL_Connect("h2k_rangi", true, gB_Error, 255);
370
371 if (DB == null)
372 SetFailState("[ERROR ON START] LOGS: %s", gB_Error);
373 }
374 else
375 SetFailState("[BŁĄD W KONFIGURACJI] Nie znaleziono configu h2k_rangi w databases.cfg");
376
377 DB.SetCharset("utf8");
378 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");
379
380 DB.Query(SQLT_Error, query);
381}
382
383public void SQLT_Error(Database db, DBResultSet results, const char[] error, any data)
384{
385 if (results == null)
386 LogError("[ERROR] Error: %s", error);
387}
388
389public void DB_LoadInfo(int client)
390{
391 char authid[64];
392 char query[512];
393
394 GetClientAuthId(client, AuthId_SteamID64, authid, sizeof(authid));
395
396 Format(query, sizeof(query), "SELECT `name`, points, rank, coin, ma_coina, hud_mode FROM h2k_ranks WHERE steamid = '%s'", authid);
397
398 DB.Query(DB_LoadInfoCallback, query, client);
399}
400
401public void DB_LoadInfoCallback(Database db, DBResultSet results, const char[] error, int client)
402{
403 if (results == null)
404 {
405 LogError("Error: %s", error);
406 return;
407 }
408
409 if (results.FetchRow())
410 {
411 results.FetchString(0, PlayerName[client], MAX_NAME_LENGTH);
412 g_iPoints[client] = results.FetchInt(1);
413 g_iRank[client] = results.FetchInt(2);
414 iCoin[client] = results.FetchInt(3);
415 iCoin_Enable[client] = results.FetchInt(4);
416 Hud_Mode[client] = results.FetchInt(5);
417
418 }
419 else
420 {
421 GetClientName(client, PlayerName[client], MAX_NAME_LENGTH);
422 g_iPoints[client] = 0;
423 g_iRank[client] = 0;
424 iCoin[client] = 0;
425 iCoin_Enable[client] = 0;
426 Hud_Mode[client] = 0;
427 }
428}
429
430public void DB_SaveInfo(int client)
431{
432 if (IsFakeClient(client))
433 return;
434
435 char authid[64];
436 char query[512];
437
438 char gB_PlayerName[MAX_NAME_LENGTH];
439 GetClientName(client, gB_PlayerName, MAX_NAME_LENGTH);
440 int iLength = ((strlen(gB_PlayerName) * 2) + 1);
441 char[] gB_EscapedName = new char[iLength];
442 DB.Escape(gB_PlayerName, gB_EscapedName, iLength);
443
444 if (GetClientAuthId(client, AuthId_SteamID64, authid, sizeof(authid)))
445 {
446 DataPack pack = new DataPack();
447 pack.WriteString(authid);
448 pack.WriteString(gB_EscapedName);
449 pack.WriteCell(g_iPoints[client]);
450 pack.WriteCell(g_iRank[client]);
451 pack.WriteCell(iCoin[client]);
452 pack.WriteCell(iCoin_Enable[client]);
453 pack.WriteCell(Hud_Mode[client]);
454
455
456 Format(query, sizeof(query), "SELECT `id` FROM h2k_ranks WHERE `steamid`='%s'", authid);
457 DB.Query(SaveInfoCallB, query, pack);
458 }
459}
460
461public void SaveInfoCallB(Database db, DBResultSet results, const char[] error, DataPack pack)
462{
463 if (results == null)
464 {
465 LogError(error);
466 return;
467 }
468
469 char query[256];
470 char steamid[64];
471 char eName[512];
472
473 int iPunkty = 0;
474 int iRanga = 0;
475 int Moneta = 0;
476 int Moneta_Wlaczona = 0;
477 int Hud_Pozycja = 0;
478
479 pack.Reset();
480
481 pack.ReadString(steamid, sizeof(steamid));
482 pack.ReadString(eName, sizeof(eName));
483
484 iPunkty = pack.ReadCell();
485 iRanga = pack.ReadCell();
486 Moneta = pack.ReadCell();
487 Moneta_Wlaczona = pack.ReadCell();
488 Hud_Pozycja = pack.ReadCell();
489
490 if (results.FetchRow())
491 {
492 int id = results.FetchInt(0);
493
494 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);
495 DB.Query(SQLT_Error, query);
496 }
497 else
498 {
499 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]);
500 DB.Query(SQLT_Error, query);
501 }
502}
503
504public Action PokazTopke(int client, int args)
505{
506 char query[2000];
507
508 DataPack pack = new DataPack();
509 pack.WriteCell(client);
510
511 Format(query, sizeof(query), "SELECT name, points, rank FROM h2k_ranks WHERE 1 ORDER BY points DESC");
512 DB.Query(DB_TopCallback, query, pack);
513
514 return Plugin_Handled;
515}
516
517public void DB_TopCallback(Database db, DBResultSet results, const char[] error, DataPack pack)
518{
519 if (results == null)
520 {
521 LogError("[ERROR] Error: %s", error);
522 return;
523 }
524
525 pack.Reset();
526 int client = pack.ReadCell();
527
528 if (client == 0 || !IsClientInGame(client))
529 return;
530
531 delete pack;
532
533 int i;
534
535 if (client == 0 || !IsClientInGame(client))
536 return;
537
538 Menu menu = new Menu(TOP_Handler, MENU_ACTIONS_ALL);
539 menu.SetTitle("[#TOP] Nick - Ranga - Punkty");
540
541 char menu_item[256];
542
543 while (results.FetchRow())
544 {
545 i++;
546 results.FetchString(0, menu_item, sizeof(menu_item));
547
548 Format(menu_item, sizeof(menu_item), "#%d - %s - %s - [ %d ]", i, menu_item, g_iRankTable[results.FetchInt(2)], results.FetchInt(1));
549 menu.AddItem("", menu_item);
550 }
551
552 if (i == 0)
553 menu.AddItem("no_records", "Wygląda na to, że ranking jest czysty.");
554
555 menu.ExitButton = true;
556 menu.Display(client, 0);
557}
558
559public int TOP_Handler(Menu menu, MenuAction action, int param1, int param2)
560{
561 return 0;
562}
563
564/* << Na końcu mapy >> */
565public void OnMapEnd()
566{
567 LoopClients(i)
568 DB_SaveInfo(i);
569 SDKUnhook(FindEntityByClassname(MAXPLAYERS + 1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
570}
571
572public void LoadClientCookiesFor(int client)
573{
574 char buffer[5];
575 GetClientCookie(client, g_hClientCookieOverlays, buffer, 5);
576 if (!StrEqual(buffer, ""))
577 {
578 g_bClientPrefOverlays[client] = StringToInt(buffer);
579 }
580 if (StrEqual(buffer, "")) {
581 g_bClientPrefOverlays[client] = 1;
582 }
583}
584
585/* << Eventy >> */
586public Action Event_PlayerDeath(Event hEvent, const char[] chName, bool bDontBroadcast)
587{
588 if (GetCurrentPlayers() < g_Cvar_MinimalnaIloscGraczy.IntValue)
589 return;
590
591 bool headshot = GetEventBool(hEvent, "headshot");
592 int attacker = GetClientOfUserId(hEvent.GetInt("attacker"));
593 int client = GetClientOfUserId(hEvent.GetInt("userid"));
594 int iPoints;
595
596 char weapon[64];
597 GetEventString(hEvent, "weapon", weapon, sizeof(weapon));
598 ReplaceString(weapon, sizeof(weapon), "weapon_", "");
599
600 // kys., mogę to zrobić w 1 linijce, ale mi się nie chce ;)
601 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")) {
602 weapon = "knife";
603 }
604
605 if (Warmup() && !g_Cvar_PunktyWarmupEnabled.BoolValue)
606 {
607 return;
608 }
609
610 if (!attacker)
611 return;
612
613 if (attacker == client)
614 return;
615
616 if (!IsValidClient(attacker))
617 return;
618
619 if (VipPlayer(attacker))
620 {
621 iPoints = headshot ? g_Cvar_PunktyHsVip.IntValue:g_Cvar_PunktyKillVip.IntValue;
622 GivePoints(attacker, iPoints);
623 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");
624
625 if (StrEqual(weapon, "knife"))
626 {
627 if (!g_Cvar_PunktyKnifeEnabled.BoolValue)
628 {
629 return;
630 }
631
632 iPoints = g_Cvar_PunktyKnifeKillVip.IntValue;
633 GivePoints(attacker, iPoints);
634 CPrintToChat(attacker, "★ {lightred}[Rangi -> Vip]{yellow} Jako {green}VIP {yellow}otrzymałeś {green}%i {yellow}punktów za zabójstwo z noża", iPoints);
635 }
636 }
637 else
638 {
639 iPoints = headshot ? g_Cvar_PunktyHs.IntValue:g_Cvar_PunktyKill.IntValue;
640 GivePoints(attacker, iPoints);
641 CPrintToChat(attacker, "★ {lightred}[Rangi]{yellow} Otrzymałeś {green}%i {yellow}punkty za {darkred}%s.", iPoints, headshot ? "HeadShota":"zabójstwo");
642
643 if (StrEqual(weapon, "knife"))
644 {
645 if (!g_Cvar_PunktyKnifeEnabled.BoolValue)
646 {
647 return;
648 }
649
650 iPoints = g_Cvar_PunktyKnifeKill.IntValue;
651 GivePoints(attacker, iPoints);
652 CPrintToChat(attacker, "★ {lightred}[Rangi]{yellow} Otrzymałeś {green}%i {yellow}punktów za zabójstwo z noża", iPoints);
653 }
654 }
655
656 if (g_Cvar_TraceniePKTEnabled.BoolValue)
657 {
658 if (VipPlayer(client))
659 {
660 iPoints = g_Cvar_PunktyDeathVip.IntValue;
661 if (g_iPoints[client] < g_Cvar_PunktyDeathVip.IntValue)
662 {
663 return;
664 }
665 else
666 {
667 TakePoints(client, iPoints);
668 CPrintToChat(client, "★ {lightred}[Rangi -> Death_Vip]{yellow} Jako {green}VIP {yellow}straciłeś tylko {green}%i {yellow}punktów za {darkred}Śmierć.", iPoints);
669 }
670 }
671 else
672 {
673 iPoints = g_Cvar_PunktyDeath.IntValue;
674 if (g_iPoints[client] < g_Cvar_PunktyDeath.IntValue)
675 {
676 return;
677 }
678 else
679 {
680 TakePoints(client, iPoints);
681 CPrintToChat(client, "★ {lightred}[Rangi -> Death]{yellow} Straciłeś właśnie {green}%i {yellow}punktów za {darkred}Śmierć", iPoints);
682 }
683 }
684 }
685}
686
687public Action Event_BombPlanted(Handle hEvent, const char[] chName, bool bDontBroadcast)
688{
689 if (!g_Cvar_PunktyBombEnabled.BoolValue)
690 return;
691
692
693 if (GetCurrentPlayers() < g_Cvar_MinimalnaIloscGraczy.IntValue)
694 return;
695
696 int client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
697
698 if (!IsValidClient(client))
699 return;
700
701 int iPoints = VipPlayer(client) ? g_Cvar_PunktyBombPlantedVip.IntValue:g_Cvar_PunktyBombPlanted.IntValue;
702 GivePoints(client, iPoints);
703 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);
704}
705
706public Action Event_BombDefused(Handle hEvent, const char[] chName, bool bDontBroadcast)
707{
708 if (!g_Cvar_PunktyBombEnabled.BoolValue)
709 return;
710
711
712 if (GetCurrentPlayers() < g_Cvar_MinimalnaIloscGraczy.IntValue)
713 return;
714
715 int client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
716
717 if (!IsValidClient(client))
718 return;
719
720 int iPoints = VipPlayer(client) ? g_Cvar_PunktyBombDefusedVip.IntValue:g_Cvar_PunktyBombDefused.IntValue;
721 GivePoints(client, iPoints);
722 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);
723}
724
725public Action Event_RoundMvp(Event event, char[] chName, bool bDontBroadcast)
726{
727 if (!g_Cvar_PunktyMvpEnabled.BoolValue)
728 return;
729
730 if (GetCurrentPlayers() < g_Cvar_MinimalnaIloscGraczy.IntValue)
731 return;
732
733 int client = GetClientOfUserId(GetEventInt(event, "userid"));
734
735 if (!IsValidClient(client))
736 return;
737
738 int iPoints = VipPlayer(client) ? g_Cvar_PunktyMvpPlayerVip.IntValue:g_Cvar_PunktyMvpPlayer.IntValue;
739 GivePoints(client, iPoints);
740 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);
741}
742
743public Action Event_RoundStart(Event event, char[] chName, bool bDontBroadcast)
744{
745 if (GetCurrentPlayers() < g_Cvar_MinimalnaIloscGraczy.IntValue)
746 {
747 CPrintToChatAll("{yellow}============= ★ {olive}Rank System {yellow}★ =============");
748 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);
749 CPrintToChatAll("{yellow}============= ★ {olive}Rank System {yellow}★ =============");
750 }
751}
752
753public Action Event_RoundEnd(Event event, char[] chName, bool bDontBroadcast)
754{
755 if (GetCurrentPlayers() < g_Cvar_MinimalnaIloscGraczy.IntValue)
756 return;
757
758 int winnerTeam = GetEventInt(event, "winner");
759
760 if (Warmup() && !g_Cvar_PunktyWarmupEnabled.BoolValue)
761
762 LoopClients(i)
763 {
764 if (GetClientTeam(i) == winnerTeam)
765 {
766 if (g_Cvar_WygranaRundaEnabled.BoolValue)
767 {
768 int iPoints = VipPlayer(i) ? g_Cvar_PunktyPrzegranaRundaVip.IntValue:g_Cvar_PunktyPrzegranaRunda.IntValue;
769 GivePoints(i, iPoints);
770 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);
771 }
772 else
773 {
774 return;
775 }
776 }
777 else
778 {
779 if (g_Cvar_TraceniePKTEnabled.BoolValue)
780 {
781 if (g_Cvar_PrzegranaRundaEnabled.BoolValue)
782 {
783 int iPoints = VipPlayer(i) ? g_Cvar_PunktyPrzegranaRundaVip.IntValue:g_Cvar_PunktyPrzegranaRunda.IntValue;
784 if (g_iPoints[i] < g_Cvar_PunktyPrzegranaRundaVip.IntValue || g_Cvar_PunktyPrzegranaRunda.IntValue)
785 {
786 return;
787 }
788 else
789 {
790 TakePoints(i, iPoints);
791 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);
792 }
793 }
794 else
795 {
796 return;
797 }
798 }
799 }
800 DB_SaveInfo(i);
801 }
802}
803
804/* << Cmds >>*/
805public Action CMD_MenuGlowne(int client, int args)
806{
807 Menu menuglowne = new Menu(Menu_menuglowne);
808
809 if (g_iRank[client] == sizeof(g_iPointsTable) - 1)
810 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]]);
811 else
812 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]]);
813 menuglowne.AddItem("1", "", ITEMDRAW_SPACER);
814 menuglowne.AddItem("option1", "» Menu Gracza");
815 menuglowne.AddItem("option2", "» Pokaż top graczy na serwerze!");
816 menuglowne.AddItem("option3", "» Zarządzanie HUD!");
817
818 if (GetAdminFlag(GetUserAdmin(client), Admin_Root))
819 menuglowne.AddItem("option5", "» Panel Administratora");
820
821 menuglowne.ExitButton = true;
822 menuglowne.Display(client, 0);
823
824 return Plugin_Handled;
825}
826
827public int Menu_menuglowne(Handle menuglowne, MenuAction action, int client, int itemNum)
828{
829 if (action == MenuAction_Select)
830 {
831 char info[32];
832 GetMenuItem(menuglowne, itemNum, info, sizeof(info));
833
834 if (StrEqual(info, "option1"))
835 CreateMenu_Glowne(client);
836 else if (StrEqual(info, "option2"))
837 PokazTopke(client, 0);
838 else if (StrEqual(info, "option5"))
839 CMD_PanelRangi(client, 0);
840 else if (StrEqual(info, "option3"))
841 CMD_HUDMode(client, 0);
842 }
843 else if (action == MenuAction_End)
844 CloseHandle(menuglowne);
845}
846
847public Action CMD_PanelRangi(int client, int args)
848{
849 if (!g_Cvar_PanelAdministracyjnyEnabled.BoolValue)
850 {
851 CPrintToChat(client, "★ {lightred}[✖] {yellow}Ta opcja została wyłączona przez administratora serwera.");
852 return Plugin_Handled;
853 }
854
855 Menu menu = new Menu(Rangi_MenuHandler);
856 menu.SetTitle("[Rangi] Panel Administratora");
857
858 menu.AddItem("addpts", "Dodaj Punkty");
859 menu.AddItem("rempts", "Zabierz Punkty");
860 menu.AddItem("setrank", "Ustaw Range");
861 menu.AddItem("removeall", "Zresetuj wszystkim graczom rangi/punkty");
862 menu.AddItem("showpoints", "Pokaz Punkty Graczy Online");
863
864 menu.ExitButton = true;
865 menu.Display(client, 60);
866
867 return Plugin_Handled;
868}
869
870public int Rangi_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
871{
872 if (action == MenuAction_Select)
873 {
874 char item[32];
875 bool found = menu.GetItem(param2, item, sizeof(item));
876 if (found)
877 {
878 if (StrEqual(item, "addpts"))
879 {
880 CreateMenu_AdminSelect(param1, 1);
881 }
882 else if (StrEqual(item, "rempts"))
883 {
884 CreateMenu_AdminSelect(param1, 2);
885 }
886 else if (StrEqual(item, "setrank"))
887 {
888 CreateMenu_AdminSelect(param1, 3);
889 }
890 else if (StrEqual(item, "removeall"))
891 {
892 Potwierdz_Reset(param1, 4);
893 }
894 else if (StrEqual(item, "showpoints"))
895 {
896 Menu next = new Menu(Empty_MenuHandler);
897 next.SetTitle("Rangi -> Punkty");
898
899 LoopClients(i)
900 {
901 char format[128];
902 char cid[16];
903 IntToString(i, cid, sizeof cid);
904 char name[MAX_NAME_LENGTH + 1];
905 GetClientName(i, name, sizeof name);
906 Format(format, sizeof format, "%s - %d punktow", name, g_iPoints[i]);
907 next.AddItem(cid, format);
908 }
909
910 next.ExitButton = true;
911 next.Display(param1, 60);
912 }
913 }
914 }
915 else if (action == MenuAction_End)
916 delete menu;
917}
918
919public Action Potwierdz_Reset(int client, int args)
920{
921 Menu menureset = new Menu(Menu_ResetRang);
922 menureset.SetTitle("Czy na pewno chcesz wyczyścyć wszystkie rangi & punkty & odznaki graczy?\nPamiętaj że tej akcji nie możesz cofnąć!");
923 menureset.AddItem("opcja1", "» NIE!");
924 menureset.AddItem("opcja1", "» NIE!");
925 menureset.AddItem("opcja2", "» TAK!!!");
926 menureset.AddItem("opcja1", "» NIE!");
927 menureset.ExitButton = true;
928 menureset.Display(client, 0);
929}
930
931public int Menu_ResetRang(Menu menureset, MenuAction action, int client, int itemNum)
932{
933 if (action == MenuAction_Select)
934 {
935 char info[32];
936 GetMenuItem(menureset, itemNum, info, sizeof(info));
937
938 if (strcmp(info, "opcja1") == 0) {
939 CMD_PanelRangi(client, 0);
940 }
941 else if (strcmp(info, "opcja2") == 0) {
942 Wyczysc_Wszystko(client, 0);
943 }
944 }
945
946 else if (action == MenuAction_End) {
947 CloseHandle(menureset);
948 }
949}
950
951public Action Wyczysc_Wszystko(int client, int args)
952{
953 char query[512];
954 Format(query, sizeof(query), "DELETE FROM `h2k_ranks` WHERE 1=1");
955 DB.Query(DB_LoadInfoCallback, query, client);
956
957 LoopClients(i) {
958 if (IsClientInGame(i))
959 OnClientPutInServer(i);
960 }
961
962 CPrintToChat(client, "★ {lightred}[Rangi]{yellow} Baza została wyczyszczona.");
963 CPrintToChat(client, "★ {lightred}[Rangi]{yellow} .");
964 CPrintToChat(client, "★ {lightred}[Rangi]{yellow} .");
965 CPrintToChat(client, "★ {lightred}[Rangi]{yellow} .");
966 CPrintToChat(client, "★ {lightred}[Rangi]{yellow} Zmień mapę bądź zrestartuj serwer by baza mogła dokładnie wczytywać wszystko na nowo.");
967 return Plugin_Handled;
968}
969
970public Action CreateMenu_Glowne(int client)
971{
972 Menu menu = new Menu(Menu_Glowne);
973 menu.SetTitle("Rangi -> Menu Gracza");
974 menu.AddItem("option1", "» System Punktow");
975 menu.AddItem("option2", "» Ile PKT trzeba na range?");
976 menu.AddItem("option3", "» Zresetuj swoje punkty!");
977 menu.AddItem("option5", "» Wybierz odznake");
978 menu.ExitButton = true;
979 menu.Display(client, 0);
980}
981
982public int Menu_Glowne(Handle menu, MenuAction action, int client, int itemNum)
983{
984 if (action == MenuAction_Select)
985 {
986 char info[32];
987 GetMenuItem(menu, itemNum, info, sizeof(info));
988
989 if (StrEqual(info, "option1"))
990 CreateMenu_PokazPunkty(client);
991 else if (StrEqual(info, "option2"))
992 CreateMenu_PokazMenuRang(client);
993 else if (StrEqual(info, "option3"))
994 CreateMenu_Potwierdzenie(client);
995 else if (StrEqual(info, "option5"))
996 ClientCommand(client, "sm_coin");
997 }
998 else if (action == MenuAction_End)
999 CloseHandle(menu);
1000}
1001
1002public Action CreateMenu_Potwierdzenie(int client)
1003{
1004 Menu menu = new Menu(Menu_Potwierdzenie);
1005 menu.SetTitle("Rangi -> Czy jesteś pewien że chcesz zresetować swoje statystyki?");
1006 menu.AddItem("option1", "» Tak");
1007 menu.AddItem("option2", "» Nie");
1008 menu.ExitButton = true;
1009 menu.Display(client, 0);
1010}
1011
1012public Action CreateMenu_PokazPunkty(int client)
1013{
1014 Menu punkty = new Menu(Menu_Punkty);
1015 punkty.SetTitle("[Rangi -> Menu Punktów] Wybierz jedną z opcji");
1016 punkty.AddItem("option1", "» Zwykły gracz");
1017 punkty.AddItem("option2", "» Gracz VIP");
1018 punkty.AddItem("option3", "Powrót do menu");
1019 punkty.ExitButton = false;
1020 punkty.Display(client, 0);
1021}
1022
1023public Action CreateMenu_PokazMenuRang(int client)
1024{
1025 char sItem[64];
1026 Menu menurang = new Menu(Menu_MenuRang);
1027 menurang.SetTitle("[Rangi -> PKT na daną range]\n");
1028 LoopRanks(i)
1029 {
1030 Format(sItem, sizeof(sItem), "%s - %d punktów\n", g_iRankTable[i], g_iPointsTable[i - 1]);
1031 menurang.AddItem("", sItem);
1032 }
1033 menurang.AddItem("option2", "Wroc do menu");
1034 menurang.ExitButton = false;
1035 menurang.Display(client, 0);
1036}
1037
1038public Action CreateMenu_Punkty(int client)
1039{
1040 Menu punktygracz = new Menu(Menu_PunktyInfo);
1041 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);
1042 punktygracz.AddItem("option1", "Wroc");
1043 punktygracz.ExitButton = false;
1044 punktygracz.Display(client, 0);
1045}
1046
1047public Action CreateMenu_PunktyVip(int client)
1048{
1049 Menu punktyvip = new Menu(Menu_PunktyInfo);
1050 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);
1051 punktyvip.AddItem("option1", "Wroc");
1052 punktyvip.ExitButton = false;
1053 punktyvip.Display(client, 0);
1054}
1055
1056public Action CreateMenu_AdminSelect(int client, int iSelect)
1057{
1058 Menu next = new Menu(SelectPlayer_MenuHandler);
1059 next.SetTitle("Rangi -> Wybor Gracza");
1060
1061 LoopClients(i)
1062 {
1063 char format[64];
1064 Format(format, sizeof format, "%d", i);
1065 char name[MAX_NAME_LENGTH + 1];
1066 GetClientName(i, name, sizeof name);
1067 next.AddItem(format, name);
1068 }
1069
1070 char sInfo[12];
1071 Format(sInfo, sizeof(sInfo), "%d", iSelect);
1072 next.AddItem("-SELECT-", sInfo, ITEMDRAW_IGNORE);
1073 next.ExitButton = true;
1074 next.Display(client, 60);
1075}
1076
1077public Action CreateMenu_AddRemovePoints(int admin, int client, int iSelect)
1078{
1079 Menu next = new Menu(PointAct_MenuHandler);
1080 char frm[128];
1081 char pname[MAX_NAME_LENGTH + 1];
1082 GetClientName(client, pname, sizeof pname);
1083 Format(frm, sizeof frm, "Rangi - %s", pname);
1084 next.SetTitle(frm);
1085
1086 next.AddItem("1", "1 Punkt");
1087 next.AddItem("5", "5 Punktow");
1088 next.AddItem("10", "10 Punktow");
1089 next.AddItem("20", "20 Punktow");
1090 next.AddItem("50", "50 Punktow");
1091 next.AddItem("100", "100 Punktow");
1092 next.AddItem("200", "200 Punktow");
1093 next.AddItem("500", "500 Punktow");
1094 next.AddItem("1000", "1000 Punktow");
1095 next.AddItem("2500", "2500 Punktow");
1096 next.AddItem("5000", "5000 Punktow");
1097
1098 char sInfo[12];
1099
1100 Format(sInfo, sizeof(sInfo), "%d", iSelect);
1101 next.AddItem("-SELECT-", sInfo, ITEMDRAW_IGNORE);
1102 Format(sInfo, sizeof(sInfo), "%d", client);
1103 next.AddItem("-CLIENT-", sInfo, ITEMDRAW_IGNORE);
1104
1105 next.ExitButton = true;
1106 next.Display(admin, 60);
1107}
1108
1109public int PointAct_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
1110{
1111 char sInfo[12], sDane[12];
1112 int iSelect, client;
1113 LoopItemCount(i)
1114 {
1115 menu.GetItem(i, sInfo, sizeof(sInfo), _, sDane, sizeof(sDane));
1116
1117 if (StrEqual(sInfo, "-SELECT-"))
1118 iSelect = StringToInt(sDane);
1119
1120 if (StrEqual(sInfo, "-CLIENT-"))
1121 client = StringToInt(sDane);
1122 }
1123 if (action == MenuAction_Select)
1124 {
1125 char item[32];
1126 menu.GetItem(param2, item, sizeof(item));
1127 if (IsValidClient(client))
1128 {
1129 if (iSelect == 1)
1130 {
1131 g_iPoints[client] += StringToInt(item);
1132 }
1133
1134 else if (iSelect == 2)
1135 {
1136 if (g_iPoints[client] < StringToInt(item))
1137 {
1138 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]);
1139 }
1140 }
1141 else
1142 {
1143 g_iPoints[client] -= StringToInt(item);
1144 }
1145
1146 CreateMenu_AddRemovePoints(param1, client, iSelect);
1147 CheckRank(client);
1148 }
1149 }
1150 else if (action == MenuAction_End)
1151 delete menu;
1152}
1153
1154public int Menu_Potwierdzenie(Handle menu, MenuAction action, int client, int itemNum)
1155{
1156 if (action == MenuAction_Select)
1157 {
1158 char info[32];
1159 GetMenuItem(menu, itemNum, info, sizeof(info));
1160
1161 if (StrEqual(info, "option1"))
1162 {
1163 g_iPoints[client] = 0;
1164 CheckRank(client);
1165 CPrintToChat(client, "★ {lightred}[Rangi -> Reset] {yellow}Twoje punkty zostały {green}Pomyślnie {yellow}wyzerowane!");
1166 }
1167 else if (StrEqual(info, "option2"))
1168 CreateMenu_Glowne(client);
1169 }
1170 else if (action == MenuAction_End)
1171 CloseHandle(menu);
1172}
1173
1174public int Menu_Punkty(Handle punkty, MenuAction action, int client, int itemNum)
1175{
1176 if (action == MenuAction_Select)
1177 {
1178 char info[32];
1179 GetMenuItem(punkty, itemNum, info, sizeof(info));
1180
1181 if (StrEqual(info, "option1"))
1182 CreateMenu_Punkty(client);
1183 else if (StrEqual(info, "option2"))
1184 CreateMenu_PunktyVip(client);
1185 else if (StrEqual(info, "option3"))
1186 CreateMenu_Glowne(client);
1187 }
1188 else if (action == MenuAction_End)
1189 CloseHandle(punkty);
1190}
1191
1192public int Menu_PunktyInfo(Handle punktyvip, MenuAction action, int client, int itemNum)
1193{
1194 if (action == MenuAction_Select)
1195 {
1196 char info[32];
1197 GetMenuItem(punktyvip, itemNum, info, sizeof(info));
1198
1199 if (StrEqual(info, "option1"))
1200 CreateMenu_PokazPunkty(client);
1201 }
1202 else if (action == MenuAction_End)
1203 CloseHandle(punktyvip);
1204}
1205
1206public int Menu_MenuRang(Handle menurang, MenuAction action, int client, int itemNum)
1207{
1208 if (action == MenuAction_Select)
1209 {
1210 char info[32];
1211 GetMenuItem(menurang, itemNum, info, sizeof(info));
1212
1213 if (StrEqual(info, "option2"))
1214 CreateMenu_Glowne(client);
1215 }
1216 else if (action == MenuAction_End)
1217 CloseHandle(menurang);
1218}
1219
1220public int SelectPlayer_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
1221{
1222 char sInfo[12], sDane[12];
1223 int iSelect;
1224 LoopItemCount(i)
1225 {
1226 menu.GetItem(i, sInfo, sizeof(sInfo), _, sDane, sizeof(sDane));
1227 if (StrEqual(sInfo, "-SELECT-"))
1228 iSelect = StringToInt(sDane);
1229 }
1230 if (action == MenuAction_Select)
1231 {
1232 char item[32];
1233 bool found = menu.GetItem(param2, item, sizeof(item));
1234 if (found)
1235 {
1236 int client = StringToInt(item);
1237 if (IsValidClient(client))
1238 {
1239 if (iSelect != 3)
1240 CreateMenu_AddRemovePoints(param1, client, iSelect);
1241 else
1242 {
1243 Menu next = new Menu(SetRank_MenuHandler);
1244 char frm[128];
1245 char pname[MAX_NAME_LENGTH + 1];
1246 GetClientName(client, pname, sizeof pname);
1247 Format(frm, sizeof frm, "Rangi - %s", pname);
1248 next.SetTitle(frm);
1249
1250 char sNum[12];
1251 LoopRanks(i)
1252 {
1253 Format(sNum, sizeof(sNum), "%d", i);
1254 next.AddItem(sNum, g_iRankTable[i]);
1255 }
1256 Format(sNum, sizeof(sNum), "%d", client);
1257 next.AddItem("-CLIENT-", sNum, ITEMDRAW_IGNORE);
1258 next.ExitButton = true;
1259 next.Display(param1, 60);
1260 }
1261 }
1262 }
1263 }
1264 else if (action == MenuAction_End)
1265 delete menu;
1266}
1267
1268public int Empty_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
1269{
1270 if (action == MenuAction_End)delete menu;
1271}
1272
1273public int SetRank_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
1274{
1275 char sInfo[32], sDane[32];
1276 int client;
1277 LoopItemCount(i)
1278 {
1279 menu.GetItem(i, sInfo, sizeof(sInfo), _, sDane, sizeof(sDane));
1280 if (StrEqual(sInfo, "-CLIENT-"))
1281 client = StringToInt(sDane);
1282 }
1283 if (action == MenuAction_Select)
1284 {
1285 char item[32];
1286 menu.GetItem(param2, item, sizeof(item));
1287 if (IsValidClient(client))
1288 {
1289 int iNewRank = StringToInt(item);
1290 CPrintToChat(client, "★ {lightred}[ADMIN]{yellow} Admin zmienił twoją rangę na {lightred}%s", g_iRankTable[iNewRank]);
1291 CPrintToChat(param1, "★ {lightred}[ADMIN]{yellow} Zmieniłeś rangę graczowi {green}%N {yellow}na {lightred}%s", client, g_iRankTable[iNewRank]);
1292 g_iPoints[client] = g_iPointsTable[iNewRank - 1];
1293 CheckRank(client);
1294 }
1295 }
1296 else if (action == MenuAction_End)
1297 delete menu;
1298}
1299
1300public Action Hook_OnThinkPost(int iEnt)
1301{
1302 static int iCoinOffset = -1;
1303 if (iCoinOffset == -1)
1304 iCoinOffset = FindSendPropInfo("CCSPlayerResource", "m_nActiveCoinRank");
1305
1306 int tempCoin[65];
1307 GetEntDataArray(iEnt, iCoinOffset, tempCoin, 65);
1308 for (int i = 1; i <= MaxClients; i++)
1309 {
1310 if (!IsValidClient(i))continue;
1311 if (iCoin_Enable[i])
1312 tempCoin[i] = g_TablicaID[iCoin[i]];
1313 }
1314
1315 for (int i = 1; i <= MaxClients; i++)
1316 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.
1317
1318 SetEntDataArray(iEnt, iCoinOffset, tempCoin, 65, 4, true);
1319 Handle hBuffer = StartMessageAll("ServerRankRevealAll");
1320 if (hBuffer == null)
1321 PrintToServer("ServerRankRevealAll = INVALID_HANDLE");
1322 else
1323 EndMessage();
1324}
1325
1326public Action CMD_DodajPkt(int client, int args)
1327{
1328 if (args < 2)
1329 {
1330 ReplyToCommand(client, "★ [ADMIN] Uzycie: sm_dodajpkt <#userid|Nick> [Ilosc]");
1331 return Plugin_Handled;
1332 }
1333
1334 char arg2[10];
1335 GetCmdArg(2, arg2, sizeof(arg2));
1336 int ilosc = StringToInt(arg2);
1337 char strTarget[32]; GetCmdArg(1, strTarget, sizeof(strTarget));
1338
1339 char strTargetName[MAX_TARGET_LENGTH];
1340 int TargetList[MAXPLAYERS], TargetCount;
1341 bool TargetTranslate;
1342
1343 if ((TargetCount = ProcessTargetString(strTarget, client, TargetList, MAXPLAYERS, COMMAND_FILTER_CONNECTED,
1344 strTargetName, sizeof(strTargetName), TargetTranslate)) <= 0)
1345 {
1346 ReplyToTargetError(client, TargetCount);
1347 return Plugin_Handled;
1348 }
1349
1350 for (int i = 0; i < TargetCount; i++)
1351 {
1352 int iClient = TargetList[i];
1353 if (IsClientInGame(iClient))
1354 {
1355 char name[32];
1356 char Admin_Name[32];
1357 GetClientName(iClient, name, sizeof(name));
1358 GetClientName(client, Admin_Name, sizeof(Admin_Name));
1359
1360 if (ilosc == 0)
1361 {
1362 CPrintToChat(client, "★ {lightred}[ADMIN]{yellow} Liczba punktów rangi musi być większa od{darkred} 0.");
1363 g_iPoints[iClient] += ilosc;
1364 }
1365
1366 if (ilosc > 0)
1367 {
1368 CPrintToChat(client, "★ {lightred}[ADMIN]{yellow} Dales {green}%i{yellow} punktów rangi graczowi {lightred}%s", ilosc, name);
1369 g_iPoints[iClient] += ilosc;
1370 CheckRank(client);
1371 }
1372 }
1373 }
1374 return Plugin_Continue;
1375}
1376
1377public Action CMD_HUD(int client, int args)
1378{
1379 if (!IsValidClient(client))
1380 return Plugin_Handled;
1381
1382 g_bHUD[client] = !g_bHUD[client];
1383 CPrintToChat(client, "HUD \x04%s\x01.", g_bHUD[client] ? "{green}[✔] {yellow}Wlaczony" : "{darkred}[✖] {yellow}Wylaczony");
1384
1385 return Plugin_Handled;
1386}
1387
1388public Action CMD_HUDMode(int client, int args)
1389{
1390 Menu menu = new Menu(Menu_HUDMode);
1391 menu.SetTitle("[HUD] Wybierz jedną z opcji, jak chciałbyś mieć wyświetlany HUD!");
1392 menu.AddItem("option1", "[ OLD ] Standardowy czyli na środku ekranu w hintbox");
1393 menu.AddItem("option2", "[ NEW ] Pod radarem, różne kolory.");
1394 menu.AddItem("option3", "[ ON/OFF ] Wyłącz/Włącz HUD");
1395 menu.Display(client, MENU_TIME_FOREVER);
1396}
1397
1398public int Menu_HUDMode(Handle menu, MenuAction action, int client, int itemNum)
1399{
1400 if (action == MenuAction_Select)
1401 {
1402 char info[32];
1403 GetMenuItem(menu, itemNum, info, sizeof(info));
1404
1405 if (strcmp(info, "option1") == 0) {
1406 Hud_Mode[client] = 0;
1407 CPrintToChat(client, "★ {lightred}[H2K -> HudMode] {yellow}Ustawiłeś pozycję swojego HUD jako: {darkred}STANDARDOWE");
1408 DB_SaveInfo(client);
1409 }
1410
1411 else if (strcmp(info, "option2") == 0) {
1412 Hud_Mode[client] = 1;
1413 CPrintToChat(client, "★ {lightred}[H2K -> HudMode] {yellow}Ustawiłeś pozycję swojego HUD jako: {darkred}NOWY!");
1414 DB_SaveInfo(client);
1415 }
1416
1417 else if (strcmp(info, "option3") == 0) {
1418 CMD_HUD(client, 0);
1419 }
1420
1421 else if (action == MenuAction_End) {
1422 CloseHandle(menu);
1423 }
1424 }
1425}
1426
1427public Action Timer_UpdateHUD(Handle Timer)
1428{
1429 LoopClients(i)
1430 {
1431 if (!g_bHUD[i])
1432 continue;
1433 UpdateHUD(i);
1434 }
1435 return Plugin_Continue;
1436}
1437
1438public void UpdateHUD(int client)
1439{
1440 if (Hud_Mode[client] == 0)
1441 {
1442 char sHintText[512];
1443
1444 char forum[32];
1445 g_Cvar_ForumName.GetString(forum, sizeof(forum));
1446
1447 if (IsPlayerAlive(client))
1448 {
1449 Format(sHintText, sizeof(sHintText), "%s<font color='#FFF'>Forum: <font color='#CA351B'>%s\n", sHintText, forum);
1450 Format(sHintText, sizeof(sHintText), "%s<font color='#FFF'>Ranga: <font color='#C9AE28'>%s\n", sHintText, g_iRankTable[g_iRank[client]]);
1451 Format(sHintText, sizeof(sHintText), "%s<font color='#FFF'>Coin: <font color='#C9AE28'>%s\n", sHintText, g_TablicaOdznak[iCoin[client]]);
1452 Format(sHintText, sizeof(sHintText), "%s<font color='#FFF'>VIP: <font color='#C9AE28'>%s</font>\n", sHintText, VipPlayer(client) ? "TAK" : "BRAK");
1453 }
1454 else
1455 {
1456 int spect = GetEntProp(client, Prop_Send, "m_iObserverMode");
1457 if (spect == 4 || spect == 5)
1458 {
1459 int target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
1460 if (target != -1 && IsValidClient(target))
1461 {
1462 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]);
1463 }
1464 }
1465 }
1466 PrintHintText(client, sHintText);
1467 }
1468 else if (Hud_Mode[client] == 1)
1469 {
1470 if (IsPlayerAlive(client))
1471 {
1472 SetHudTextParams(0.02, 0.37, 1.0, 255, 0, 0, 255, 0, 10.0, 0.0, 0.0);
1473 ShowHudText(client, 6, "(- [ Twoje Statystyki ] -)");
1474 SetHudTextParams(0.02, 0.40, 1.0, 0, 162, 232, 255, 0, 10.0, 0.0, 0.0);
1475 ShowHudText(client, 7, "(- Aktualna ranga: [ %s ] -)", g_iRankTable[g_iRank[client]]);
1476 SetHudTextParams(0.02, 0.43, 1.0, 6, 231, 1, 255, 0, 10.0, 0.0, 0.0);
1477 ShowHudText(client, 8, "(- Ilość punktów [ %d ] -)\n(- Odznaka [ %s ] -)", g_iPoints[client], g_TablicaOdznak[iCoin[client]]);
1478 }
1479 else
1480 {
1481 int spect = GetEntProp(client, Prop_Send, "m_iObserverMode");
1482 if (spect == 4 || spect == 5)
1483 {
1484 int target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
1485 if (target != -1 && IsValidClient(target))
1486 {
1487 SetHudTextParams(0.02, 0.37, 1.0, 255, 0, 0, 255, 0, 10.0, 0.0, 0.0);
1488 ShowHudText(client, 6, "(- Statystyki Gracza -)");
1489 SetHudTextParams(0.02, 0.40, 1.0, 0, 162, 232, 255, 0, 10.0, 0.0, 0.0);
1490 ShowHudText(client, 7, "(- Aktualna ranga: [ %s ] -)", g_iRankTable[g_iRank[target]]);
1491 SetHudTextParams(0.02, 0.43, 1.0, 6, 231, 1, 255, 0, 10.0, 0.0, 0.0);
1492 ShowHudText(client, 8, "(- Ilość punktów [ %d ] -)\n(- Odznaka [ %s ] -)", g_iPoints[target], g_TablicaOdznak[iCoin[target]]);
1493 }
1494 }
1495 }
1496 }
1497}
1498
1499public Action Timer_DeleteOverlay(Handle timer, any client)
1500{
1501 if (IsValidClient(client))
1502 ClientCommand(client, "r_screenoverlay \"%s\"", "");
1503}
1504
1505public Action CMD_ShowOverlayPrefs(int client, int args)
1506{
1507 ShowOVMenu(client);
1508 return Plugin_Handled;
1509}
1510
1511public ShowOVMenu(client)
1512{
1513 Menu menu = new Menu(MenuHandlerOverlays);
1514 menu.SetTitle("H2K_Rangi - OV EDITION");
1515 menu.AddItem("g_bClientPrefOverlays[client] == 1", "Wyłącz/Włącz overlaye.");
1516 menu.ExitButton = true;
1517 menu.Display(client, MENU_TIME_FOREVER);
1518}
1519
1520public int OVPrefSelected(int client, CookieMenuAction action, any info, char[] buffer, int maxlen)
1521{
1522 if (action == CookieMenuAction_SelectOption)
1523 {
1524 ShowOVMenu(client);
1525 }
1526}
1527
1528public int MenuHandlerOverlays(Handle menu, MenuAction action, int param1, int param2)
1529{
1530 if (action == MenuAction_Select)
1531 {
1532 if (param2 == 0)
1533 {
1534 if (g_bClientPrefOverlays[param1] == 0)
1535 {
1536 g_bClientPrefOverlays[param1] = 1;
1537 CPrintToChat(param1, "{green}[✔] {yellow}Pomyślnie włączyłeś Overlaye!");
1538 }
1539 else
1540 {
1541 g_bClientPrefOverlays[param1] = 0;
1542 CPrintToChat(param1, "{green}[✔] {yellow}Pomyślnie wyłączyłeś Overlaye!");
1543 }
1544 }
1545 char buffer[5];
1546 SetClientCookie(param1, g_hClientCookieOverlays, buffer);
1547 IntToString(g_bClientPrefOverlays[param1], buffer, 5);
1548 CMD_ShowOverlayPrefs(param1, 0);
1549 }
1550 else if (action == MenuAction_End)
1551 {
1552 CloseHandle(menu);
1553 }
1554}
1555
1556/* << Check for ranks>> */
1557void CheckRank(int client)
1558{
1559 bool bRankUp = false;
1560 bool bRankDown = false;
1561
1562 if (!IsValidClient(client))
1563 return;
1564
1565 while (g_iPoints[client] >= g_iPointsTable[g_iRank[client]] && g_iRank[client] < sizeof(g_iPointsTable) - 1)
1566 {
1567 g_iRank[client]++;
1568 bRankUp = true;
1569 }
1570
1571 if (g_iRank[client] > 0)
1572 {
1573 while (g_iRank[client] > 0 && g_iPoints[client] < g_iPointsTable[g_iRank[client] - 1]) // i wasted fucking, 3 days on you...
1574 {
1575 g_iRank[client]--;
1576 bRankDown = true;
1577 }
1578 }
1579
1580 if (bRankUp)
1581 {
1582 CPrintToChat(client, "★ {lightred}[Awans]{yellow} Gratulacje! właśnie awansowałeś na range: {green}%s", g_iRankTable[g_iRank[client]]);
1583 EmitSoundToClient(client, "*/h2k/rangi/awans.mp3");
1584 CPrintToChatAll("{yellow}============= ★ {olive}Rank System {yellow}★ =============");
1585
1586 if (g_bClientPrefOverlays[client])
1587 {
1588 char sBuffer[32];
1589 Format(sBuffer, sizeof(sBuffer), "h2k_overlays/rank_%d", g_iRank[client]);
1590 ClientCommand(client, "r_screenoverlay \"%s\"", sBuffer);
1591 CreateTimer(2.5, Timer_DeleteOverlay, client);
1592 }
1593 }
1594
1595 if (bRankDown)
1596 {
1597 CPrintToChat(client, "★ {lightred}[[Spadek]]{yellow} UPS! Właśnie spadłeś do rangi: {green}%s", g_iRankTable[g_iRank[client]]);
1598 ClientCommand(client, "play */UI/armsrace_demoted.wav");
1599
1600 if (g_bClientPrefOverlays[client])
1601 {
1602 char sBuffer[32];
1603 Format(sBuffer, sizeof(sBuffer), "h2k_overlays/rank_%d", g_iRank[client]);
1604 ClientCommand(client, "r_screenoverlay \"%s\"", sBuffer);
1605 CreateTimer(2.5, Timer_DeleteOverlay, client);
1606 }
1607 }
1608}
1609
1610public Action Timer_AD(Handle timer)
1611{
1612 CPrintToChatAll("{yellow}============= ★ {olive}Rank System {yellow}★ =============");
1613 CPrintToChatAll("★ {lightred}[RankSystem]{yellow} Licencjonowany plugin RankSystem stworzony przez Mesharsky!.");
1614 CPrintToChatAll("{yellow}============= ★ {olive}Rank System {yellow}★ =============");
1615}
1616
1617/* << Stocks / Bolls >> */
1618stock int GetCurrentPlayers() {
1619 int count;
1620 LoopClients(i) {
1621 if (!IsFakeClient(i)) {
1622 count++;
1623 }
1624 }
1625 return count;
1626}
1627
1628stock void GivePoints(int client, int value)
1629{
1630 g_iPoints[client] += value;
1631 CheckRank(client);
1632}
1633
1634stock void TakePoints(int client, int value)
1635{
1636 if (g_iPoints[client] < value)
1637 {
1638 return;
1639 }
1640 else
1641 {
1642 g_iPoints[client] -= value;
1643 CheckRank(client);
1644 }
1645}
1646
1647stock bool CzyNumerekJestNumerkiem(char[] arg)
1648{
1649 int argl = strlen(arg);
1650 for (int i = 0; i < argl; i++)
1651 {
1652 if (!IsCharNumeric(arg[i]))
1653 {
1654 return false;
1655 }
1656 }
1657 return true;
1658}
1659
1660stock bool VipPlayer(int client)
1661{
1662 int flag = GetFlag();
1663
1664 if (GetUserFlagBits(client) & flag || GetAdminFlag(GetUserAdmin(client), Admin_Root)) {
1665 return true;
1666 } else {
1667 return false;
1668 }
1669}
1670
1671int GetFlag()
1672{
1673 char flag[10];
1674 g_Cvar_VipFlag.GetString(flag, sizeof(flag));
1675
1676 return ReadFlagString(flag);
1677}
1678
1679stock bool Warmup()
1680{
1681 return GameRules_GetProp("m_bWarmupPeriod") != 0;
1682}
1683
1684stock bool IsValidClient(int client)
1685{
1686 if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || IsFakeClient(client))
1687 return false;
1688 return true;
1689}
1690
1691public int Native_GetClientPoints(Handle plugin, int numParams)
1692{
1693 int client = GetNativeCell(1);
1694 return g_iPoints[client];
1695}
1696
1697public int Native_GivePoints(Handle plugin, int numParams)
1698{
1699 int client = GetNativeCell(1);
1700 int points = GetNativeCell(2);
1701
1702 g_iPoints[client] = points;
1703
1704}
1705
1706/* © 2019 Coded with ❤ */