· 8 years ago · May 24, 2018, 08:56 PM
1#include <sdktools>
2#include <sdkhooks>
3#include <cstrike>
4#include <clientprefs>
5#include <multicolors>
6
7ConVar g_Cvar_PluginEnabled = null;
8ConVar g_Cvar_MinimalnaIloscGraczy = null;
9ConVar g_Cvar_PunktyKill = null;
10ConVar g_Cvar_PunktyKillVip = null;
11ConVar g_Cvar_PunktyHs = null;
12ConVar g_Cvar_PunktyHsVip = null;
13ConVar g_Cvar_PunktyBombPlanted = null;
14ConVar g_Cvar_PunktyBombPlantedVip = null;
15ConVar g_Cvar_PunktyBombDefused = null;
16ConVar g_Cvar_PunktyBombDefusedVip = null;
17ConVar g_Cvar_PunktyWygranaRundaVip = null;
18ConVar g_Cvar_PunktyWygranaRunda = null;
19ConVar g_Cvar_PunktyMvpPlayerVip = null;
20ConVar g_Cvar_PunktyMvpPlayer = null;
21bool g_bHUD[66];
22Handle g_hSql = null;
23int g_MinimalnaIloscGraczy = 0;
24int g_iPoints[66];
25int g_iRank[66];
26int iColor[4] = { 254, 127, 0, 100 };
27int g_iRankTable[19] = {25, 50, 100, 250, 500, 750, 1000, 1250, 1500, 2000, 2500, 5000, 7500, 10000, 12500, 15000, 17000, 24000, 24000};
28char g_sRanksNames[19][] = {
29 "Unranked",
30 "Silver 1",
31 "Silver 2",
32 "Silver 3",
33 "Silver 4",
34 "Silver Elite",
35 "Silver Elite Master",
36 "Gold Nova 1",
37 "Gold Nova 2",
38 "Gold Nova 3",
39 "Gold Nova Master",
40 "Master Guardian 1",
41 "Master Guardian 2",
42 "Master Guardian Elite",
43 "DMG",
44 "Legendary Eagle",
45 "Legendary Eagle Master",
46 "Supreme Master First Class",
47 "The Global Elite"
48};
49
50public Plugin myinfo = {
51
52 name = "Ranking",
53 description = "Punkty, rangi - ranking",
54 author = "fabko",
55 version = "1.0",
56 url = "fabko.ovh"
57};
58
59public void OnPluginStart()
60{
61 CreateTimer(0.1, Timer_UpdateHUD, 0, 1);
62 HookEvent("round_start", Event_RoundStart, EventHookMode_Post);
63 HookEvent("round_end", Event_RoundEnd, EventHookMode_Post);
64 HookEvent("round_mvp", Event_RoundMvp, EventHookMode_Post);
65 HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post);
66 HookEvent("bomb_planted", Event_BombPlanted, EventHookMode_Post);
67 HookEvent("bomb_defused", Event_BombDefused, EventHookMode_Post);
68 RegConsoleCmd("sm_info", CMD_HUD);
69 RegConsoleCmd("sm_ranga", CMD_MenuGlowne);
70 RegConsoleCmd("sm_lvl", CMD_MenuGlowne);
71 RegConsoleCmd("sm_menu", CMD_MenuGlowne);
72 RegAdminCmd("sm_panel", CMD_PanelRangi, 16384, "", "", 0);
73 g_Cvar_PluginEnabled = CreateConVar("rangi_enabled", "1", "Włączyć czy wyłączyć rangi?", 0, false, 0.0, false, 0.0);
74 g_Cvar_MinimalnaIloscGraczy = CreateConVar("rangi_ilosc_graczy", "2", "Ile musi być graczy żeby punkty działały.", 0, true, 0.0, false, 0.0);
75 g_Cvar_PunktyKill = CreateConVar("rangi_kill", "1", "Ila dodawać punktów za zabójstwo", 0, false, 0.0, false, 0.0);
76 g_Cvar_PunktyKillVip = CreateConVar("rangi_kill_vip", "2", "Ile dodawać punktów za zabójstwo (VIP)", 0, false, 0.0, false, 0.0);
77 g_Cvar_PunktyHs = CreateConVar("rangi_kill_hs", "3", "Ile dodawać punktów za headshot'a?", 0, false, 0.0, false, 0.0);
78 g_Cvar_PunktyHsVip = CreateConVar("rangi_kill_hs_vip", "5", "Ile dodawać punktów za headshot'a (VIP)", 0, false, 0.0, false, 0.0);
79 g_Cvar_PunktyBombPlanted = CreateConVar("rangi_bomb_planted", "2", "Ile dodawać punktów za podłożenie bomby", 0, false, 0.0, false, 0.0);
80 g_Cvar_PunktyBombPlantedVip = CreateConVar("rangi_bomb_planted_vip", "5", "Ile dodawać pkt za podłożenie bomby (VIP)", 0, false, 0.0, false, 0.0);
81 g_Cvar_PunktyBombDefused = CreateConVar("rangi_bomb_defused", "2", "Ile dodawać punktów za rozbrojenie bomby", 0, false, 0.0, false, 0.0);
82 g_Cvar_PunktyBombDefusedVip = CreateConVar("rangi_bomb_defused_vip", "5", "Ile dodawać pkt za rozbrojenie bomby (VIP)", 0, false, 0.0, false, 0.0);
83 g_Cvar_PunktyWygranaRunda = CreateConVar("wygrana_runda", "2", "Ile dodawać punktów za wygranie rundy", 0, false, 0.0, false, 0.0);
84 g_Cvar_PunktyWygranaRundaVip = CreateConVar("wygrana_runda_vip", "4", "Ile dodawać punktów za wygranie rundy (VIP)", 0, false, 0.0, false, 0.0);
85 g_Cvar_PunktyMvpPlayer = CreateConVar("mvp_player", "3", "Ile dostanie punktów gracz MVP?", 0, false, 0.0, false, 0.0);
86 g_Cvar_PunktyMvpPlayerVip = CreateConVar("mvp_player_vip", "5", "Ile dostanie punktów gracz MVP (VIP)?", 0, false, 0.0, false, 0.0);
87 AutoExecConfig(true, "FK_Ranking", "sourcemod");
88 DB_Connect();
89}
90
91public void OnConfigsExecuted()
92{
93 g_MinimalnaIloscGraczy = GetConVarInt(g_Cvar_MinimalnaIloscGraczy);
94}
95
96public void OnMapStart()
97{
98 SDKHook(FindEntityByClassname(66, "cs_player_manager"), view_as<SDKHookType>(21), Hook_OnThinkPost);
99 AddFileToDownloadsTable("sound/h2k/rangi/awans.mp3");
100 PrecacheSound("*/h2k/rangi/awans.mp3", true);
101}
102
103public void OnMapEnd()
104{
105 for (int i = 1; i <= MaxClients; i++)
106 {
107 if (IsClientInGame(i))
108 {
109 DB_SaveInfo(i);
110 }
111 }
112 SDKUnhook(FindEntityByClassname(66, "cs_player_manager"), view_as<SDKHookType>(21), Hook_OnThinkPost);
113}
114
115public void OnClientPutInServer(int client)
116{
117 if (!g_Cvar_PluginEnabled.BoolValue)
118 {
119 return;
120 }
121 g_iRank[client] = 0;
122 g_iPoints[client] = 0;
123 g_bHUD[client] = true;
124 DB_LoadInfo(client);
125}
126
127public void OnClientDisconnect(int client)
128{
129 if (!g_Cvar_PluginEnabled.BoolValue)
130 {
131 return;
132 }
133 DB_SaveInfo(client);
134 g_iRank[client] = 0;
135 g_iPoints[client] = 0;
136}
137
138public Action DB_Connect()
139{
140 if (!g_Cvar_PluginEnabled.BoolValue)
141 {
142 return;
143 }
144 if (SQL_CheckConfig("fk_rangi"))
145 {
146 char DBBuffer[512];
147 g_hSql = SQL_Connect("fk_rangi", true, DBBuffer, 512);
148 if (g_hSql == null)
149 {
150 LogError("[FK] Could not connect: %s", DBBuffer);
151 }
152 else
153 {
154 SQL_LockDatabase(g_hSql);
155 SQL_FastQuery(g_hSql, "CREATE TABLE IF NOT EXISTS `fk_user` (`auth_data` VARCHAR(64) NOT NULL, `name` VARCHAR(64) NOT NULL, `points` INT NOT NULL, `rank` INT NOT NULL, UNIQUE KEY `auth_data` (`auth_data`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;", -1);
156 SQL_UnlockDatabase(g_hSql);
157 }
158 }
159 else
160 {
161 SetFailState("Nie mozna odnalezc konfiguracji 'fk_rangi' w databases.cfg.");
162 }
163}
164
165public void DB_LoadInfo(int client)
166{
167 if (g_hSql)
168 {
169 char _authid[64];
170 GetClientAuthId(client, AuthId_Steam2, _authid, 63, true);
171 char sQuery[256];
172 Format(sQuery, 256, "SELECT points, rank FROM fk_user WHERE auth_data = '%s';", _authid);
173 SQL_LockDatabase(g_hSql);
174 Handle hQuery = SQL_Query(g_hSql, sQuery, -1);
175 if (hQuery == null)
176 {
177 char blad[256];
178 SQL_GetError(g_hSql, blad, 255);
179 LogError("Nie mozna odszukac z tabeli. (blad: %s)", blad);
180 CloseHandle(g_hSql);
181 }
182 else
183 {
184 if (SQL_FetchRow(hQuery))
185 {
186 g_iPoints[client] = SQL_FetchInt(hQuery, 0);
187 g_iRank[client] = SQL_FetchInt(hQuery, 1);
188 }
189 else
190 {
191 g_iRank[client] = 0;
192 g_iPoints[client] = 0;
193 }
194 }
195 CloseHandle(hQuery);
196 SQL_UnlockDatabase(g_hSql);
197 }
198}
199
200public void DB_SaveInfo(int client)
201{
202 if (!IsValidClient(client) || IsFakeClient(client))
203 {
204 return;
205 }
206 char authid[64];
207 if (!GetClientAuthId(client, AuthId_Steam2, authid, 64, true))
208 {
209 return;
210 }
211 char nick[64];
212 char EscapedName[64];
213 GetClientName(client, nick, 64);
214 SQL_EscapeString(g_hSql, nick, EscapedName, 64);
215 char sQuery[5000];
216 Format(sQuery, 5000, "INSERT INTO `fk_user` (auth_data, name, points, rank) VALUES ('%s', '%s', %d, %d) ON DUPLICATE KEY UPDATE name=VALUES(name), points=VALUES(points), rank=VALUES(rank)", authid, EscapedName, g_iPoints[client], g_iRank[client]);
217 SQL_TQuery(g_hSql, DB_SaveInfoCallback, sQuery, 0, DBPrio_Normal);
218}
219
220public Action PokazTopke(int client, int args)
221{
222 char query[256];
223 DataPack info_pack = new DataPack();
224 info_pack.WriteCell(client);
225 Format(query, 256, "SELECT name, points, rank FROM fk_user WHERE 1 ORDER BY points DESC");
226 SQL_TQuery(g_hSql, DB_TopCallback, query, info_pack, DBPrio_Normal);
227 return Plugin_Handled;
228}
229
230public void DB_TopCallback(Handle owner, Handle hndl, char[] error, DataPack info_pack)
231{
232 if (hndl == null)
233 {
234 LogError("[TOP] Query failed! %s", error);
235 return;
236 }
237 info_pack.Reset(false);
238 int client = info_pack.ReadCell();
239 if (client == 0 || !IsClientInGame(client))
240 {
241 return;
242 }
243 delete info_pack;
244 int i = 0;
245 Menu menu = new Menu(TOP_Handler, MENU_ACTIONS_ALL);
246 menu.SetTitle("Pozycja - Nick - Ranga - Punkty");
247 char menu_item[256];
248 while(SQL_FetchRow(hndl))
249 {
250 i++;
251 SQL_FetchString(hndl, 0, menu_item, 256);
252 Format(menu_item, 256, "#%d - %s - %s - [ %d ]", i, menu_item, g_sRanksNames[SQL_FetchInt(hndl, 2)], SQL_FetchInt(hndl, 1));
253 menu.AddItem("", menu_item, 0);
254 }
255 if (i == 0)
256 {
257 menu.AddItem("no_records", "Ranking jest pusty.", 0);
258 }
259 menu.ExitButton = true;
260 menu.Display(client, 0);
261}
262
263public int TOP_Handler(Menu menu, MenuAction action, int param1, int param2)
264{
265 return 0;
266}
267
268public Action Potwierdz_Reset(int client, int args)
269{
270 Menu menureset = new Menu(Menu_ResetRang, MENU_ACTIONS_DEFAULT);
271 menureset.SetTitle("Czy na pewno chcesz wyczyścyć wszystkie rangi i punkty?\nNie możesz cofnąć tej akcji!");
272 menureset.AddItem("opcja2", "Tak!", 0);
273 menureset.AddItem("opcja1", "Nie!", 0);
274 menureset.ExitButton = true;
275 menureset.Display(client, 0);
276}
277
278public int Menu_ResetRang(Menu menureset, MenuAction action, int client, int itemNum)
279{
280 if (action == view_as<MenuAction>(4))
281 {
282 char info[32];
283 GetMenuItem(menureset, itemNum, info, 32);
284 if (strcmp(info, "opcja1", true) == 0)
285 {
286 CMD_PanelRangi(client, 0);
287 }
288 else
289 {
290 if (strcmp(info, "opcja2", true) == 0)
291 {
292 Wyczysc_Wszystko(client, 0);
293 }
294 }
295 }
296 else
297 {
298 if (action == view_as<MenuAction>(16))
299 {
300 CloseHandle(menureset);
301 }
302 }
303}
304
305public Action Wyczysc_Wszystko(int client, int args)
306{
307 char sQuery[1000];
308 Format(sQuery, 1000, "DELETE FROM `fk_user` WHERE 1=1");
309 SQL_TQuery(g_hSql, DB_SaveInfoCallback, sQuery, 0, DBPrio_Normal);
310 for (int i = 1; i <= MaxClients; i++)
311 {
312 if (IsClientInGame(i))
313 {
314 if (IsClientInGame(i))
315 {
316 OnClientPutInServer(i);
317 }
318 }
319 }
320 PrintToChat(client, " \x07★ [AWP -> Ranking] \x05Ranking został wyczyszczony!");
321 return Plugin_Handled;
322}
323
324public int DB_SaveInfoCallback(Handle owner, Handle query, char[] error, any data)
325{
326 if (query == null)
327 {
328 LogError("[RANKS] Failed to save client info (error: %s)", error);
329 return;
330 }
331}
332
333public Action Event_PlayerDeath(Event hEvent, char[] chName, bool bDontBroadcast)
334{
335 if (!g_Cvar_PluginEnabled.BoolValue)
336 {
337 return;
338 }
339 if (GetCurrentPlayers() < g_MinimalnaIloscGraczy)
340 {
341 return;
342 }
343 bool headshot = GetEventBool(hEvent, "headshot", false);
344 int attacker = GetClientOfUserId(hEvent.GetInt("attacker", 0));
345 int client = GetClientOfUserId(hEvent.GetInt("userid", 0));
346 int iPoints = 0;
347 if (GameRules_GetProp("m_bWarmupPeriod", 4, 0) == 1)
348 {
349 return;
350 }
351 if (!attacker)
352 {
353 return;
354 }
355 if (attacker == client)
356 {
357 return;
358 }
359 if (!IsValidClient(attacker))
360 {
361 return;
362 }
363 if (IsPlayerVIP(attacker))
364 {
365 iPoints = headshot ? (GetConVarInt(g_Cvar_PunktyHsVip)) : (GetConVarInt(g_Cvar_PunktyKillVip));
366 GivePoints(attacker, iPoints);
367 PrintToChat(attacker, " \x07★ [AWP -> VIP] \x05Otrzymałeś \x04%i \x05punktów za \x04%s\x05!", iPoints, headshot ? "HS`a" : "zabójstwo");
368 }
369 else
370 {
371 iPoints = headshot ? (GetConVarInt(g_Cvar_PunktyHs)) : (GetConVarInt(g_Cvar_PunktyKill));
372 GivePoints(attacker, iPoints);
373 PrintToChat(attacker, " \x07★ [AWP -> Rank] \x05Dostałeś \x04i \x05punkty za \x04%s\x05!", iPoints, headshot ? "HS`a" : "zabójstwo");
374 }
375}
376
377public Action Event_BombPlanted(Handle hEvent, char[] chName, bool bDontBroadcast)
378{
379 if (!g_Cvar_PluginEnabled.BoolValue)
380 {
381 return;
382 }
383 if (GetCurrentPlayers() < g_MinimalnaIloscGraczy)
384 {
385 return;
386 }
387 int client = GetClientOfUserId(GetEventInt(hEvent, "userid", 0));
388 if (!IsValidClient(client))
389 {
390 return;
391 }
392 int iPoints = (IsPlayerVIP(client)) ? (GetConVarInt(g_Cvar_PunktyBombPlantedVip)) : (GetConVarInt(g_Cvar_PunktyBombPlanted));
393 GivePoints(client, iPoints);
394 PrintToChat(client, "\x05%s \x04%i \x05punktów za \x04podłożenie bomby\x05!", (IsPlayerVIP(client)) ? " \x07★ [AWP -> VIP] \x05Otrzymałeś" : " \x07★ [AWP -> Rank] \x05Otrzymałeś", iPoints);
395}
396
397public Action Event_BombDefused(Handle hEvent, char[] chName, bool bDontBroadcast)
398{
399 if (!g_Cvar_PluginEnabled.BoolValue)
400 {
401 return;
402 }
403 if (GetCurrentPlayers() < g_MinimalnaIloscGraczy)
404 {
405 return;
406 }
407 int client = GetClientOfUserId(GetEventInt(hEvent, "userid", 0));
408 if (!IsValidClient(client))
409 {
410 return;
411 }
412 int iPoints = (IsPlayerVIP(client)) ? (GetConVarInt(g_Cvar_PunktyBombDefusedVip)) : (GetConVarInt(g_Cvar_PunktyBombDefused));
413 GivePoints(client, iPoints);
414 CPrintToChat(client, "\x05%s \x04%i \x05punktów za \x04rozbrojenie bomby\x05!", (IsPlayerVIP(client)) ? " \x07★ [AWP -> VIP] \x05Otrzymałeś" : " \x07★ [AWP -> Rank] \x05Otrzymałeś", iPoints);
415}
416
417public Action Event_RoundMvp(Event event, char[] chName, bool bDontBroadcast) // address: 32372
418{
419 if (!g_Cvar_PluginEnabled.BoolValue)
420 {
421 return;
422 }
423 if (GetCurrentPlayers() < g_MinimalnaIloscGraczy)
424 {
425 return;
426 }
427 int client = GetClientOfUserId(GetEventInt(event, "userid", 0));
428 if (!IsValidClient(client))
429 {
430 return;
431 }
432 int iPoints = (IsPlayerVIP(client)) ? (GetConVarInt(g_Cvar_PunktyMvpPlayerVip)) : (GetConVarInt(g_Cvar_PunktyMvpPlayer));
433 GivePoints(client, iPoints);
434 CPrintToChat(client, "\x05%s \x04%i \x05punktów za \x04MVP\x05!", (IsPlayerVIP(client)) ? " \x07★ [AWP -> VIP] \x05Otrzymałeś" : " \x07★ [AWP -> Rank] \x05Otrzymałeś", iPoints);
435}
436
437public Action Event_RoundStart(Event event, char[] chName, bool bDontBroadcast)
438{
439 if (!g_Cvar_PluginEnabled.BoolValue)
440 {
441 return;
442 }
443 if (GetCurrentPlayers() < g_MinimalnaIloscGraczy)
444 {
445 PrintToChatAll(" \x07-----------------------------------------");
446 PrintToChatAll(" \x07★ [AWP -> Ranking] \x05Na serwerze jest \x07zbyt mało\x05 graczy! Potrzeba minimum \x07%i graczy\x05, aby ranking zaczął działać!", GetConVarInt(g_Cvar_MinimalnaIloscGraczy));
447 PrintToChatAll(" \x07-----------------------------------------");
448 }
449}
450
451public Action Event_RoundEnd(Event event, char[] chName, bool bDontBroadcast)
452{
453 if (!g_Cvar_PluginEnabled.BoolValue)
454 {
455 return;
456 }
457 if (GetCurrentPlayers() < g_MinimalnaIloscGraczy)
458 {
459 return;
460 }
461 int winnerTeam = GetEventInt(event, "winner", 0);
462 if (GameRules_GetProp("m_bWarmupPeriod", 4, 0) == 1)
463 {
464 return;
465 }
466 for (int i = 1; i <= MaxClients; i++)
467 {
468 if (IsClientInGame(i))
469 {
470 if (GetClientTeam(i) == winnerTeam)
471 {
472 int iPoints = (IsPlayerVIP(i)) ? (GetConVarInt(g_Cvar_PunktyWygranaRundaVip)) : (GetConVarInt(g_Cvar_PunktyWygranaRunda));
473 GivePoints(i, iPoints);
474 CPrintToChat(i, "\x05%s \x04%i \x05punkty za \x04wygranie rundy\x05!", (IsPlayerVIP(i)) ? " \x07★ [AWP -> VIP] \x05Otrzymałeś" : " \x07★ [AWP -> Rank] \x05Otrzymałeś", iPoints);
475 DB_SaveInfo(i);
476 }
477 }
478 }
479}
480
481public Action CMD_MenuGlowne(int client, int args)
482{
483 Menu menuglowne = new Menu(Menu_menuglowne, MENU_ACTIONS_DEFAULT);
484 if (g_iRank[client] == 18)
485 {
486 menuglowne.SetTitle("Informacje: %N\nRanga: %s\nAktualnie posiadasz: %d punktów", client, g_sRanksNames[g_iRank[client]] ,g_iPoints[client]);
487 }
488 else
489 {
490 menuglowne.SetTitle("Informacje: %N\nMasz aktualnie: %d punktów\nRanga: %s\nAby awansować na rangę %s, musisz zdobyć %d punktów!", client, g_iPoints[client], g_sRanksNames[g_iRank[client]], g_sRanksNames[g_iRank[client] + 1], g_iRankTable[g_iRank[client] + 1]);
491 }
492 menuglowne.AddItem("1", "", 8);
493 menuglowne.AddItem("option1", "Panel gracza", 0);
494 menuglowne.AddItem("option2", "Najlepsi gracze na serwerze", 0);
495 if (GetAdminFlag(GetUserAdmin(client), view_as<AdminFlag>(14), view_as<AdmAccessMode>(1)))
496 {
497 menuglowne.AddItem("option5", "Panel administratora", 0);
498 }
499 menuglowne.ExitButton = true;
500 menuglowne.Display(client, 0);
501}
502
503public Action CMD_PanelRangi(int client, int args)
504{
505 Menu menu = new Menu(Rangi_MenuHandler, MENU_ACTIONS_DEFAULT);
506 menu.SetTitle("[fabko] Panel administracyjny");
507 menu.AddItem("addpts", "Dodawanie punktów", 0);
508 menu.AddItem("rempts", "Odbieranie punktów", 0);
509 menu.AddItem("setrank", "Ustawienie rangi", 0);
510 menu.AddItem("removeall", "Reset na serwerze (rangi & punkty)", 0);
511 menu.AddItem("showpoints", "Punkty graczy online", 0);
512 menu.ExitButton = true;
513 menu.Display(client, 60);
514 return Plugin_Handled;
515}
516
517public Action CreateMenu_Glowne(int client)
518{
519 Menu menu = new Menu(Menu_Glowne, MENU_ACTIONS_DEFAULT);
520 menu.SetTitle("Panel gracza");
521 menu.AddItem("option4", "Wyłącz informację o randze", 0);
522 menu.AddItem("option3", "Zresetuj punkty", 0);
523 menu.AddItem("option1", "System punktów", 0);
524 menu.AddItem("option2", "Wymagana liczba punktów na rangę", 0);
525 menu.ExitButton = true;
526 menu.Display(client, 0);
527}
528
529public Action CreateMenu_Potwierdzenie(int client)
530{
531 Menu menu = new Menu(Menu_Potwierdzenie, MENU_ACTIONS_DEFAULT);
532 menu.SetTitle("Jesteś pewny, że chcesz zresetować swoje statystyki?");
533 menu.AddItem("option1", "Tak!", 0);
534 menu.AddItem("option2", "Nie!", 0);
535 menu.ExitButton = true;
536 menu.Display(client, 0);
537}
538
539public Action CreateMenu_PokazPunkty(int client) // address: 41180
540{
541 Menu punkty = new Menu(Menu_Punkty, MENU_ACTIONS_DEFAULT);
542 punkty.SetTitle("Informacje o punktach");
543 punkty.AddItem("option1", "Zwykły gracz", 0);
544 punkty.AddItem("option2", "Gracz VIP", 0);
545 punkty.AddItem("option3", "Wróć do menu głównego", 0);
546 punkty.ExitButton = false;
547 punkty.Display(client, 0);
548}
549
550public Action CreateMenu_PokazMenuRang(int client)
551{
552 char sItem[64];
553 Menu menurang = new Menu(Menu_MenuRang, MENU_ACTIONS_DEFAULT);
554 menurang.SetTitle("Liczba punktów na konkretną rangę\n");
555 for (int i = 1; i < 19; i++)
556 {
557 Format(sItem, 64, "%s - %d punktów\n", g_sRanksNames[i], g_iRankTable[i + -1]);
558 menurang.AddItem("", sItem, 0);
559 }
560 menurang.AddItem("option2", "Wróć do menu głównego", 0);
561 menurang.ExitButton = false;
562 menurang.Display(client, 0);
563}
564
565public Action CreateMenu_Punkty(int client)
566{
567 Menu punktygracz = new Menu(Menu_PunktyInfo, MENU_ACTIONS_DEFAULT);
568 punktygracz.SetTitle("System punktów - gracz\n\nZwykłe zabójstwo - %i punkt\nZabójstwo w głowę - %i punkty\nPodłożenie bomby - %i punkty\nRozbrojenie bomby - %i punkty\nWygranie rundy - %i punkty", GetConVarInt(g_Cvar_PunktyKill), GetConVarInt(g_Cvar_PunktyHs), GetConVarInt(g_Cvar_PunktyBombPlanted), GetConVarInt(g_Cvar_PunktyBombDefused), GetConVarInt(g_Cvar_PunktyWygranaRunda));
569 punktygracz.AddItem("option1", "Wroc", 0);
570 punktygracz.ExitButton = false;
571 punktygracz.Display(client, 0);
572}
573
574public Action CreateMenu_PunktyVip(int client)
575{
576 Menu punktyvip = new Menu(Menu_PunktyInfo, MENU_ACTIONS_DEFAULT);
577 punktyvip.SetTitle("System punktów - VIP\nZwykłe zabójstwo - %i punkty\nZabójstwo w głowę - %i punktów\nPodłożenie bomby - %i punktów\nRozbrojenie bomby - %i punktów\nWygranie rundy - %i punkty", GetConVarInt(g_Cvar_PunktyKillVip), GetConVarInt(g_Cvar_PunktyHsVip), GetConVarInt(g_Cvar_PunktyBombPlantedVip), GetConVarInt(g_Cvar_PunktyBombDefusedVip), GetConVarInt(g_Cvar_PunktyWygranaRundaVip));
578 punktyvip.AddItem("option1", "Wroc", 0);
579 punktyvip.ExitButton = false;
580 punktyvip.Display(client, 0);
581}
582
583public Action CreateMenu_AdminSelect(int client, int iSelect)
584{
585 Menu next = new Menu(SelectPlayer_MenuHandler, MENU_ACTIONS_DEFAULT);
586 next.SetTitle("Wybierz gracza");
587 for (int i = 1; i <= MaxClients; i++)
588 {
589 if (IsClientInGame(i))
590 {
591 char format[64];
592 Format(format, 64, "%d", i);
593 char name[36];
594 GetClientName(i, name, 33);
595 next.AddItem(format, name, 0);
596 }
597 }
598 char sInfo[12];
599 Format(sInfo, 12, "%d", iSelect);
600 next.AddItem("-SELECT-", sInfo, 6);
601 next.ExitButton = true;
602 next.Display(client, 60);
603}
604
605public Action CreateMenu_AddRemovePoints(int admin, int client, int iSelect) // address: 43464
606{
607 Menu next = new Menu(PointAct_MenuHandler, MENU_ACTIONS_DEFAULT);
608 char frm[128];
609 char pname[36];
610 GetClientName(client, pname, 33);
611 Format(frm, 128, "Rangi - %s", pname);
612 next.SetTitle(frm);
613 next.AddItem("1", "1 Punkt", 0);
614 next.AddItem("5", "5 Punktow", 0);
615 next.AddItem("10", "10 Punktow", 0);
616 next.AddItem("20", "20 Punktow", 0);
617 next.AddItem("50", "50 Punktow", 0);
618 next.AddItem("100", "100 Punktow", 0);
619 next.AddItem("200", "200 Punktow", 0);
620 next.AddItem("500", "500 Punktow", 0);
621 next.AddItem("1000", "1000 Punktow", 0);
622 next.AddItem("2500", "2500 Punktow", 0);
623 next.AddItem("5000", "5000 Punktow", 0);
624 char sInfo[12];
625 Format(sInfo, 12, "%d", iSelect);
626 next.AddItem("-SELECT-", sInfo, 6);
627 Format(sInfo, 12, "%d", client);
628 next.AddItem("-CLIENT-", sInfo, 6);
629 next.ExitButton = true;
630 next.Display(admin, 60);
631}
632
633public int Menu_menuglowne(Handle menuglowne, MenuAction action, int client, int itemNum) // address: 44460
634{
635 if (action == view_as<MenuAction>(4))
636 {
637 char info[32];
638 GetMenuItem(menuglowne, itemNum, info, 32);
639 if (StrEqual(info, "option1", true))
640 {
641 CreateMenu_Glowne(client);
642 }
643 else
644 {
645 if (StrEqual(info, "option2", true))
646 {
647 PokazTopke(client, 0);
648 }
649 else
650 {
651 if (StrEqual(info, "option5", true))
652 {
653 CMD_PanelRangi(client, 0);
654 }
655 }
656 }
657 }
658 else
659 {
660 if (action == view_as<MenuAction>(16))
661 {
662 CloseHandle(menuglowne);
663 }
664 }
665}
666
667public int Menu_Glowne(Handle menu, MenuAction action, int client, int itemNum) // address: 44972
668{
669 if (action == view_as<MenuAction>(4))
670 {
671 char info[32];
672 GetMenuItem(menu, itemNum, info, 32);
673 if (StrEqual(info, "option1", true))
674 {
675 CreateMenu_PokazPunkty(client);
676 }
677 else
678 {
679 if (StrEqual(info, "option2", true))
680 {
681 CreateMenu_PokazMenuRang(client);
682 }
683 else
684 {
685 if (StrEqual(info, "option3", true))
686 {
687 CreateMenu_Potwierdzenie(client);
688 }
689 else
690 {
691 if (StrEqual(info, "option4", true))
692 {
693 ClientCommand(client, "sm_hud");
694 }
695 }
696 }
697 }
698 }
699 else
700 {
701 if (action == view_as<MenuAction>(16))
702 {
703 CloseHandle(menu);
704 }
705 }
706}
707
708public int Menu_Potwierdzenie(Handle menu, MenuAction action, int client, int itemNum) // address: 45644
709{
710 if (action == view_as<MenuAction>(4))
711 {
712 char info[32];
713 GetMenuItem(menu, itemNum, info, 32);
714 if (StrEqual(info, "option1", true))
715 {
716 g_iPoints[client] = 0;
717 CheckRank(client);
718 CPrintToChat(client, " \x07★ [AWP -> Reset] \x05Twoje punkty zostały zresetowane\x04pomyślnie\x05!");
719 }
720 else
721 {
722 if (StrEqual(info, "option2", true))
723 {
724 CreateMenu_Glowne(client);
725 }
726 }
727 }
728 else
729 {
730 if (action == view_as<MenuAction>(16))
731 {
732 CloseHandle(menu);
733 }
734 }
735}
736
737public int Menu_Punkty(Handle punkty, MenuAction action, int client, int itemNum) // address: 46136
738{
739 if (action == view_as<MenuAction>(4))
740 {
741 char info[32];
742 GetMenuItem(punkty, itemNum, info, 32);
743 if (StrEqual(info, "option1", true))
744 {
745 CreateMenu_Punkty(client);
746 }
747 else
748 {
749 if (StrEqual(info, "option2", true))
750 {
751 CreateMenu_PunktyVip(client);
752 }
753 else
754 {
755 if (StrEqual(info, "option3", true))
756 {
757 CreateMenu_Glowne(client);
758 }
759 }
760 }
761 }
762 else
763 {
764 if (action == view_as<MenuAction>(16))
765 {
766 CloseHandle(punkty);
767 }
768 }
769}
770
771public int Menu_PunktyInfo(Handle punktyvip, MenuAction action, int client, int itemNum) // address: 46632
772{
773 if (action == view_as<MenuAction>(4))
774 {
775 char info[32];
776 GetMenuItem(punktyvip, itemNum, info, 32);
777 if (StrEqual(info, "option1", true))
778 {
779 CreateMenu_PokazPunkty(client);
780 }
781 }
782 else
783 {
784 if (action == view_as<MenuAction>(16))
785 {
786 CloseHandle(punktyvip);
787 }
788 }
789}
790
791public int Menu_MenuRang(Handle menurang, MenuAction action, int client, int itemNum) // address: 46960
792{
793 if (action == view_as<MenuAction>(4))
794 {
795 char info[32];
796 GetMenuItem(menurang, itemNum, info, 32);
797 if (StrEqual(info, "option2", true))
798 {
799 CreateMenu_Glowne(client);
800 }
801 }
802 else
803 {
804 if (action == view_as<MenuAction>(16))
805 {
806 CloseHandle(menurang);
807 }
808 }
809}
810
811public int Rangi_MenuHandler(Menu menu, MenuAction action, int param1, int param2) // address: 47288
812{
813 if (action == view_as<MenuAction>(4))
814 {
815 char item[32];
816 bool found = menu.GetItem(param2, item, 32);
817 if (found)
818 {
819 if (StrEqual(item, "addpts", true))
820 {
821 CreateMenu_AdminSelect(param1, 1);
822 }
823 else
824 {
825 if (StrEqual(item, "rempts", true))
826 {
827 CreateMenu_AdminSelect(param1, 2);
828 }
829 else
830 {
831 if (StrEqual(item, "setrank", true))
832 {
833 CreateMenu_AdminSelect(param1, 3);
834 }
835 else
836 {
837 if (StrEqual(item, "removeall", true))
838 {
839 Potwierdz_Reset(param1, 4);
840 }
841 else
842 {
843 if (StrEqual(item, "showpoints", true))
844 {
845 Menu next = new Menu(Empty_MenuHandler, MENU_ACTIONS_DEFAULT);
846 next.SetTitle("Punkty");
847 for (int i = 1; i <= MaxClients; i++)
848 {
849 if (IsClientInGame(i))
850 {
851 char format[128];
852 char cid[16];
853 IntToString(i, cid, 16);
854 char name[36];
855 GetClientName(i, name, 33);
856 Format(format, 128, "%s - %d punktów", name, g_iPoints[i]);
857 next.AddItem(cid, format, 0);
858 }
859 }
860 next.ExitButton = true;
861 next.Display(param1, 60);
862 }
863 }
864 }
865 }
866 }
867 }
868 }
869 else
870 {
871 if (action == view_as<MenuAction>(16))
872 {
873 delete menu;
874 }
875 }
876}
877
878public int PointAct_MenuHandler(Menu menu, MenuAction action, int param1, int param2) // address: 48588
879{
880 char sInfo[12], sDane[12];
881 int iSelect = 0, client = 0;
882 for (int i = 0; i < menu.ItemCount; i++)
883 {
884 menu.GetItem(i, sInfo, 12, _, sDane, 12);
885 if (StrEqual(sInfo, "-SELECT-", true))
886 {
887 iSelect = StringToInt(sDane, 10);
888 }
889 if (StrEqual(sInfo, "-CLIENT-", true))
890 {
891 client = StringToInt(sDane, 10);
892 }
893 }
894 if (action == view_as<MenuAction>(4))
895 {
896 char item[32];
897 menu.GetItem(param2, item, 32);
898 if (IsValidClient(client))
899 {
900 if (iSelect == 1)
901 {
902 g_iPoints[client] += StringToInt(item, 10);
903 }
904 else
905 {
906 if (iSelect == 2)
907 {
908 //g_iPoints[client] = g_iPoints[client] - StringToInt(item, 10);
909 g_iPoints[client] -= StringToInt(item, 10);
910 }
911 }
912 CreateMenu_AddRemovePoints(param1, client, iSelect);
913 CheckRank(client);
914 }
915 }
916 else
917 {
918 if (action == view_as<MenuAction>(16))
919 {
920 delete menu;
921 }
922 }
923}
924
925public int SelectPlayer_MenuHandler(Menu menu, MenuAction action, int param1, int param2) // address: 49640
926{
927 char sInfo[12], sDane[12];
928 int iSelect = 0;
929 for (int i = 0; i < menu.ItemCount; i++)
930 {
931 menu.GetItem(i, sInfo, 12, _, sDane, 12);
932 if (StrEqual(sInfo, "-SELECT-", true))
933 {
934 iSelect = StringToInt(sDane, 10);
935 }
936 }
937 if (action == view_as<MenuAction>(4))
938 {
939 char item[32];
940 bool found = menu.GetItem(param2, item, 32);
941 if (found)
942 {
943 int client = StringToInt(item, 10);
944 if (IsValidClient(client))
945 {
946 if (iSelect != 3)
947 {
948 CreateMenu_AddRemovePoints(param1, client, iSelect);
949 }
950 else
951 {
952 Menu next = new Menu(SetRank_MenuHandler, MENU_ACTIONS_DEFAULT);
953 char frm[128];
954 char pname[36];
955 GetClientName(client, pname, 33);
956 Format(frm, 128, "Rangi - %s", pname);
957 next.SetTitle(frm);
958 char sNum[12];
959 for (int i = 1; i < 19; i++)
960 {
961 Format(sNum, 12, "%d", i);
962 next.AddItem(sNum, g_sRanksNames[i], 0);
963 }
964 Format(sNum, 12, "%d", client);
965 next.AddItem("-CLIENT-", sNum, 6);
966 next.ExitButton = true;
967 next.Display(param1, 60);
968 }
969 }
970 }
971 }
972 else
973 {
974 if (action == view_as<MenuAction>(16))
975 {
976 delete menu;
977 }
978 }
979}
980
981public int Empty_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
982{
983 if (action == view_as<MenuAction>(16))
984 {
985 delete menu;
986 }
987}
988
989public int SetRank_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
990{
991 char sInfo[32], sDane[32];
992 int client = 0;
993 for (int i = 0; i < menu.ItemCount; i++)
994 {
995 menu.GetItem(i, sInfo, 32, _, sDane, 32);
996 if (StrEqual(sInfo, "-CLIENT-", true))
997 {
998 client = StringToInt(sDane, 10);
999 }
1000 }
1001 if (action == view_as<MenuAction>(4))
1002 {
1003 char item[32];
1004 menu.GetItem(param2, item, 32);
1005 if (IsValidClient(client))
1006 {
1007 int iNewRank = StringToInt(item, 10);
1008 CPrintToChat(client, " \x07★ [AWP -> Admin] \x05Zmieniono twoją rangę na \x04%s\x05!", g_sRanksNames[iNewRank]);
1009 CPrintToChat(param1, " \x07★ [AWP -> Admin] \x05Zmieniłeś rangę \x04%N \x05na \x04%s\x05!", client, g_sRanksNames[iNewRank]);
1010 g_iPoints[client] = g_iRankTable[iNewRank + -1];
1011 CheckRank(client);
1012 }
1013 }
1014 else
1015 {
1016 if (action == view_as<MenuAction>(16))
1017 {
1018 delete menu;
1019 }
1020 }
1021}
1022
1023public Action Hook_OnThinkPost(int iEnt)
1024{
1025 static int iCoinOffset = -1;
1026 if (iCoinOffset == -1)
1027 {
1028 iCoinOffset = FindSendPropInfo("CCSPlayerResource", "m_nActiveCoinRank");
1029 }
1030
1031 SetEntDataArray(iEnt, FindSendPropInfo("CCSPlayerResource", "m_iCompetitiveRanking"), g_iRank, 66, 4, false);
1032 Handle hBuffer = StartMessageAll("ServerRankRevealAll", 0);
1033 if (hBuffer == null)
1034 {
1035 PrintToServer("ServerRankRevealAll = INVALID_HANDLE");
1036 }
1037 else
1038 {
1039 EndMessage();
1040 }
1041}
1042
1043public Action CMD_HUD(int client, int args)
1044{
1045 if (!IsValidClient(client))
1046 {
1047 return Plugin_Handled;
1048 }
1049 g_bHUD[client] = !g_bHUD[client];
1050 PrintToChat(client, " \x07★ [AWP -> Info] \x05Informacja o randze %s", (g_bHUD[client]) ? " \x04włączona\x05!" : " \x04wyłączona\x05!");
1051 return Plugin_Handled;
1052}
1053
1054public Action Timer_UpdateHUD(Handle Timer)
1055{
1056 for (int i = 1; i <= MaxClients; i++)
1057 {
1058 if (IsClientInGame(i))
1059 {
1060 if (!g_bHUD[i])
1061 {
1062 continue;
1063 }
1064 UpdateHUD(i);
1065 }
1066 }
1067 return Plugin_Continue;
1068}
1069
1070public void UpdateHUD(int client)
1071{
1072 char sHintText[512];
1073 if (IsPlayerAlive(client))
1074 {
1075
1076 SetHudTextParamsEx(-1.0, 0.92, 1.1, iColor, {0, 0, 0, 100}, 0, 0.0, 0.0, 0.0);
1077
1078
1079 if(g_iPoints[client] <= 24)
1080 {
1081 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/25", g_iPoints[client]);
1082 ShowHudText(client, 4, sHintText);
1083 }
1084
1085 else if(g_iPoints[client] > 24 && g_iPoints[client] <= 49)
1086 {
1087 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/50", g_iPoints[client]);
1088 ShowHudText(client, 4, sHintText);
1089 }
1090
1091 else if(g_iPoints[client] > 49 && g_iPoints[client] <= 99)
1092 {
1093 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/100", g_iPoints[client]);
1094 ShowHudText(client, 4, sHintText);
1095 }
1096
1097 else if(g_iPoints[client] > 99 && g_iPoints[client] <= 249)
1098 {
1099 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/250", g_iPoints[client]);
1100 ShowHudText(client, 4, sHintText);
1101 }
1102
1103 else if(g_iPoints[client] > 249 && g_iPoints[client] <= 499)
1104 {
1105 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/500", g_iPoints[client]);
1106 ShowHudText(client, 4, sHintText);
1107 }
1108
1109 else if(g_iPoints[client] > 499 && g_iPoints[client] <= 749)
1110 {
1111 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/750", g_iPoints[client]);
1112 ShowHudText(client, 4, sHintText);
1113 }
1114
1115 else if(g_iPoints[client] > 749 && g_iPoints[client] <= 999)
1116 {
1117 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/1000", g_iPoints[client]);
1118 ShowHudText(client, 4, sHintText);
1119 }
1120
1121 else if(g_iPoints[client] > 999 && g_iPoints[client] <= 1249)
1122 {
1123 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/1250", g_iPoints[client]);
1124 ShowHudText(client, 4, sHintText);
1125 }
1126
1127 else if(g_iPoints[client] > 1249 && g_iPoints[client] <= 1499)
1128 {
1129 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/1500", g_iPoints[client]);
1130 ShowHudText(client, 4, sHintText);
1131 }
1132
1133 else if(g_iPoints[client] > 1499 && g_iPoints[client] <= 1999)
1134 {
1135 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/2000", g_iPoints[client]);
1136 ShowHudText(client, 4, sHintText);
1137 }
1138
1139 else if(g_iPoints[client] > 1999 && g_iPoints[client] <= 2499)
1140 {
1141 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/2500", g_iPoints[client]);
1142 ShowHudText(client, 4, sHintText);
1143 }
1144
1145 else if(g_iPoints[client] > 2499 && g_iPoints[client] <= 4999)
1146 {
1147 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/5000", g_iPoints[client]);
1148 ShowHudText(client, 4, sHintText);
1149 }
1150
1151 else if(g_iPoints[client] > 4999 && g_iPoints[client] <= 7499)
1152 {
1153 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/7500", g_iPoints[client]);
1154 ShowHudText(client, 4, sHintText);
1155 }
1156
1157 else if(g_iPoints[client] > 7499 && g_iPoints[client] <= 9999)
1158 {
1159 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/10000", g_iPoints[client]);
1160 ShowHudText(client, 4, sHintText);
1161 }
1162
1163 else if(g_iPoints[client] > 9999 && g_iPoints[client] <= 12499)
1164 {
1165 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/12500", g_iPoints[client]);
1166 ShowHudText(client, 4, sHintText);
1167 }
1168
1169 else if(g_iPoints[client] > 12499 && g_iPoints[client] <= 14999)
1170 {
1171 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/15000", g_iPoints[client]);
1172 ShowHudText(client, 4, sHintText);
1173 }
1174
1175 else if(g_iPoints[client] > 14999 && g_iPoints[client] <= 16999)
1176 {
1177 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/17000", g_iPoints[client]);
1178 ShowHudText(client, 4, sHintText);
1179 }
1180 else if(g_iPoints[client] > 16999 && g_iPoints[client] <= 23999)
1181 {
1182 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i/24000", g_iPoints[client]);
1183 ShowHudText(client, 4, sHintText);
1184 }
1185 else
1186 {
1187 Format(sHintText, sizeof(sHintText), "Twoje punkty: %i", g_iPoints[client]);
1188 ShowHudText(client, 4, sHintText);
1189 }
1190
1191 SetHudTextParamsEx(-1.0, 0.95, 1.1, iColor, {0, 0, 0, 100}, 0, 0.0, 0.0, 0.0);
1192 Format(sHintText, sizeof(sHintText), "Ranga: %s", g_sRanksNames[g_iRank[client]]);
1193 ShowHudText(client, 3, sHintText);
1194 }
1195 else
1196 {
1197 int spect = GetEntProp(client, Prop_Send, "m_iObserverMode", 4, 0);
1198 if (spect == 4 || spect == 5)
1199 {
1200 int target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget", 0);
1201 if (target != -1 && IsValidClient(target))
1202 {
1203 //Format(sHintText, 512, "<font size='16'> | <font color='#C9AE28'>Statystyki gracza</font> \n| Ranga: [ %s ] |\n | Punkty: [ %d ] |", g_sRanksNames[g_iRank[target]], g_iPoints[target]);
1204
1205 SetHudTextParamsEx(-1.0, 0.94, 1.1, iColor, {0, 0, 0, 100}, 0, 0.0, 0.0, 0.0);
1206 Format(sHintText, sizeof(sHintText), "Ranga: %s", g_sRanksNames[g_iRank[target]]);
1207 ShowHudText(client, 3, sHintText);
1208
1209 SetHudTextParamsEx(-1.0, 0.92, 1.1, iColor, {0, 0, 0, 100}, 0, 0.0, 0.0, 0.0);
1210 Format(sHintText, sizeof(sHintText), "Punkty: %i", g_iPoints[target]);
1211 ShowHudText(client, 4, sHintText);
1212
1213 SetHudTextParamsEx(-1.0, 0.9, 1.1, iColor, {0, 0, 0, 100}, 0, 0.0, 0.0, 0.0);
1214 Format(sHintText, sizeof(sHintText), "Statystyki gracza: %N", target);
1215 ShowHudText(client, 5, sHintText);
1216 }
1217 }
1218 }
1219}
1220
1221void CheckRank(int client)
1222{
1223 bool bRankUp = false;
1224 bool bRankDown = false;
1225 if (!IsClientConnected(client))
1226 {
1227 return;
1228 }
1229 while(g_iPoints[client] >= g_iRankTable[g_iRank[client]] && g_iRank[client] < 18)
1230 {
1231 g_iRank[client]++;
1232 bRankUp = true;
1233 }
1234 if (g_iRank[client] > 0)
1235 {
1236 while(g_iPoints[client] < g_iRankTable[g_iRank[client] + -1])
1237 {
1238 g_iRank[client]--;
1239 bRankDown = true;
1240 }
1241 }
1242 if (bRankUp)
1243 {
1244 CPrintToChat(client, " \x07★ [AWP -> Awans] \x05Gratulacje! Awansowałeś do: \x04%s\x05!", g_sRanksNames[g_iRank[client]]);
1245 EmitSoundToClient(client, "*/fk/rangi/awans.mp3", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
1246 //CPrintToChatAll(" \x07★ [AWP -> Awans] Gracz {lightred}%N{yellow} właśnie awansował na rangę {green}%s!", client, g_sRanksNames[g_iRank[client]]);
1247 for (int i = 1; i <= MaxClients; i++)
1248 {
1249 if (IsClientInGame(i))
1250 {
1251 SetHudTextParams(0.23, 0.085, 5.0, 255, 131, 0, 1, 0, 0.0, 0.0, 0.2);
1252 ShowHudText(i, 5, "Gracz %N awansował do rangi %s!", client, g_sRanksNames[g_iRank[client]]);
1253 }
1254 }
1255 }
1256 if (bRankDown)
1257 {
1258 CPrintToChat(client, " \x07★ [AWP -> Awans] \x05Niestety, spadłeś do rangi: \x04%s\x05!", g_sRanksNames[g_iRank[client]]);
1259 EmitSoundToClient(client, "*/fk/rangi/awans.mp3", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
1260 //CPrintToChatAll("★ {lightred}[Rangi -> Awans]{yellow} Gracz {lightred}%N{yellow} właśnie awansował na rangę {green}%s!", client, g_sRanksNames[g_iRank[client]]);
1261 for (int i = 1; i <= MaxClients; i++)
1262 {
1263 if (IsClientInGame(i))
1264 {
1265 SetHudTextParams(0.23, 0.085, 5.0, 255, 131, 0, 1, 0, 0.0, 0.0, 0.2);
1266 ShowHudText(i, 5, "Gracz %N spadł do rangi %s!!", client, g_sRanksNames[g_iRank[client]]);
1267 }
1268 }
1269 }
1270}
1271
1272int GetCurrentPlayers()
1273{
1274 int count = 0;
1275 for (int i = 1; i <= MaxClients; i++)
1276 {
1277 if (IsClientInGame(i))
1278 {
1279 if (!IsFakeClient(i))
1280 {
1281 count++;
1282 }
1283 }
1284 }
1285 return count;
1286}
1287
1288void GivePoints(int client, int value)
1289{
1290 g_iPoints[client] += value;
1291 CheckRank(client);
1292}
1293
1294bool IsPlayerVIP(int client)
1295{
1296 if (!CheckCommandAccess(client, "sm_vip", 0, true))
1297 {
1298 return false;
1299 }
1300 return true;
1301}
1302
1303bool IsValidClient(int client)
1304{
1305 if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || IsFakeClient(client))
1306 {
1307 return false;
1308 }
1309 return true;
1310}