· 6 years ago · Jan 15, 2020, 04:16 AM
1#include <sdkhooks>
2#include <sdktools>
3#include <regex>
4#include <cstrike>
5#include <fpvm_interface>
6#include <clientprefs>
7#include <multicolors>
8#include <sourcecomms>
9
10#pragma semicolon 1
11#pragma newdecls required
12
13Database DB;
14
15char DownloadList[][] =
16{
17 "models/weaponf/v_knife_tridagger_v2.dx90.vtx",
18 "models/weaponf/v_knife_tridagger_v2.mdl",
19 "models/weaponf/v_knife_tridagger_v2.vvd",
20 "materials/models/weaponf/v_models/tridagger/tridagger.vmt",
21 "materials/models/weaponf/v_models/tridagger/tridagger.vtf",
22 "materials/models/weaponf/v_models/tridagger/tridagger_exp.vtf",
23 "materials/models/weaponf/v_models/tridagger/tridagger_normal.vtf",
24 "models/weaponf/v_knife_tridagger_steel.dx90.vtx",
25 "models/weaponf/v_knife_tridagger_steel.mdl",
26 "models/weaponf/v_knife_tridagger_steel.vvd",
27 "materials/models/weaponf/v_models/tridagger/steel/tridagger.vmt",
28 "materials/models/weaponf/v_models/tridagger/steel/tridagger_elite.vtf",
29 "materials/models/weaponf/v_models/tridagger/steel/tridagger_exp.vtf",
30 "materials/models/weaponf/v_models/tridagger/steel/tridagger_elite_normal.vtf",
31 "models/weaponf/v_knife_reaper.dx90.vtx",
32 "models/weaponf/v_knife_reaper.mdl",
33 "models/weaponf/v_knife_reaper.vvd",
34 "materials/models/weaponf/v_models/dtb_dagger/dtb.vmt",
35 "materials/models/weaponf/v_models/dtb_dagger/dtb.vtf",
36 "materials/models/weaponf/v_models/dtb_dagger/dtb_exp.vtf",
37 "materials/models/weaponf/v_models/dtb_dagger/dtb_normal.vtf",
38 "models/weaponf/v_knife_kabar_v2.dx90.vtx",
39 "models/weaponf/v_knife_kabar_v2.mdl",
40 "models/weaponf/v_knife_kabar_v2.vvd",
41 "materials/models/weaponf/kabar/KABAR.vmt",
42 "materials/models/weaponf/kabar/kabar.vtf",
43 "materials/models/weaponf/kabar/kabar_G.vtf",
44 "materials/models/weaponf/kabar/kabar_n.vtf",
45 "materials/models/weaponf/v_models/knife_ct/bowieknife.vmt",
46 "materials/models/weaponf/v_models/knife_ct/knife.vtf",
47 "materials/models/weaponf/v_models/knife_ct/knife_env.vtf",
48 "materials/models/weaponf/v_models/knife_ct/knife_normal.vtf",
49 "models/weaponf/crashz.dx80.vtx",
50 "models/weaponf/crashz.dx90.vtx",
51 "models/weaponf/crashz.mdl",
52 "models/weaponf/crashz.sw.vtx",
53 "models/weaponf/crashz.vvd",
54 "materials/models/weaponf/ultimate/texture_1.vmt",
55 "materials/models/weaponf/ultimate/texture_1.vtf",
56 "materials/models/weaponf/ultimate/texture_2.vmt",
57 "materials/models/weaponf/ultimate/texture_2.vtf",
58 "materials/models/weaponf/ultimate/texture_3.vmt",
59 "materials/models/weaponf/ultimate/texture_3.vtf",
60 "materials/models/weaponf/ultimate/texture_4.vmt",
61 "materials/models/weaponf/ultimate/texture_4.vtf",
62 "materials/models/weaponf/ultimate/texture_5.vmt",
63 "materials/models/weaponf/ultimate/texture_5.vtf",
64 "materials/models/weaponf/ultimate/texture_6.vmt",
65 "materials/models/weaponf/ultimate/texture_6.vtf",
66 "materials/models/weaponf/ultimate/texture_7.vmt",
67 "materials/models/weaponf/ultimate/texture_7.vtf",
68 "models/weaponf/v_knife_ultimate.dx90.vtx",
69 "models/weaponf/v_knife_ultimate.mdl",
70 "models/weaponf/v_knife_ultimate.vvd",
71 "models/weapons/caleon1/screwdriver/v_knife_screwdriver.dx90.vtx",
72 "models/weapons/caleon1/screwdriver/v_knife_screwdriver.mdl",
73 "models/weapons/caleon1/screwdriver/v_knife_screwdriver.vvd",
74 "materials/models/weapons/caleon1/screwdriver/orange.vtf",
75 "materials/models/weapons/caleon1/screwdriver/black.vmt",
76 "materials/models/weapons/caleon1/screwdriver/black.vtf",
77 "materials/models/weapons/caleon1/screwdriver/metal.vmt",
78 "materials/models/weapons/caleon1/screwdriver/metal.vtf",
79 "materials/models/weapons/caleon1/screwdriver/orange.vmt",
80};
81
82char KnifeModels[][] =
83{
84 "models/weaponf/v_knife_tridagger_v2.mdl",
85 "models/weaponf/v_knife_tridagger_steel.mdl",
86 "models/weaponf/v_knife_reaper.mdl",
87 "models/weaponf/v_knife_kabar_v2.mdl",
88 "models/weaponf/crashz.mdl",
89 "models/weaponf/v_knife_ultimate.mdl",
90 "models/weapons/caleon1/screwdriver/v_knife_screwdriver.mdl",
91};
92
93char KnifeNames[][] =
94{
95 "", "Spiralka", "białą Spiralka", "Rozpruwacz", "nóż Stalowy Prosty", "nóż Polowy", "Asiimov", "Wkrętak"
96};
97
98char KnifesNames[][] =
99{
100 "", "nożem Spiralnym", "białym nożem Spiralnym", "Rozpruwaczem", "nożem Stalowym Prostym", "nożem Polowym", "nożem Asiimov", "z Wkrętakiem"
101};
102
103char KnifesNamesLogs[][] =
104{
105 "", "Spiralka [1]", "Biała Spiralka[2]", "Rozpruwacz[3]", "Stalowy Prosty[4]", "Polowym[5]", "Asiimov[6]", "Wkrętak[7]"
106};
107
108char g_sPrefiksNames[][] =
109{
110 "",
111 "{green}[Boski]",
112 "{blue}[Furiat]",
113 "{olive}[Laluś]",
114 "{lime}[Magiczny]",
115 "{purple}[Cheater]",
116 "{grey}[Bogobojny]",
117 "{yellow}[Kot]",
118 "{orange}[Zjawiskowy]",
119 "{bluegrey}[Bandzior]",
120 "{lightgreen}[Nałogowiec]",
121 "{lightblue}[Strażnik]",
122 "{darkblue}[Sknera]",
123 "{orchid}[Melepeta]",
124 "{orchid}}[Queen]",
125 "{bluegrey}[DziK]",
126 "{lightgreen}[Alkoholik]",
127 "{grey}[Legenda]",
128 "{lightblue}[Noob]",
129 "{orange}[Master]"
130
131};
132
133char PrefiksNames[][] =
134{
135 "",
136 "[Boski]", "[Furiat]", "[Laluś]", "[Magiczny]", "[Cheater]", "[Bogobojny]", "[Kot]", "[Zjawiskowy]",
137 "[Bandzior]", "[Nałogowiec]", "[Strażnik]", "[Sknera]", "[Melepeta]", "[Queen]", "[DziK]",
138 "[Alkoholik]", "[Legenda]", "[Noob]", "[Master]"
139};
140
141char g_sColorsName[][] =
142{
143 "", "Zielony", "Niebieski", "Oliwkowy", "Limonkowy", "Fioletowy", "Szary", "Żółty", "Złoty", "Niebieskoszary",
144 "Jasnozielony", "Jasnoniebieski", "Ciemnoniebieski", "Orchid"
145};
146
147char g_sColorsNameLogs[][] =
148{
149 "", "Zielony [1]", "Niebieski [2]", "Oliwkowy [3]", "Limonkowy [4]", "Fioletowy [5]", "Szary [6]", "Żółty [7]", "Złoty [8]", "Niebieskoszary [9]",
150 "Jasnozielony [10]", "Jasnoniebieski [11]", "Ciemnoniebieski [12]", "Orchid [13]"
151};
152
153char g_sColors[][] =
154{
155 "",
156 "{green}",
157 "{blue}",
158 "{olive}",
159 "{lime}",
160 "{purple}",
161 "{grey}",
162 "{yellow}",
163 "{orange}",
164 "{bluegrey}",
165 "{lightgreen}",
166 "{lightblue}",
167 "{darkblue}",
168 "{orchid}"
169};
170
171char logFile[256];
172
173ConVar gc_MinPlayers, gc_HUDEnable;
174
175Handle g_hCiasteczkoVIP;
176
177int g_Model[8];
178
179int g_iKeys[MAXPLAYERS + 1];
180int g_iCases[MAXPLAYERS + 1];
181int g_iAKnife[MAXPLAYERS + 1], g_iAPrefiks[MAXPLAYERS + 1], g_iAKolor[MAXPLAYERS + 1];
182bool g_iKosa[MAXPLAYERS + 1][32];
183bool g_iKolor[MAXPLAYERS + 1][32];
184bool g_iPrefix[MAXPLAYERS + 1][32];
185bool g_bHUD[MAXPLAYERS + 1];
186
187public Plugin myinfo =
188{
189 name = "CS:GO GOMOD",
190 author = "fabko Rewrite Brum Brum",
191 description = "System skrzynek/kluczy",
192 version = "3.0",
193 url = "Nie kupujcie NIDGY nic od FABKO"
194};
195
196public void OnPluginStart()
197{
198 gc_MinPlayers = CreateConVar("sm_gomod_min_player", "4", "Minimalna liczba graczy aby system skrzynek był włączony");
199 gc_HUDEnable = CreateConVar("sm_godmod_hud_enable", "1", "Włącz/wyłącz HUD`a", _, true, 0.0, true, 1.0);
200 g_hCiasteczkoVIP = RegClientCookie("WK_VIP", "Weak_VIP", CookieAccess_Private);
201
202 HookEvent("round_start", Event_RoundStart);
203 HookEvent("player_death", Event_PlayerDeath);
204 HookEvent("player_spawn", Event_PlayerSpawn);
205
206 RegConsoleCmd("sm_hudgo", CMD_HUD);
207 RegConsoleCmd("sm_open", CMD_OpenChest);
208 RegConsoleCmd("sm_wybierz", CMD_Wybierz);
209 RegConsoleCmd("sm_prefiks", CMD_Prefiks);
210 RegConsoleCmd("sm_kolory", CMD_Kolory);
211 RegConsoleCmd("sm_csgo", CMD_Csgo);
212 RegConsoleCmd("say", Say);
213 RegConsoleCmd("say_team", SayTeam);
214
215 BuildPath(Path_SM, logFile, sizeof(logFile), "logs/Uslugi/GOMOD.txt");
216
217 CreateTimer(0.9, ShowHud, _, TIMER_REPEAT);
218
219 OnMapStart();
220 DB_Connect();
221
222 for (int i = 1; i < MaxClients; i++)
223 {
224 if (IsValidClient(i))
225 {
226 SQL_LoadData(i);
227 }
228 }
229}
230
231public void OnClientPutInServer(int client)
232{
233 if (gc_HUDEnable.BoolValue)
234 {
235 g_bHUD[client] = true;
236 }
237 else
238 {
239 g_bHUD[client] = false;
240 }
241}
242
243public void OnMapStart()
244{
245 for (int i = 0; i < sizeof(DownloadList); i++)
246 {
247 char buffer[128];
248 Format(buffer, sizeof(buffer), "%s", DownloadList[i]);
249 AddFileToDownloadsTable(buffer);
250 if (StrContains(buffer, ".mdl", true) == -1) {
251 PrecacheDecal(buffer, true);
252 }
253 }
254 for (int i = 0; i < sizeof(KnifeModels); i++)
255 {
256 char buffer[128];
257 Format(buffer, sizeof(buffer), "%s", KnifeModels[i]);
258 g_Model[i] = PrecacheModel(buffer, true);
259 }
260}
261
262public Action DB_Connect()
263{
264 if (SQL_CheckConfig("weak_gomod_w"))
265 {
266 char error[512];
267 DB = SQL_Connect("weak_gomod_w", true, error, sizeof(error));
268 if (DB == null) {
269 LogMessage("Could not connect to weak_gomod_w! Error: %s", error);
270 return;
271 } else {
272 char query[512];
273 Format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `weak_gomod` (`auth_data` VARCHAR(64) NOT NULL, `name` VARCHAR(64) NOT NULL, `KeyP` INT NOT NULL, `CaseP` INT NOT NULL, `Kalach` INT NOT NULL, `Kosa1` INT NOT NULL, `Kosa2` INT NOT NULL, `Kosa3` INT NOT NULL, `Kosa4` INT NOT NULL, `Kosa5` INT NOT NULL, `Kosa6` INT NOT NULL, `Kosa7` INT NOT NULL, UNIQUE KEY `auth_data` (`auth_data`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;");
274 DB.Query(CreateTableHandler, query, _, DBPrio_Normal);
275 Format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `weak_chat` (`auth_data` VARCHAR(64) NOT NULL, `name` VARCHAR(64) NOT NULL, `K1` INT NOT NULL, `K2` INT NOT NULL, `K3` INT NOT NULL, `K4` INT NOT NULL, `K5` INT NOT NULL, `K6` INT NOT NULL, `K7` INT NOT NULL, `K8` INT NOT NULL, `K9` INT NOT NULL, `K10` INT NOT NULL, `K11` INT NOT NULL, `K12` INT NOT NULL, `K13` INT NOT NULL, `AKolory` INT NOT NULL, UNIQUE KEY `auth_data` (`auth_data`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;");
276 DB.Query(CreateTableHandler, query, _, DBPrio_Normal);
277 Format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `weak_prefiksy` (`auth_data` VARCHAR(64) NOT NULL, `name` VARCHAR(64) NOT NULL, `P1` INT NOT NULL, `P2` INT NOT NULL, `P3` INT NOT NULL, `P4` INT NOT NULL, `P5` INT NOT NULL, `P6` INT NOT NULL, `P7` INT NOT NULL, `P8` INT NOT NULL, `P9` INT NOT NULL, `P10` INT NOT NULL, `P11` INT NOT NULL, `P12` INT NOT NULL, `P13` INT NOT NULL, P14` INT NOT NULL, P15` INT NOT NULL, P16` INT NOT NULL, P17` INT NOT NULL, P18` INT NOT NULL, P19` INT NOT NULL, `APrefiks` INT NOT NULL, UNIQUE KEY `auth_data` (`auth_data`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;");
278 DB.Query(CreateTableHandler, query, _, DBPrio_Normal);
279 }
280 }
281 else {
282 SetFailState("Nie mozna odnalezc konfiguracji 'weak_gomod_w' w data.cfg. ");
283 }
284}
285
286public void CreateTableHandler(Database db, DBResultSet results, const char[] error, any data)
287{
288 if (db == null) {
289 LogMessage("Could not create tables! Error: %s", error);
290 }
291}
292
293public void OnClientAuthorized(int client, const char[] auth)
294{
295 g_iKeys[client] = 0;
296 g_iCases[client] = 0;
297 g_iAKnife[client] = 0;
298 for (int i = 0; i < 8; i++) {
299 g_iKosa[client][i] = false;
300 g_iPrefix[client][i] = false;
301 g_iKolor[client][i] = false;
302 }
303 SQL_LoadData(client);
304}
305
306void SQL_LoadData(int client) {
307 char steamid[64];
308 GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid));
309
310 char query[512];
311 Format(query, sizeof(query), "SELECT KeyP, CaseP, Kalach, Kosa1, Kosa2, Kosa3, Kosa4, Kosa5, Kosa6, Kosa7 FROM weak_gomod WHERE auth_data = '%s'", steamid);
312 DB.Query(LoadDataHandler, query, GetClientUserId(client), DBPrio_Normal);
313 Format(query, sizeof(query), "SELECT K1, K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, K12, K13, AKolory FROM weak_chat WHERE auth_data = '%s'", steamid);
314 DB.Query(LoadDataHandler1, query, GetClientUserId(client), DBPrio_Normal);
315 Format(query, sizeof(query), "SELECT P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, APrefiks FROM weak_prefiksy WHERE auth_data = '%s'", steamid);
316 DB.Query(LoadDataHandler2, query, GetClientUserId(client), DBPrio_Normal);
317}
318
319public void LoadDataHandler(Database db, DBResultSet results, const char[] error, int userid)
320{
321 if (db == null) {
322 LogMessage("Could not load user data! Error: %s", error);
323 return;
324 }
325
326 int client = GetClientOfUserId(userid);
327 if (!client)return;
328
329 char name[256], auth[64];
330 GetClientName(client, name, sizeof(name));
331 GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth));
332
333 char sanitized_name[128];
334 DB.Escape(name, sanitized_name, sizeof(name));
335
336 if (results.RowCount == 0) {
337 char query[512];
338 Format(query, sizeof(query), "INSERT INTO `weak_gomod` (auth_data, name, KeyP, CaseP, Kalach, Kosa1, Kosa2, Kosa3, Kosa4, Kosa5, Kosa6, Kosa7) VALUES ('%s', '%s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", auth, sanitized_name);
339 DB.Query(InsertNewPlayer, query, _, DBPrio_Normal);
340 } else {
341 while (SQL_FetchRow(results)) {
342 g_iKeys[client] = SQL_FetchBool(results, 0);
343 g_iCases[client] = SQL_FetchBool(results, 1);
344 g_iAKnife[client] = SQL_FetchBool(results, 2);
345 g_iKosa[client][1] = SQL_FetchBool(results, 3);
346 g_iKosa[client][2] = SQL_FetchBool(results, 4);
347 g_iKosa[client][3] = SQL_FetchBool(results, 5);
348 g_iKosa[client][4] = SQL_FetchBool(results, 6);
349 g_iKosa[client][5] = SQL_FetchBool(results, 7);
350 g_iKosa[client][6] = SQL_FetchBool(results, 8);
351 g_iKosa[client][7] = SQL_FetchBool(results, 9);
352 }
353 }
354}
355
356public void LoadDataHandler1(Database db, DBResultSet results, const char[] error, int userid)
357{
358 if (db == null) {
359 LogMessage("Could not load user data! Error: %s", error);
360 return;
361 }
362
363 int client = GetClientOfUserId(userid);
364 if (!client)return;
365
366 char name[256], auth[64];
367 GetClientName(client, name, sizeof(name));
368 GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth));
369
370 char sanitized_name[128];
371 DB.Escape(name, sanitized_name, sizeof(name));
372
373 if (results.RowCount == 0) {
374 char query[512];
375 Format(query, sizeof(query), "INSERT INTO `weak_chat` (auth_data, name, K1, K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, K12, K13, AKolory) VALUES ('%s', '%s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", auth, sanitized_name);
376 DB.Query(InsertNewPlayer, query, _, DBPrio_Normal);
377 } else {
378 while (SQL_FetchRow(results)) {
379 g_iKolor[client][1] = SQL_FetchBool(results, 0);
380 g_iKolor[client][2] = SQL_FetchBool(results, 1);
381 g_iKolor[client][3] = SQL_FetchBool(results, 2);
382 g_iKolor[client][4] = SQL_FetchBool(results, 3);
383 g_iKolor[client][5] = SQL_FetchBool(results, 4);
384 g_iKolor[client][6] = SQL_FetchBool(results, 5);
385 g_iKolor[client][7] = SQL_FetchBool(results, 6);
386 g_iKolor[client][8] = SQL_FetchBool(results, 7);
387 g_iKolor[client][9] = SQL_FetchBool(results, 8);
388 g_iKolor[client][10] = SQL_FetchBool(results, 9);
389 g_iKolor[client][11] = SQL_FetchBool(results, 10);
390 g_iKolor[client][12] = SQL_FetchBool(results, 11);
391 g_iKolor[client][13] = SQL_FetchBool(results, 12);
392 g_iAKolor[client] = SQL_FetchBool(results, 13);
393
394 }
395 }
396}
397
398public void LoadDataHandler2(Database db, DBResultSet results, const char[] error, int userid)
399{
400 if (db == null) {
401 LogMessage("Could not load user data! Error: %s", error);
402 return;
403 }
404
405 int client = GetClientOfUserId(userid);
406 if (!client)return;
407
408 char name[256], auth[64];
409 GetClientName(client, name, sizeof(name));
410 GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth));
411
412 char sanitized_name[128];
413 DB.Escape(name, sanitized_name, sizeof(name));
414
415 if (results.RowCount == 0) {
416 char query[512];
417 Format(query, sizeof(query), "INSERT INTO `weak_prefiksy` (auth_data, name, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, APrefiks) VALUES ('%s', '%s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", auth, sanitized_name);
418 DB.Query(InsertNewPlayer, query, _, DBPrio_Normal);
419 } else {
420 while (SQL_FetchRow(results)) {
421 g_iPrefix[client][1] = SQL_FetchBool(results, 0);
422 g_iPrefix[client][2] = SQL_FetchBool(results, 1);
423 g_iPrefix[client][3] = SQL_FetchBool(results, 2);
424 g_iPrefix[client][4] = SQL_FetchBool(results, 3);
425 g_iPrefix[client][5] = SQL_FetchBool(results, 4);
426 g_iPrefix[client][6] = SQL_FetchBool(results, 5);
427 g_iPrefix[client][7] = SQL_FetchBool(results, 6);
428 g_iPrefix[client][8] = SQL_FetchBool(results, 7);
429 g_iPrefix[client][9] = SQL_FetchBool(results, 8);
430 g_iPrefix[client][10] = SQL_FetchBool(results, 9);
431 g_iPrefix[client][11] = SQL_FetchBool(results, 10);
432 g_iPrefix[client][12] = SQL_FetchBool(results, 11);
433 g_iPrefix[client][13] = SQL_FetchBool(results, 12);
434 g_iPrefix[client][14] = SQL_FetchBool(results, 13);
435 g_iPrefix[client][15] = SQL_FetchBool(results, 14);
436 g_iPrefix[client][16] = SQL_FetchBool(results, 15);
437 g_iPrefix[client][17] = SQL_FetchBool(results, 16);
438 g_iPrefix[client][18] = SQL_FetchBool(results, 17);
439 g_iPrefix[client][19] = SQL_FetchBool(results, 18);
440 g_iAPrefiks[client] = SQL_FetchBool(results, 19);
441
442 }
443 }
444}
445
446public void InsertNewPlayer(Database db, DBResultSet results, const char[] error, any data)
447{
448 if (db == null) {
449 LogMessage("Could not insert player! Error: %s", error);
450 }
451}
452
453void SQL_SaveData(int client)
454{
455 char query[512], name[256], steamid[64];
456 GetClientName(client, name, sizeof(name));
457 GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid));
458 char sanitized_name[128];
459 DB.Escape(name, sanitized_name, sizeof(name));
460
461 Format(query, sizeof(query), "UPDATE weak_gomod SET `KeyP` = '%d', `CaseP` = '%d',`Kalach` = '%d', `Kosa1` = '%d',`Kosa2` = '%d',`Kosa3` = '%d',`Kosa4` = '%d',`Kosa5` = '%d',`Kosa6` = '%d',`Kosa7` = '%d',`name` = '%s' WHERE auth_data = '%s'", g_iKeys[client], g_iCases[client], g_iAKnife[client], g_iKosa[client][1], g_iKosa[client][2], g_iKosa[client][3], g_iKosa[client][4], g_iKosa[client][5], g_iKosa[client][6], g_iKosa[client][7], sanitized_name, steamid);
462 DB.Query(UpdatePlayerData, query, _, DBPrio_Normal);
463 Format(query, sizeof(query), "UPDATE weak_chat SET `K1` = '%d', `K2` = '%d',`K3` = '%d', `K4` = '%d',`K5` = '%d',`K6` = '%d',`K7` = '%d',`K8` = '%d',`K9` = '%d',`K10` = '%d',`K11` = '%d',`K12` = '%d',`K13` = '%d',`AKolory` = '%d',`name` = '%s' WHERE auth_data = '%s'", g_iKolor[client][1], g_iKolor[client][2], g_iKolor[client][3], g_iKolor[client][4], g_iKolor[client][5], g_iKolor[client][6], g_iKolor[client][7], g_iKolor[client][8], g_iKolor[client][9], g_iKolor[client][10], g_iKolor[client][11], g_iKolor[client][12], g_iKolor[client][13], g_iAKolor[client], sanitized_name, steamid);
464 DB.Query(UpdatePlayerData, query, _, DBPrio_Normal);
465 Format(query, sizeof(query), "UPDATE weak_prefiksy SET `P1` = '%d', `P2` = '%d',`P3` = '%d', `P4` = '%d',`P5` = '%d',`P6` = '%d',`P7` = '%d',`P8` = '%d',`P9` = '%d',`P10` = '%d',`P11` = '%d',`P12` = '%d',`P13` = '%d',`P14` = '%d',`P15` = '%d',`P16` = '%d',`P17` = '%d',`P18` = '%d',`P19` = '%d',`APrefiks` = '%d',`name` = '%s' WHERE auth_data = '%s'", g_iPrefix[client][1], g_iPrefix[client][2], g_iPrefix[client][3], g_iPrefix[client][4], g_iPrefix[client][5], g_iPrefix[client][6], g_iPrefix[client][7], g_iPrefix[client][8], g_iPrefix[client][9], g_iPrefix[client][10], g_iPrefix[client][11], g_iPrefix[client][12], g_iPrefix[client][13], g_iPrefix[client][14], g_iPrefix[client][15], g_iPrefix[client][16], g_iPrefix[client][17], g_iPrefix[client][18], g_iPrefix[client][19], g_iAPrefiks[client], sanitized_name, steamid);
466 DB.Query(UpdatePlayerData, query, _, DBPrio_Normal);
467}
468
469public void UpdatePlayerData(Database db, DBResultSet results, const char[] error, any data)
470{
471 if (db == null) {
472 LogMessage("Could not update player data! Error: %s", error);
473 }
474}
475
476public Action ShowHud(Handle timer)
477{
478 if (!gc_HUDEnable.BoolValue)return Plugin_Continue;
479
480 for (int i = 1; i < MaxClients; i++)
481 {
482 if (IsValidClient(i) && g_bHUD[i])
483 {
484 SetHudTextParams(-1.0, 0.96, 1.0, 255, 255, 255, 255, 1, 1.0, 0.0, 0.0);
485 ShowHudText(i, -1, "Skrzynki: [ %d ] | Klucze: [ %d ]", g_iCases[i], g_iKeys[i]);
486 }
487 }
488
489 return Plugin_Continue;
490}
491
492public void OnClientCookiesCached(int client)
493{
494 char temp[64];
495 GetClientCookie(client, g_hCiasteczkoVIP, temp, sizeof(temp));
496 int time = StringToInt(temp);
497 if (time > GetTime()) {
498 int before = GetUserFlagBits(client);
499 int flags = before | ADMFLAG_CUSTOM1;
500 SetUserFlagBits(client, flags);
501 }
502}
503
504public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
505{
506 if (GetClientCount(true) < gc_MinPlayers.IntValue)
507 {
508 CPrintToChatAll("★ {lightred}[Skrzynki]{yellow} Na serwerze jest {darkred}zbyt mało{yellow} graczy, by system skrzynek był włączony, potrzeba minimum {lightred}%i{yellow} graczy.", gc_MinPlayers.IntValue);
509 }
510}
511
512public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
513{
514 int client = GetClientOfUserId(event.GetInt("userid"));
515 if (!IsValidClient(client))return;
516
517 CheckKnife(client);
518}
519
520public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
521{
522 if (GetClientCount(true) < gc_MinPlayers.IntValue)return Plugin_Continue;
523
524 int victim = GetClientOfUserId(event.GetInt("userid"));
525 int attacker = GetClientOfUserId(event.GetInt("attacker"));
526 if (!IsValidClient(attacker) || !IsValidClient(victim))return Plugin_Continue;
527
528 if (IsPlayerVIP(attacker))
529 {
530 if (GetRandomInt(1, 30) == 1)
531 {
532 CPrintToChat(attacker, "★ {lightred}[Klucze] {lightgreen}Udało Ci się, {green}zdobyłeś klucz{lightgreen}!");
533 g_iKeys[attacker]++;
534 }
535
536 if (GetRandomInt(1, 28) == 1)
537 {
538 CPrintToChat(attacker, "★ {lightred}[Skrzynka] {lightgreen}Udało Ci się, {green}zdobyłeś skrzynkę{lightgreen}!");
539 g_iCases[attacker]++;
540 }
541 }
542 else
543 {
544 if (GetRandomInt(1, 32) == 1)
545 {
546 CPrintToChat(attacker, "★ {lightred}[Klucze] {lightgreen}Udało Ci się, {green}zdobyłeś klucz{lightgreen}!");
547 g_iKeys[attacker]++;
548 }
549
550 if (GetRandomInt(1, 30) == 1)
551 {
552 CPrintToChat(attacker, "★ {lightred}[Skrzynka] {lightgreen}Udało Ci się, {green}zdobyłeś skrzynkę{lightgreen}!");
553 g_iCases[attacker]++;
554 }
555 }
556 return Plugin_Continue;
557}
558
559public Action CMD_HUD(int client, int args)
560{
561 if (!gc_HUDEnable.BoolValue) {
562 CPrintToChat(client, "★ {lightred}[HUD]{yellow} Właściciel serwera nie włączył HUDU, więc nie możesz użyć tej komendy");
563 return Plugin_Handled;
564 }
565
566 Menu menu = new Menu(MENU_HUD_HANDLER);
567 menu.SetTitle("Co zrobić z hudem?");
568 menu.AddItem("", "Włącz", (!g_bHUD[client]) ? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
569 menu.AddItem("", "Wyłącz", (g_bHUD[client]) ? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
570 menu.ExitButton = true;
571 menu.Display(client, 60);
572 return Plugin_Handled;
573}
574
575public Action CMD_OpenChest(int client, int args)
576{
577 if (g_iCases[client] >= 1 && g_iKeys[client] >= 1)
578 {
579 g_iCases[client]--;
580 g_iKeys[client]--;
581
582 if (IsPlayerVIP(client))
583 {
584 if (GetRandomInt(1, 13) == 1)
585 {
586 WinChest(client);
587 }
588 else
589 {
590 LoseChest(client);
591 }
592 }
593 else
594 {
595 if (GetRandomInt(1, 18) == 1)
596 {
597 WinChest(client);
598 }
599 else
600 {
601 LoseChest(client);
602 }
603 }
604 }
605 else
606 {
607 if (g_iCases[client] < 1 && g_iKeys[client] >= 1)
608 {
609 CPrintToChat(client, "★ {lightred}[Klucze] {lightgreen}Nie masz wystarczająco skrzynek!");
610 return Plugin_Handled;
611 }
612 else if (g_iKeys[client] < 1 && g_iCases[client] >= 1)
613 {
614 CPrintToChat(client, "★ {lightred}[Klucze] {lightgreen}Nie masz wystarczająco kluczy!");
615 return Plugin_Handled;
616 }
617 else
618 {
619 CPrintToChat(client, "★ {lightred}[Klucze] {lightgreen}Zdobądź {green}klucz {lightgreen}i {green}skrzynkę{lightgreen}!");
620 return Plugin_Handled;
621 }
622 }
623
624 return Plugin_Handled;
625}
626
627public Action CMD_Wybierz(int client, int args)
628{
629 Menu menu = new Menu(Select_knife_Handler);
630 menu.SetTitle("Wybierz jakiego chcesz używać noża!");
631 menu.AddItem("0", "Domyślny");
632 for (int i = 1; i < sizeof(KnifeNames); i++)
633 {
634 char buffer[64], num[4];
635 Format(num, sizeof(num), "%d", i);
636 Format(buffer, sizeof(buffer), "%s", KnifeNames[i]);
637 menu.AddItem(num, buffer, (g_iKosa[client][i]) ? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
638 }
639 menu.ExitButton = true;
640 menu.Display(client, 60);
641}
642
643public Action CMD_Prefiks(int client, int args)
644{
645 Menu menu = new Menu(Select_prefiks_Handler);
646 menu.SetTitle("Jakiego prefiksu chcesz używać?");
647 menu.AddItem("0", "Brak");
648 for (int i = 1; i < sizeof(PrefiksNames); i++)
649 {
650 char buffer[64], num[4];
651 Format(num, sizeof(num), "%d", i);
652 Format(buffer, sizeof(buffer), "%s", PrefiksNames[i]);
653 menu.AddItem(num, buffer, (g_iPrefix[client][i]) ? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
654 }
655 menu.ExitButton = true;
656 menu.Display(client, 60);
657}
658
659public Action CMD_Kolory(int client, int args)
660{
661 Menu menu = new Menu(Select_kolor_Handler);
662 menu.SetTitle("Jakiego koloru chcesz używać?");
663 menu.AddItem("0", "Brak");
664 for (int i = 1; i < sizeof(g_sColorsName); i++)
665 {
666 char buffer[64], num[4];
667 Format(num, sizeof(num), "%d", i);
668 Format(buffer, sizeof(buffer), "%s", g_sColorsName[i]);
669 menu.AddItem(num, buffer, (g_iKolor[client][i]) ? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
670 }
671 menu.ExitButton = true;
672 menu.Display(client, 60);
673}
674
675public Action CMD_Csgo(int client, int args)
676{
677 Menu menu = new Menu(Menu_Handler);
678 menu.SetTitle("Szybki dostęp:");
679 menu.AddItem("1", "Otwórz skrzynkę");
680 menu.AddItem("2", "Wybierz nóż");
681 menu.AddItem("3", "Ustaw prefiks");
682 menu.AddItem("4", "Ustaw kolor");
683 menu.AddItem("5", "HUD");
684 menu.ExitButton = true;
685 menu.Display(client, 15);
686}
687
688public int MENU_HUD_HANDLER(Menu menu, MenuAction action, int client, int item)
689{
690 if (!IsValidClient(client))return;
691
692 switch (action)
693 {
694 case MenuAction_Select:
695 {
696 switch(item)
697 {
698 case 0:g_bHUD[client] = true;
699 case 1:g_bHUD[client] = false;
700 }
701 }
702 case MenuAction_End:delete menu;
703 }
704}
705
706public int Select_knife_Handler(Menu menu, MenuAction action, int client, int item)
707{
708 if (!IsValidClient(client))return;
709
710 switch (action)
711 {
712 case MenuAction_Select:
713 {
714 char info[32];
715 menu.GetItem(item, info, sizeof(info));
716 int number = StringToInt(info);
717 g_iAKnife[client] = number;
718 CheckKnife(client);
719 }
720 case MenuAction_End:delete menu;
721 }
722}
723
724public int Select_prefiks_Handler(Menu menu, MenuAction action, int client, int item)
725{
726 if (!IsValidClient(client))return;
727
728 switch (action)
729 {
730 case MenuAction_Select:
731 {
732 char info[32];
733 menu.GetItem(item, info, sizeof(info));
734 int number = StringToInt(info);
735 g_iAPrefiks[client] = number;
736 }
737 case MenuAction_End:delete menu;
738 }
739}
740
741public int Select_kolor_Handler(Menu menu, MenuAction action, int client, int item)
742{
743 if (!IsValidClient(client))return;
744
745 switch (action)
746 {
747 case MenuAction_Select:
748 {
749 char info[32];
750 menu.GetItem(item, info, sizeof(info));
751 int number = StringToInt(info);
752 g_iAKolor[client] = number;
753 }
754 case MenuAction_End:delete menu;
755 }
756}
757
758public int Menu_Handler(Menu menu, MenuAction action, int client, int item)
759{
760 if (!IsValidClient(client))return;
761
762 switch (action)
763 {
764 case MenuAction_Select:
765 {
766 switch (item)
767 {
768 case 0:CMD_OpenChest(client, 0);
769 case 1:ClientCommand(client, "sm_wybierz");
770 case 2:ClientCommand(client, "sm_prefiks");
771 case 3:ClientCommand(client, "sm_kolory");
772 case 4:ClientCommand(client, "sm_hudgo");
773 }
774 }
775 case MenuAction_End:delete menu;
776 }
777}
778
779public Action Say(int client, int args)
780{
781 if (IsValidClient(client))
782 {
783 char kolor[9];
784 char vip[37];
785
786 if (GetClientTeam(client) == 2)
787 {
788 kolor = "{yellow}"; // kolor dla TT
789 vip = "{orange}[★{lightred} VIP {orange}★]";
790 }
791 if (GetClientTeam(client) == 3)
792 {
793 kolor = "{bluegrey}"; // kolor dla CT
794 vip = "{orange}[★{lightred} VIP {orange}★]";
795 }
796
797 char message[512];
798 GetCmdArgString(message, 512);
799 StripQuotes(message);
800
801 if (strlen(message) == 0)
802 {
803 return Plugin_Handled;
804 }
805
806 if (SourceComms_GetClientGagType(client))
807 {
808 CPrintToChat(client, "★{lightred} [Info] {lightgreen}Nie możesz używać chatu, masz gaga!");
809 return Plugin_Handled;
810 }
811
812 if (!(message[0] == '/' || message[0] == '!' || message[0] == '@' || message[0] == ' ' || message[0] == '$' || message[0] == '%' || message[0] == '*'))
813 {
814
815 char name[32];
816 GetClientName(client, name, 32);
817
818 if (IsPlayerAlive(client))
819 {
820 if (GetUserFlagBits(client) & ADMFLAG_ROOT)
821 Format(message, sizeof(message), " {darkred}[Właściciel] %s %s%s{default}:%s %s", g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
822 else if ((GetUserFlagBits(client) & ADMFLAG_CUSTOM1) && !(GetUserFlagBits(client) & ADMFLAG_CUSTOM2))
823 Format(message, sizeof(message), " %s %s %s%s{default}:%s %s", vip, g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
824 else if (GetUserFlagBits(client) & ADMFLAG_CUSTOM2)
825 Format(message, sizeof(message), " {darkblue}[Opiekun] %s %s%s{default}:%s %s", g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
826 else
827 Format(message, sizeof(message), " %s %s%s{default}:%s %s", g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
828
829 CPrintToChatAll(message);
830 }
831 else
832 {
833 if (GetUserFlagBits(client) & ADMFLAG_ROOT)
834 Format(message, sizeof(message), " %s*DEAD* {darkred}[Właściciel] %s %s%s{default}:%s %s", kolor, g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
835 else if ((GetUserFlagBits(client) & ADMFLAG_CUSTOM1) && !(GetUserFlagBits(client) & ADMFLAG_CUSTOM2))
836 Format(message, sizeof(message), " %s*DEAD* %s %s %s%s{default}:%s %s", kolor, vip, g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
837 else if (GetUserFlagBits(client) & ADMFLAG_CUSTOM2)
838 Format(message, sizeof(message), " %s*DEAD* {darkblue}[Opiekun] %s %s%s{default}:%s %s", kolor, g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
839 else
840 Format(message, sizeof(message), " %s*DEAD* %s %s%s{default}:%s %s", kolor, g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
841
842 for (int i = 1; i <= MaxClients; i++)
843 {
844 if (IsValidClient(i) && !IsPlayerAlive(i))CPrintToChat(i, message);
845 }
846 }
847 }
848 }
849
850 return Plugin_Handled;
851}
852
853public Action SayTeam(int client, int args)
854{
855 if (IsValidClient(client))
856 {
857 char kolor[9];
858 char team[5];
859 char vip[37];
860
861 if (GetClientTeam(client) == 2)
862 {
863 kolor = "{yellow}"; // kolor dla TT
864 team = "[TT]";
865 vip = "{orange}[★{lightred} VIP {orange}★]";
866
867 }
868 if (GetClientTeam(client) == 3)
869 {
870 kolor = "{bluegrey}"; // kolor dla CT
871 team = "[CT]";
872 vip = "{orange}[★{lightred} VIP {orange}★]";
873 }
874
875 char message[512];
876 GetCmdArgString(message, 512);
877 StripQuotes(message);
878
879 if (strlen(message) == 0)
880 {
881 return Plugin_Handled;
882 }
883
884 if (SourceComms_GetClientGagType(client))
885 {
886 CPrintToChat(client, "★{lightred} [Info] {lightgreen}Nie możesz używać chatu, masz gaga!");
887 return Plugin_Handled;
888 }
889
890 if (!(message[0] == '/' || message[0] == '!' || message[0] == '@' || message[0] == ' ' || message[0] == '$' || message[0] == '%' || message[0] == '*'))
891 {
892
893 char name[32];
894 GetClientName(client, name, 32);
895
896 if (IsPlayerAlive(client))
897 {
898 if (GetUserFlagBits(client) & ADMFLAG_ROOT)
899 Format(message, sizeof(message), " %s%s {darkred}[Właściciel] %s %s%s{default}:%s %s", kolor, team, g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
900 else if ((GetUserFlagBits(client) & ADMFLAG_CUSTOM1) && !(GetUserFlagBits(client) & ADMFLAG_CUSTOM2))
901 Format(message, sizeof(message), " %s%s %s %s %s%s{default}:%s %s", kolor, team, vip, g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
902 else if (GetUserFlagBits(client) & ADMFLAG_CUSTOM2)
903 Format(message, sizeof(message), " %s%s {darkblue}[Opiekun] %s %s%s{default}:%s %s", kolor, team, g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
904 else
905 Format(message, sizeof(message), " %s%s %s %s%s{default}:%s %s", kolor, team, g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
906
907 for (int i = 1; i <= MaxClients; i++)
908 {
909 if (!IsClientInGame(i) || !IsPlayerAlive(i) || GetClientTeam(client) != GetClientTeam(i))
910 continue;
911
912 CPrintToChat(i, message);
913 }
914 }
915 else
916 {
917 if (GetUserFlagBits(client) & ADMFLAG_ROOT)
918 Format(message, sizeof(message), " %s%s *DEAD* {darkred}[Właściciel] %s %s%s{default}:%s %s", kolor, team, g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
919 else if ((GetUserFlagBits(client) & ADMFLAG_CUSTOM1) && !(GetUserFlagBits(client) & ADMFLAG_CUSTOM2))
920 Format(message, sizeof(message), " %s%s *DEAD* %s %s %s%s{default}:%s %s", kolor, team, vip, g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
921 else if (GetUserFlagBits(client) & ADMFLAG_CUSTOM2)
922 Format(message, sizeof(message), " %s%s *DEAD* {darkblue}[Opiekun] %s %s%s{default}:%s %s", kolor, team, g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
923 else
924 Format(message, sizeof(message), " %s%s *DEAD* {default}%s %s%s{default}:%s %s", kolor, team, g_sPrefiksNames[g_iAPrefiks[client]], kolor, name, g_sColors[g_iAKolor[client]], message);
925
926 for (int i = 1; i <= MaxClients; i++)
927 {
928 if (!IsValidClient(i) || IsPlayerAlive(i) || GetClientTeam(client) != GetClientTeam(i))
929 continue;
930
931 CPrintToChat(i, message);
932 }
933 }
934 }
935 }
936
937 return Plugin_Handled;
938}
939
940void WinChest(int client)
941{
942 if (!IsValidClient(client))return;
943 CPrintToChat(client, "★ {lightred}[Otwieranie] {lightgreen}Trwa otwieranie skrzynki...");
944 CreateTimer(3.0, TimerWin, GetClientUserId(client));
945}
946
947public Action TimerWin(Handle timer, int userid)
948{
949 int client = GetClientOfUserId(userid);
950 if (!IsValidClient(client))return;
951
952 char SteamID[32];
953 int random = GetRandomInt(1, 14);
954
955 switch (random)
956 {
957 case 0, 1, 2, 3, 4, 5, 6, 7:
958 {
959 if (g_iKosa[client][random])
960 {
961 CPrintToChat(client, "★ {lightred}[Otwieranie] {lightgreen}Trafiłeś nóż, który już posiadasz. Losujemy inną wygraną!");
962 WinChest(client);
963 }
964 else {
965 CPrintToChat(client, "★ {lightred}[Pomyślne otwarcie] {lightgreen}W pojemniku znalazłeś {green}%s{lightgreen}!", KnifeNames[random]);
966 g_iKosa[client][random] = true;
967 CPrintToChatAll("★ {lightred}Gratulacje! {green}%N {lightgreen}otworzył skrzynkę z {green}%s{lightgreen}!", client, KnifesNames[random]);
968
969 GetClientAuthId(client, AuthId_Steam2, SteamID, sizeof(SteamID), true);
970 LogToFile(logFile, "[NÓŻ] %N (%s) wylosował: %s!", client, SteamID, KnifesNamesLogs[random]);
971
972 }
973 }
974 case 8:NadajPrefiks(client);
975 case 9:NadajKolor(client);
976 case 10:
977 {
978 if (GetRandomInt(1, 2) == 1)
979 {
980 if (!IsPlayerVIP(client))
981 {
982 NadajVIP(client, GetRandomInt(1, 9));
983 }
984 else
985 {
986 CPrintToChat(client, "★ {lightred}[Otwieranie] {lightgreen}Posiadasz już konto VIP, losowanie zostanie powtórzone!");
987 WinChest(client);
988 }
989 }
990 else
991 {
992 CPrintToChat(client, "★ {lightred}[Otwieranie] {lightgreen}Niestety, skrzynka była pusta!");
993 }
994 }
995 }
996}
997
998void NadajPrefiks(int client)
999{
1000 if (!IsValidClient(client))return;
1001
1002 char SteamID[32];
1003 int random = GetRandomInt(1, 19);
1004
1005 if (g_iPrefix[client][random])
1006 {
1007 CPrintToChat(client, "★ {lightred}[Otwieranie] {lightgreen}Trafiłeś prefiks, który już posiadasz. Losujemy inną wygraną!");
1008 WinChest(client);
1009 }
1010 else
1011 {
1012 CPrintToChat(client, "★{lightred} [Dodatki] {lightgreen}Wylosowałeś prefiks %s!", g_sPrefiksNames[random]);
1013 g_iPrefix[client][random] = true;
1014
1015 GetClientAuthId(client, AuthId_Steam2, SteamID, sizeof(SteamID), true);
1016 LogToFile(logFile, "[PREFIX] %N (%s) wylosował: %s!", client, SteamID, PrefiksNames[random]);
1017 }
1018}
1019
1020void NadajKolor(int client)
1021{
1022 if (!IsValidClient(client))return;
1023
1024 char SteamID[32];
1025 int random = GetRandomInt(1, 13);
1026
1027 if (g_iKolor[client][random])
1028 {
1029 CPrintToChat(client, "★ {lightred}[Otwieranie] {lightgreen}Trafiłeś kolor, który już posiadasz. Losujemy inną wygraną!");
1030 WinChest(client);
1031 }
1032 else
1033 {
1034 CPrintToChat(client, "★{lightred} [Dodatki] {lightgreen}Wylosowałeś %s kolor chatu!", g_sColors[random]);
1035 g_iKolor[client][random] = true;
1036
1037 GetClientAuthId(client, AuthId_Steam2, SteamID, sizeof(SteamID), true);
1038 LogToFile(logFile, "[KOLOR] %N (%s) wylosował: %s!", client, SteamID, g_sColorsNameLogs[random]);
1039 }
1040}
1041
1042void NadajVIP(int client, int dni)
1043{
1044 if (!IsValidClient(client))return;
1045 char temp[64];
1046 char SteamID[32];
1047 int time = dni * 86400;
1048 IntToString(GetTime() + time, temp, sizeof(temp));
1049 SetClientCookie(client, g_hCiasteczkoVIP, temp);
1050 int before = GetUserFlagBits(client);
1051 int flags = before | ADMFLAG_CUSTOM1;
1052 SetUserFlagBits(client, flags);
1053 GetClientAuthId(client, AuthId_Steam2, SteamID, sizeof(SteamID), true);
1054 LogToFile(logFile, "[VIP] %N (%s) wylosował VIPa na %i dni!", client, SteamID, dni);
1055 CPrintToChatAll("★ {lightred}[VIP] {lightgreen}Gracz %N wylosował VIPa na {lightred}%i {lightgreen}dni!", client, dni);
1056}
1057
1058void LoseChest(int client)
1059{
1060 if (!IsValidClient(client))return;
1061 CPrintToChat(client, "★ {lightred}[Otwieranie] {lightgreen}Trwa otwieranie skrzynki...");
1062 CreateTimer(3.0, TimerLose, GetClientUserId(client));
1063}
1064
1065public Action TimerLose(Handle timer, int userid)
1066{
1067 int client = GetClientOfUserId(userid);
1068 if (!IsValidClient(client))return;
1069
1070 CPrintToChat(client, "★ {lightred}[Otwieranie] {lightgreen}Niestety, skrzynka była pusta!");
1071}
1072
1073void CheckKnife(int client)
1074{
1075 if (!IsValidClient(client))return;
1076
1077 if (g_iAKnife[client] == 0)FPVMI_RemoveViewModelToClient(client, "weapon_knife");
1078 else FPVMI_AddViewModelToClient(client, "weapon_knife", g_Model[g_iAKnife[client] - 1]);
1079
1080}
1081
1082public void OnClientDisconnect(int client)
1083{
1084 SQL_SaveData(client);
1085 ResetAllVariables(client);
1086}
1087
1088void ResetAllVariables(int client)
1089{
1090 if (!IsValidClient(client))return;
1091
1092 g_iKeys[client] = 0;
1093 g_iCases[client] = 0;
1094 g_iAKnife[client] = 0;
1095 g_bHUD[client] = false;
1096 for (int i = 0; i < 8; i++) {
1097 g_iKosa[client][i] = false;
1098 g_iPrefix[client][i] = false;
1099 g_iKolor[client][i] = false;
1100 }
1101}
1102
1103stock bool SQL_FetchBool(Handle query, int field, DBResult &result = DBVal_Error)
1104{
1105 return view_as<bool>(SQL_FetchInt(query, field, result));
1106}
1107
1108public bool IsPlayerVIP(int client)
1109{
1110 if (GetUserFlagBits(client) & ADMFLAG_CUSTOM1)return true;
1111 if (GetUserFlagBits(client) & ADMFLAG_BAN)return true;
1112 if (GetUserFlagBits(client) & ADMFLAG_ROOT)return true;
1113
1114 return false;
1115}
1116
1117public bool IsValidClient(int client)
1118{
1119 if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || !IsClientConnected(client) || IsFakeClient(client) || IsClientSourceTV(client))
1120 return false;
1121
1122 return true;
1123}