· 8 years ago · Jul 24, 2018, 04:36 PM
1#pragma semicolon 1
2
3#define DEBUG
4
5#define PLUGIN_AUTHOR "jenz"
6#define PLUGIN_VERSION "1.09"
7#define ZONE_PREFIX_CT "ZONE_PREFIX_CT"
8
9
10#include <sourcemod>
11#include <sdktools>
12#include <sdkhooks>
13#include <devzones>
14#include <tokengroups>
15#include <zombiereloaded>
16
17//map prefferences
18KeyValues g_kZoneStats;
19static char g_sKVPATH[PLATFORM_MAX_PATH];
20
21
22//sets players health
23int g_iclientSpawn[MAXPLAYERS+1];
24//set score
25int g_iClientScore[MAXPLAYERS+1];
26
27//damage
28float i_bDmgScale[MAXPLAYERS+1];
29
30//zonepoints
31int i_points[MAXPLAYERS+1];
32char c_storestats[MAXPLAYERS+1][MAX_NAME_LENGTH];
33float f_2kdmgPoints[MAXPLAYERS+1];
34
35
36//convars
37ConVar G_hCvar_Points_Humans = null;
38
39bool g_bClientFilter[MAXPLAYERS+1];
40bool g_bDmgScale[MAXPLAYERS+1];
41bool g_bDmgOutput[MAXPLAYERS+1];
42
43
44public Plugin myinfo =
45{
46 name = "end Zones",
47 author = PLUGIN_AUTHOR,
48 description = "end zones in maps",
49 version = PLUGIN_VERSION,
50 url = "https://forums.alliedmods.net/showthread.php?t=224839"
51};
52
53
54public void OnPluginStart()
55{
56 // Events.
57 HookEvent("round_end", Event_RoundEnd);
58 HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
59
60 //mysql
61 SQL_StartConnection();
62
63 //translations
64 LoadTranslations("common.phrases");
65
66 //commands
67 RegConsoleCmd("sm_dmgscale", cmd_dmgScaleOutput, "Enables output for damage");
68 RegConsoleCmd("sm_store", cmd_shopmenu, "Shop for Unloze Tokens");
69 RegConsoleCmd("sm_shop", cmd_shopmenu, "Shop for Unloze Tokens");
70 RegConsoleCmd("sm_transfertoken", cmd_transfertoken, "transfers token from player to player");
71 RegConsoleCmd("sm_transfertokens", cmd_transfertoken, "transfers token from player to player");
72 RegAdminCmd("sm_zoneDataDel", Cmd_zoneDataDel, ADMFLAG_ROOT);
73 RegAdminCmd("sm_mysqlpoints", Cmd_mysqltokens, ADMFLAG_ROOT);
74 RegAdminCmd("sm_givetokens", Cmd_givetokens, ADMFLAG_ROOT);
75
76 //prefference for reconnect
77 g_kZoneStats = new KeyValues("zoneStats");
78 BuildPath(Path_SM, g_sKVPATH, sizeof(g_sKVPATH), "data/playerprefs.zoneStats.txt");
79 g_kZoneStats.ImportFromFile(g_sKVPATH);
80
81 //convars
82 G_hCvar_Points_Humans = CreateConVar("hlx_roundpoints_humans", "250", "The amount of points to reward to humans for winning a round.");
83
84}
85
86//----------------------------------------------------------------------------------------------------
87// Purpose: cmds
88//----------------------------------------------------------------------------------------------------
89public Action Cmd_zoneDataDel(int client, int args)
90{
91 DeleteAll(g_kZoneStats);
92}
93
94public Action Cmd_mysqltokens(int client, int args)
95{
96 PrintToChat(client, "c_storestats value: %s", c_storestats[client]);
97 return Plugin_Handled;
98}
99
100
101
102public Action cmd_transfertoken(int client, int args)
103{
104 if (args < 2)
105 {
106 ReplyToCommand(client, "[SM] Usage: sm_transfertoken <#userid|name> <value>");
107 return Plugin_Handled;
108 }
109 char sArgs[65];
110 char sArgs2[20];
111 GetCmdArg(1, sArgs, sizeof(sArgs));
112 GetCmdArg(2, sArgs2, sizeof(sArgs2));
113
114 int amount = clamp(StringToInt(sArgs2), 1, 0x7FFFFFFF);
115
116 if (amount == 1)
117 {
118 PrintToChat(client, "Invalid amount");
119 return Plugin_Handled;
120 }
121 else if (i_points[client] < amount)
122 {
123 PrintToChat(client, "Not enough Tokens: %i", i_points[client]);
124 return Plugin_Handled;
125 }
126
127 //PrintToChat(client, "amount value: %i", amount);
128 //PrintToChat(client, "sArgs value: %s", sArgs);
129
130 int i = FindTarget(client, sArgs, true, false);
131 if (i == -1)
132 {
133 PrintToChat(client, "Invalid target");
134 return Plugin_Handled;
135 }
136
137 if (IsValidClient1(i))
138 {
139 //PrintToChatAll("i %N", i);
140 //PrintToChatAll("Client %N", client);
141 i_points[client] -= amount;
142 sendMYSQL(client);
143 PrintToChat(client, "You send %i Tokens to %N, your total amount: %i", amount, i, i_points[client]);
144 i_points[i] += amount;
145 sendMYSQL(i);
146 PrintToChat(i, "You received %i Tokens from %N, your total amount: %i", amount, client, i_points[i]);
147 }
148 return Plugin_Handled;
149}
150
151
152public Action Cmd_givetokens(int client, int args)
153{
154 i_points[client] += 2500;
155 sendMYSQL(client);
156 PrintToChat(client, "You received 2500 Tokens, your total amount: %i", i_points[client]);
157 return Plugin_Handled;
158}
159
160public Action cmd_dmgScaleOutput(int client, int args)
161{
162 if (!(g_bDmgOutput[client]))
163 {
164 g_bDmgOutput[client] = true;
165 ReplyToCommand(client, "Enabled output for Damage Scaler");
166 }
167 else
168 {
169 g_bDmgOutput[client] = false;
170 ReplyToCommand(client, "Disabled output for Damage Scaler");
171 }
172}
173
174public Action cmd_shopmenu(int client, int args)
175{
176 Menu menu = new Menu(ShopMenu_Handler, MenuAction_Display|MenuAction_Select|MenuAction_Cancel);
177 menu.SetTitle("Unloze Shop | Your Tokens: %i", i_points[client]);
178 menu.AddItem("Playermodels CT", "Playermodels CT");
179 menu.AddItem("Playermodels ZM", "Playermodels ZM");
180 menu.AddItem("Paint", "Paint");
181 menu.AddItem("Tracers", "Tracers");
182 menu.AddItem("Chat Tags", "Chat Tags");
183 menu.Display(client, 0);
184 // ?? return Plugin_Handled;
185}
186
187//----------------------------------------------------------------------------------------------------
188// Purpose: shop menu handlers
189//----------------------------------------------------------------------------------------------------
190
191public int ShopMenu_Handler(Menu menu, MenuAction action, int client, int choice)
192{
193 switch (action)
194 {
195 case MenuAction_Select:
196 {
197 Menu menu1 = new Menu(PlayermodelMenu_Handler, MenuAction_Display|MenuAction_Select|MenuAction_Cancel);
198 menu1.AddItem("Back", "Back");
199 char info[32];
200 menu.GetItem(choice, info, sizeof(info));
201 static char SID[32];
202 GetClientAuthId(client, AuthId_Steam2, SID, sizeof(SID));
203 if (StrEqual(info, "Playermodels CT", true))
204 {
205 menu1.SetTitle("Unloze Playermodels CT | Command: !zclass | Your Tokens: %i", i_points[client]);
206 menu1.AddItem("Lightning [120 Tokens]", "Lightning [120 Tokens]");
207 menu1.AddItem("Batman [500 Tokens]", "Batman [500 Tokens]");
208 menu1.AddItem("Connor [3000 Tokens]", "Connor [3000 Tokens]");
209 menu1.AddItem("Samus [3000 Tokens]", "Samus [3000 Tokens]");
210 menu1.AddItem("Duke Nukem [4000 Tokens]", "Duke Nukem [4000 Tokens]");
211 menu1.AddItem("Back", "Back");
212 menu1.AddItem("Trevor [15000 Tokens]", "Trevor [15000 Tokens]");
213 menu1.Display(client, 0);
214
215 return -1;
216 }
217 else if (StrEqual(info, "Playermodels ZM", true))
218 {
219 menu1.SetTitle("Unloze Playermodels ZM | Command: !zclass | Your Tokens: %i", i_points[client]);
220 menu1.AddItem("Stalker [200 Tokens]", "Stalker [200 Tokens]");
221 menu1.AddItem("Xeno [600 Tokens]", "Xeno [600 Tokens]");
222 menu1.AddItem("Grunt [3000 Tokens]", "Grunt [3000 Tokens]");
223
224 menu1.Display(client, 0);
225 return -1;
226 }
227 else if (StrEqual(info, "Paint", true))
228 {
229 Menu menu2 = new Menu(PaintMenu_Handler);
230 menu2.SetTitle("UNLOZE Paint | Commands: !paint !paintcolor !paintsize | Your Tokens: %i", i_points[client]);
231 menu2.AddItem("Back", "Back");
232 menu2.AddItem("Unlock paint [4000 Tokens]", "Unlock paint [4000 Tokens]");
233 menu2.AddItem("Unlock size [4500 Tokens]", "Unlock size [4500 Tokens]");
234 menu2.AddItem("Unlock colour [5000 Tokens]", "Unlock colour [5000 Tokens]");
235 menu2.Display(client, 0);
236 return -1;
237 }
238 else if (StrEqual(info, "Tracers", true))
239 {
240 Menu menu2 = new Menu(TracersMenu_Handler);
241 menu2.SetTitle("UNLOZE Tracers | Command: !tracers (Enable/disable) | Your Tokens: %i", i_points[client]);
242 menu2.AddItem("Back", "Back");
243 menu2.AddItem("ZEUS Tracers [25000 Tokens]", "ZEUS Tracers [25000 Tokens]");
244 menu2.Display(client, 0);
245 return -1;
246 }
247 else if (StrEqual(info, "Chat Tags", true))
248 {
249 Menu menu2 = new Menu(ChatTagsMenu_Handler);
250 menu2.SetTitle("UNLOZE ChatTags | Commands: !tokentags !chatcolor | Your Tokens: %i", i_points[client]);
251 menu2.AddItem("Back", "Back");
252 menu2.AddItem("Rookie [1500 Tokens]", "Rookie [1500 Tokens]");
253 menu2.AddItem("Member [2400 Tokens]", "Member [2400 Tokens]");
254 menu2.AddItem("Overweight Vegetarian [3000 Tokens]", "Overweight Vegetarian [3000 Tokens]");
255 menu2.AddItem("руÑÑкий [3800 Tokens]", "руÑÑкий [3800 Tokens]");
256 menu2.AddItem("SERBIAN [5000 Tokens]", "SERBIAN [5000 Tokens]");
257 menu2.AddItem("Back", "Back");
258 menu2.AddItem("WEEB [6000 Tokens]", "WEEB [6000 Tokens]");
259 menu2.AddItem("BAGUETTE [7000 Tokens]", "BAGUETTE [7000 Tokens]");
260 menu2.AddItem("NIGGER elites [11377 Tokens]", "NIGGER elites [11377 Tokens]");
261 menu2.AddItem("DANE [15000 Tokens]", "DANE [15000 Tokens]");
262 menu2.AddItem("Nosteam Chad [20000 Tokens]", "Nosteam Chad [20000 Tokens]");
263 menu2.Display(client, 0);
264 return -1;
265 }
266 }
267 }
268 return -1;
269}
270
271public int PlayermodelMenu_Handler(Menu menu, MenuAction action, int client, int choice)
272{
273 if (action == MenuAction_Select)
274 {
275 int purchaseEntry;
276 char info[32];
277 menu.GetItem(choice, info, sizeof(info));
278
279 static char SID[32];
280 GetClientAuthId(client, AuthId_Steam2, SID, sizeof(SID));
281
282 if (StrEqual(info, "Lightning [120 Tokens]", true))
283 {
284 if (i_points[client] >= 120 && (StrContains(c_storestats[client], "1") < 0))
285 {
286 purchaseEntry = 1;
287 i_points[client] -= 120;
288 sendMYSQL(client);
289 GrantTokens(client, 4);
290 storeEntryMYSQL(client, purchaseEntry);
291 PrintToChat(client, "Purchased Lightning playermodel for 120 UNLOZE tokens!");
292 PrintToChat(client, "Check !zclass for your new playermodel!");
293 }
294 else if (StrContains(c_storestats[client], "1") >= 0)
295 {
296 PrintToChat(client, "You already purchased Lightning!");
297 }
298 else if (i_points[client] <= 120)
299 {
300 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
301 }
302 }
303 else if (StrEqual(info, "Stalker [200 Tokens]", true))
304 {
305 if (i_points[client] >= 200 && (StrContains(c_storestats[client], "a") < 0))
306 {
307 purchaseEntry = 2;
308 i_points[client] -= 200;
309 sendMYSQL(client);
310 GrantTokens(client, 1);
311 storeEntryMYSQL(client, purchaseEntry);
312 PrintToChat(client, "Purchased Stalker playermodel for 200 UNLOZE tokens!");
313 PrintToChat(client, "Check !zclass for your new playermodel!");
314 }
315 else if (StrContains(c_storestats[client], "a") >= 0)
316 {
317 PrintToChat(client, "You already purchased Stalker!");
318 }
319 else if (i_points[client] <= 200)
320 {
321 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
322 }
323 }
324 else if (StrEqual(info, "Batman [500 Tokens]", true))
325 {
326 if (i_points[client] >= 500 && (StrContains(c_storestats[client], "2") < 0))
327 {
328 purchaseEntry = 3;
329 i_points[client] -= 500;
330 sendMYSQL(client);
331 GrantTokens(client, 5);
332 storeEntryMYSQL(client, purchaseEntry);
333 PrintToChat(client, "Purchased Batman playermodel for 500 UNLOZE tokens!");
334 PrintToChat(client, "Check !zclass for your new playermodel!");
335 }
336 else if (StrContains(c_storestats[client], "2") >= 0)
337 {
338 PrintToChat(client, "You already purchased Batman!");
339 }
340 else if (i_points[client] <= 500)
341 {
342 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
343 }
344 }
345 else if (StrEqual(info, "Xeno [600 Tokens]", true))
346 {
347 if (i_points[client] >= 600 && (StrContains(c_storestats[client], "c") < 0))
348 {
349 //paint has purchaseEntry 4 and c_storestats b
350 purchaseEntry = 5;
351 i_points[client] -= 600;
352 sendMYSQL(client);
353 GrantTokens(client, 3);
354 storeEntryMYSQL(client, purchaseEntry);
355 PrintToChat(client, "Purchased Xeno playermodel for 600 UNLOZE tokens!");
356 PrintToChat(client, "Check !zclass for your new playermodel!");
357 }
358 else if (StrContains(c_storestats[client], "c") >= 0)
359 {
360 PrintToChat(client, "You already purchased Xeno!");
361 }
362 else if (i_points[client] <= 600)
363 {
364 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
365 }
366 }
367 else if (StrEqual(info, "Connor [3000 Tokens]", true))
368 {
369 if (i_points[client] >= 3000 && (StrContains(c_storestats[client], "f") < 0))
370 {
371 //paint has purchaseEntry 4 and c_storestats b
372 purchaseEntry = 8;
373 i_points[client] -= 3000;
374 sendMYSQL(client);
375 GrantTokens(client, 6);
376 storeEntryMYSQL(client, purchaseEntry);
377 PrintToChat(client, "Purchased Connor playermodel for 3000 UNLOZE tokens!");
378 PrintToChat(client, "Check !zclass for your new playermodel!");
379 }
380 else if (StrContains(c_storestats[client], "f") >= 0)
381 {
382 PrintToChat(client, "You already purchased Connor!");
383 }
384 else if (i_points[client] <= 3000)
385 {
386 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
387 }
388 }
389 else if (StrEqual(info, "Duke Nukem [4000 Tokens]", true))
390 {
391 if (i_points[client] >= 4000 && (StrContains(c_storestats[client], "g") < 0))
392 {
393 //paint has purchaseEntry 4 and c_storestats b
394 purchaseEntry = 9;
395 i_points[client] -= 4000;
396 sendMYSQL(client);
397 GrantTokens(client, 7);
398 storeEntryMYSQL(client, purchaseEntry);
399 PrintToChat(client, "Purchased Duke playermodel for 4000 UNLOZE tokens!");
400 PrintToChat(client, "Check !zclass for your new playermodel!");
401 }
402 else if (StrContains(c_storestats[client], "g") >= 0)
403 {
404 PrintToChat(client, "You already purchased Duke!");
405 }
406 else if (i_points[client] <= 4000)
407 {
408 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
409 }
410 }
411 else if (StrEqual(info, "Samus [3000 Tokens]", true))
412 {
413 if (i_points[client] >= 3000 && (StrContains(c_storestats[client], "h") < 0))
414 {
415 //paint has purchaseEntry 4 and c_storestats b
416 purchaseEntry = 10;
417 i_points[client] -= 3000;
418 sendMYSQL(client);
419 GrantTokens(client, 8);
420 storeEntryMYSQL(client, purchaseEntry);
421 PrintToChat(client, "Purchased Samus playermodel for 3000 UNLOZE tokens!");
422 PrintToChat(client, "Check !zclass for your new playermodel!");
423 }
424 else if (StrContains(c_storestats[client], "h") >= 0)
425 {
426 PrintToChat(client, "You already purchased Samus!");
427 }
428 else if (i_points[client] <= 3000)
429 {
430 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
431 }
432 }
433 else if (StrEqual(info, "Trevor [15000 Tokens]", true))
434 {
435 if (i_points[client] >= 15000 && (StrContains(c_storestats[client], "i") < 0))
436 {
437 //paint has purchaseEntry 4 and c_storestats b
438 purchaseEntry = 11;
439 i_points[client] -= 15000;
440 sendMYSQL(client);
441 GrantTokens(client, 9);
442 storeEntryMYSQL(client, purchaseEntry);
443 PrintToChat(client, "Purchased Trevor playermodel for 15000 UNLOZE tokens!");
444 PrintToChat(client, "Check !zclass for your new playermodel!");
445 }
446 else if (StrContains(c_storestats[client], "i") >= 0)
447 {
448 PrintToChat(client, "You already purchased Trevor!");
449 }
450 else if (i_points[client] <= 15000)
451 {
452 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
453 }
454 }
455 else if (StrEqual(info, "Back", true))
456 {
457 cmd_shopmenu(client, 0);
458 }
459 else if (StrEqual(info, "Grunt [3000 Tokens]", true))
460 {
461 if (i_points[client] >= 3000 && (StrContains(c_storestats[client], "j") < 0))
462 {
463 //paint has purchaseEntry 4 and c_storestats b
464 purchaseEntry = 12;
465 i_points[client] -= 3000;
466 sendMYSQL(client);
467 GrantTokens(client, 2);
468 storeEntryMYSQL(client, purchaseEntry);
469 PrintToChat(client, "Purchased Grunt playermodel for 3000 UNLOZE tokens!");
470 PrintToChat(client, "Check !zclass for your new playermodel!");
471 }
472 else if (StrContains(c_storestats[client], "j") >= 0)
473 {
474 PrintToChat(client, "You already purchased Grunt!");
475 }
476 else if (i_points[client] <= 3000)
477 {
478 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
479 }
480 }
481 }
482}
483
484
485public int TracersMenu_Handler(Menu menu, MenuAction action, int client, int choice)
486{
487 if (action == MenuAction_Select)
488 {
489 int purchaseEntry;
490 char info[32];
491 menu.GetItem(choice, info, sizeof(info));
492
493 static char SID[32];
494 GetClientAuthId(client, AuthId_Steam2, SID, sizeof(SID));
495
496 if (StrEqual(info, "ZEUS Tracers [25000 Tokens]", true))
497 {
498 if (i_points[client] >= 25000 && (StrContains(c_storestats[client], "k") < 0))
499 {
500 purchaseEntry = 13;
501 i_points[client] -= 25000;
502 sendMYSQL(client);
503 storeEntryMYSQL(client, purchaseEntry);
504 PrintToChat(client, "Purchased ZEUS Tracers for 25000 UNLOZE tokens!");
505 PrintToChat(client, "Rejoin the server to use !tracers to enable/disable!");
506 }
507 else if (StrContains(c_storestats[client], "k") >= 0)
508 {
509 PrintToChat(client, "You already purchased ZEUS tracers!");
510 }
511 else if (i_points[client] <= 25000)
512 {
513 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
514 }
515 }
516 else if (StrEqual(info, "Back", true))
517 {
518 cmd_shopmenu(client, 0);
519 }
520 }
521}
522public int ChatTagsMenu_Handler(Menu menu, MenuAction action, int client, int choice)
523{
524 if (action == MenuAction_Select)
525 {
526 int purchaseEntry;
527 char info[32];
528 menu.GetItem(choice, info, sizeof(info));
529
530 static char SID[32];
531 GetClientAuthId(client, AuthId_Steam2, SID, sizeof(SID));
532
533 if (StrEqual(info, "Rookie [1500 Tokens]", true))
534 {
535 if (i_points[client] >= 1500 && (StrContains(c_storestats[client], "l") < 0))
536 {
537 purchaseEntry = 14;
538 i_points[client] -= 1500;
539 sendMYSQL(client);
540 storeEntryMYSQL(client, purchaseEntry);
541 PrintToChat(client, "Purchased Rookie Tag for 1500 UNLOZE tokens!");
542 PrintToChat(client, "Reconnect to the server to use !tokentag!");
543 }
544 else if (StrContains(c_storestats[client], "l") >= 0)
545 {
546 PrintToChat(client, "You already purchased Rookie Tag! Use !tokentag to select your tag!");
547 }
548 else if (i_points[client] <= 1500)
549 {
550 PrintToChat(client, "You only have %i UNLOZE tokens, your legit broke nigga", i_points[client]);
551 }
552 }
553 else if (StrEqual(info, "Member [2400 Tokens]", true))
554 {
555 if (i_points[client] >= 2400 && (StrContains(c_storestats[client], "m") < 0))
556 {
557 purchaseEntry = 15;
558 i_points[client] -= 2400;
559 sendMYSQL(client);
560 storeEntryMYSQL(client, purchaseEntry);
561 PrintToChat(client, "Purchased MEMBER Tag for 2400 UNLOZE tokens!");
562 PrintToChat(client, "Reconnect to the server to use !tokentag!");
563 }
564 else if (StrContains(c_storestats[client], "m") >= 0)
565 {
566 PrintToChat(client, "You already purchased MEMBER Tag! Use !tokentag to select your tag!");
567 }
568 else if (i_points[client] <= 2400)
569 {
570 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
571 }
572 }
573 else if (StrEqual(info, "SERBIAN [5000 Tokens]", true))
574 {
575 if (i_points[client] >= 5000 && (StrContains(c_storestats[client], "n") < 0))
576 {
577 purchaseEntry = 16;
578 i_points[client] -= 5000;
579 sendMYSQL(client);
580 storeEntryMYSQL(client, purchaseEntry);
581 PrintToChat(client, "Purchased SERBIAN Tag for 5000 UNLOZE tokens!");
582 PrintToChat(client, "Reconnect to the server to use !tokentag!");
583 }
584 else if (StrContains(c_storestats[client], "n") >= 0)
585 {
586 PrintToChat(client, "You already purchased SERBIAN Tag! Use !tokentag to select your tag!");
587 }
588 else if (i_points[client] <= 5000)
589 {
590 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
591 }
592 }
593 else if (StrEqual(info, "Overweight Vegetarian [3000 Tokens]", true))
594 {
595 if (i_points[client] >= 3000 && (StrContains(c_storestats[client], "o") < 0))
596 {
597 purchaseEntry = 17;
598 i_points[client] -= 3000;
599 sendMYSQL(client);
600 storeEntryMYSQL(client, purchaseEntry);
601 PrintToChat(client, "Purchased Overweight Vegetarian Tag for 3000 UNLOZE tokens!");
602 PrintToChat(client, "Reconnect to the server to use !tokentag!");
603 }
604 else if (StrContains(c_storestats[client], "o") >= 0)
605 {
606 PrintToChat(client, "You already purchased Overweight Vegetarian Tag! Use !tokentag to select your tag!");
607 }
608 else if (i_points[client] <= 3000)
609 {
610 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
611 }
612 }
613 else if (StrEqual(info, "руÑÑкий [3800 Tokens]", true))
614 {
615 if (i_points[client] >= 3800 && (StrContains(c_storestats[client], "p") < 0))
616 {
617 purchaseEntry = 18;
618 i_points[client] -= 3800;
619 sendMYSQL(client);
620 storeEntryMYSQL(client, purchaseEntry);
621 PrintToChat(client, "Purchased руÑÑкий Tag for 3800 UNLOZE tokens!");
622 PrintToChat(client, "Reconnect to the server to use !tokentag!");
623 }
624 else if (StrContains(c_storestats[client], "p") >= 0)
625 {
626 PrintToChat(client, "You already purchased руÑÑкий Tag! Use !tokentag to select your tag!");
627 }
628 else if (i_points[client] <= 3800)
629 {
630 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
631 }
632 }
633 else if (StrEqual(info, "NIGGER elites [11377 Tokens]", true))
634 {
635 if (i_points[client] >= 11377 && (StrContains(c_storestats[client], "q") < 0))
636 {
637 purchaseEntry = 19;
638 i_points[client] -= 11377;
639 sendMYSQL(client);
640 storeEntryMYSQL(client, purchaseEntry);
641 PrintToChat(client, "Purchased NIGGER elites Tag for 11377 UNLOZE tokens!");
642 PrintToChat(client, "Reconnect to the server to use !tokentag!");
643 }
644 else if (StrContains(c_storestats[client], "q") >= 0)
645 {
646 PrintToChat(client, "You already purchased NIGGER elites Tag! Use !tokentag to select your tag!");
647 }
648 else if (i_points[client] <= 11377)
649 {
650 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
651 }
652 }
653 else if (StrEqual(info, "BAGUETTE [7000 Tokens]", true))
654 {
655 if (i_points[client] >= 7000 && (StrContains(c_storestats[client], "r") < 0))
656 {
657 purchaseEntry = 20;
658 i_points[client] -= 7000;
659 sendMYSQL(client);
660 storeEntryMYSQL(client, purchaseEntry);
661 PrintToChat(client, "Purchased BAGUETTE Tag for 7000 UNLOZE tokens!");
662 PrintToChat(client, "Reconnect to the server to use !tokentag!");
663 }
664 else if (StrContains(c_storestats[client], "r") >= 0)
665 {
666 PrintToChat(client, "You already purchased BAGUETTE Tag! Use !tokentag to select your tag!");
667 }
668 else if (i_points[client] <= 7000)
669 {
670 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
671 }
672 }
673 else if (StrEqual(info, "DANE [15000 Tokens]", true))
674 {
675 if (i_points[client] >= 15000 && (StrContains(c_storestats[client], "s") < 0))
676 {
677 purchaseEntry = 21;
678 i_points[client] -= 15000;
679 sendMYSQL(client);
680 storeEntryMYSQL(client, purchaseEntry);
681 PrintToChat(client, "Purchased DANE Tag for 15000 UNLOZE tokens!");
682 PrintToChat(client, "Reconnect to the server to use !tokentag!");
683 }
684 else if (StrContains(c_storestats[client], "s") >= 0)
685 {
686 PrintToChat(client, "You already purchased DANE Tag! Use !tokentag to select your tag!");
687 }
688 else if (i_points[client] <= 15000)
689 {
690 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
691 }
692 }
693 else if (StrEqual(info, "WEEB [6000 Tokens]", true))
694 {
695 if (i_points[client] >= 6000 && (StrContains(c_storestats[client], "t") < 0))
696 {
697 purchaseEntry = 22;
698 i_points[client] -= 6000;
699 sendMYSQL(client);
700 storeEntryMYSQL(client, purchaseEntry);
701 PrintToChat(client, "Purchased WEEB Tag for 6000 UNLOZE tokens!");
702 PrintToChat(client, "Reconnect to the server to use !tokentag!");
703 }
704 else if (StrContains(c_storestats[client], "t") >= 0)
705 {
706 PrintToChat(client, "You already purchased WEEB Tag! Use !tokentag to select your tag!");
707 }
708 else if (i_points[client] <= 6000)
709 {
710 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
711 }
712 }
713 else if (StrEqual(info, "Nosteam Chad [20000 Tokens]", true))
714 {
715 if (i_points[client] >= 20000 && (StrContains(c_storestats[client], "u") < 0))
716 {
717 purchaseEntry = 23;
718 i_points[client] -= 20000;
719 sendMYSQL(client);
720 storeEntryMYSQL(client, purchaseEntry);
721 PrintToChat(client, "Purchased Nosteam Chad Tag for 20000 UNLOZE tokens!");
722 PrintToChat(client, "Reconnect to the server to use !tokentag!");
723 }
724 else if (StrContains(c_storestats[client], "u") >= 0)
725 {
726 PrintToChat(client, "You already purchased Nosteam Chad Tag! Use !tokentag to select your tag!");
727 }
728 else if (i_points[client] <= 20000)
729 {
730 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
731 }
732 }
733 else if (StrEqual(info, "Back", true))
734 {
735 cmd_shopmenu(client, 0);
736 }
737 }
738}
739
740public int PaintMenu_Handler(Menu menu, MenuAction action, int client, int choice)
741{
742 if (action == MenuAction_Select)
743 {
744 int purchaseEntry;
745 char info[32];
746 menu.GetItem(choice, info, sizeof(info));
747
748 static char SID[32];
749 GetClientAuthId(client, AuthId_Steam2, SID, sizeof(SID));
750
751 if (StrEqual(info, "Unlock size [4500 Tokens]", true))
752 {
753 if (i_points[client] >= 4500 && (StrContains(c_storestats[client], "b") < 0))
754 {
755 //this one does thank god not need an group on sourceban
756 purchaseEntry = 4;
757 i_points[client] -= 4500;
758 sendMYSQL(client);
759 storeEntryMYSQL(client, purchaseEntry);
760 PrintToChat(client, "Purchased Paintsize feature for 4500 UNLOZE tokens!");
761 PrintToChat(client, "use !paintsize to change paint size!");
762 }
763 else if (StrContains(c_storestats[client], "b") >= 0)
764 {
765 PrintToChat(client, "You already purchased Paintsize!");
766 }
767 else if (i_points[client] <= 4500)
768 {
769 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
770 }
771 }
772 else if (StrEqual(info, "Unlock paint [4000 Tokens]", true))
773 {
774 if (i_points[client] >= 4000 && (StrContains(c_storestats[client], "d") < 0))
775 {
776 purchaseEntry = 6;
777 i_points[client] -= 4000;
778 sendMYSQL(client);
779 storeEntryMYSQL(client, purchaseEntry);
780 PrintToChat(client, "Purchased paint feature for 4000 UNLOZE tokens!");
781 PrintToChat(client, "Reconnect to the server and use !paint to enable the feature!");
782 }
783 else if (StrContains(c_storestats[client], "d") >= 0)
784 {
785 PrintToChat(client, "You already purchased the paint feature!");
786 }
787 else if (i_points[client] <= 4000)
788 {
789 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
790 }
791 }
792 else if (StrEqual(info, "Unlock colour [5000 Tokens]", true))
793 {
794 if (i_points[client] >= 5000 && (StrContains(c_storestats[client], "e") < 0))
795 {
796 purchaseEntry = 7;
797 i_points[client] -= 5000;
798 sendMYSQL(client);
799 storeEntryMYSQL(client, purchaseEntry);
800 PrintToChat(client, "Purchased paintcolour feature for 5000 UNLOZE tokens!");
801 PrintToChat(client, "Reconnect to the server and use !paintcolour to enable the feature!");
802 }
803 else if (StrContains(c_storestats[client], "e") >= 0)
804 {
805 PrintToChat(client, "You already purchased the paintcolour feature!");
806 }
807 else if (i_points[client] <= 5000)
808 {
809 PrintToChat(client, "You only have %i UNLOZE tokens", i_points[client]);
810 }
811 }
812 else if (StrEqual(info, "Back", true))
813 {
814 cmd_shopmenu(client, 0);
815 }
816 }
817}
818
819//----------------------------------------------------------------------------------------------------
820// Purpose: verifications onmapstart/end/disconnect/connect/auth
821//----------------------------------------------------------------------------------------------------
822
823public void OnMapStart()
824{
825 DeleteAll(g_kZoneStats);
826 DeleteAll(g_kZoneStats);
827}
828
829public void OnMapEnd()
830{
831 DeleteAll(g_kZoneStats);
832 DeleteAll(g_kZoneStats);
833}
834
835
836public Action reloadgroups(Handle timer, any client)
837{
838 for (int i = 1; i <= MaxClients; i++)
839 {
840 if (IsValidClient1(i))
841 {
842 if (StrContains(c_storestats[i], "1") >= 0)
843 {
844 GrantTokens(client, 4);
845 }
846 if (StrContains(c_storestats[i], "a") >= 0)
847 {
848 GrantTokens(client, 1);
849 }
850 if (StrContains(c_storestats[i], "2") >= 0)
851 {
852 GrantTokens(client, 5);
853 }
854 if (StrContains(c_storestats[i], "c") >= 0)
855 {
856 GrantTokens(client, 3);
857 }
858 if (StrContains(c_storestats[i], "f") >= 0)
859 {
860 GrantTokens(client, 6);
861 }
862 if (StrContains(c_storestats[i], "g") >= 0)
863 {
864 GrantTokens(client, 7);
865 }
866 if (StrContains(c_storestats[i], "h") >= 0)
867 {
868 GrantTokens(client, 8);
869 }
870 if (StrContains(c_storestats[i], "i") >= 0)
871 {
872 GrantTokens(client, 9);
873 }
874 if (StrContains(c_storestats[i], "j") >= 0)
875 {
876 GrantTokens(client, 2);
877 }
878 }
879 }
880}
881
882public void OnClientDisconnect(int iClient)
883{
884 f_2kdmgPoints[iClient] = 0.0;
885 Format(c_storestats[iClient], sizeof(c_storestats), "");
886 i_points[iClient] = 0;
887 g_iclientSpawn[iClient] = 0;
888 g_bClientFilter[iClient] = false;
889 g_bDmgScale[iClient] = false;
890 g_bDmgOutput[iClient] = false;
891 g_iClientScore[iClient] = 0;
892 i_bDmgScale[iClient] = 0.0;
893}
894
895public void OnClientPostAdminCheck(int client)
896{
897 f_2kdmgPoints[client] = 0.0;
898 i_points[client] = 0;
899 CreateTimer(2.0, points_delay, client, TIMER_FLAG_NO_MAPCHANGE);
900}
901
902public Action points_delay(Handle timer, int client)
903{
904 receiveMYSQL(client);
905}
906
907public Action roundsettings(Handle timer, any data)
908{
909 for (int i = 1; i < MaxClients; i++)
910 {
911 if (IsValidClient(i))
912 {
913 g_kZoneStats.Rewind();
914 static char SID[32];
915 GetClientAuthId(i, AuthId_Steam2, SID, sizeof(SID));
916 if (KvJumpToKey(g_kZoneStats, SID, false))
917 {
918 int disabled = g_kZoneStats.GetNum("disabled", 0);
919 if (!disabled)
920 {
921 return;
922 }
923 i_bDmgScale[i] = disabled * 1.0;
924 g_iclientSpawn[i] = disabled * 10;
925 g_iClientScore[i] = disabled * 25;
926 g_bDmgScale[i] = true;
927 SetEntityHealth(i, GetClientHealth(i) + g_iclientSpawn[i]);
928 SetEntProp(i, Prop_Data, "m_iFrags", g_iClientScore[i]);
929 }
930 g_bClientFilter[i] = false;
931 }
932 }
933}
934
935public void OnClientPostAdminFilter(int i)
936{
937 if (StrContains(c_storestats[i], "1") >= 0)
938 {
939 GrantTokens(i, 4);
940 }
941 if (StrContains(c_storestats[i], "a") >= 0)
942 {
943 GrantTokens(i, 1);
944 }
945 if (StrContains(c_storestats[i], "2") >= 0)
946 {
947 GrantTokens(i, 5);
948 }
949 if (StrContains(c_storestats[i], "c") >= 0)
950 {
951 GrantTokens(i, 3);
952 }
953 if (StrContains(c_storestats[i], "f") >= 0)
954 {
955 GrantTokens(i, 6);
956 }
957 if (StrContains(c_storestats[i], "g") >= 0)
958 {
959 GrantTokens(i, 7);
960 }
961 if (StrContains(c_storestats[i], "h") >= 0)
962 {
963 GrantTokens(i, 8);
964 }
965 if (StrContains(c_storestats[i], "i") >= 0)
966 {
967 GrantTokens(i, 9);
968 }
969 if (StrContains(c_storestats[i], "j") >= 0)
970 {
971 GrantTokens(i, 2);
972 }
973}
974
975public void OnClientAuthorized(int client, const char[] auth)
976{
977 if (!IsFakeClient(client))
978 {
979 //has to be checked before onpostadmincheck because mysql takes a bit time
980 CheckFlagsMYSQL(client);
981
982 g_kZoneStats.Rewind();
983 if (KvJumpToKey(g_kZoneStats, auth, false))
984 {
985 int disabled = g_kZoneStats.GetNum("disabled", 0);
986 if (!disabled)
987 {
988 return;
989 }
990 i_bDmgScale[client] = disabled * 1.0;
991 g_iclientSpawn[client] = disabled * 10;
992 g_iClientScore[client] = disabled * 25;
993 g_bDmgScale[client] = true;
994 }
995 }
996}
997
998public OnClientPutInServer(int client)
999{
1000 SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamagePre);
1001}
1002
1003//----------------------------------------------------------------------------------------------------
1004// Purpose: zones
1005//----------------------------------------------------------------------------------------------------
1006//Zone_OnClientEntry
1007public int Zone_OnClientEntry(int client, char[] zone)
1008{
1009 //maybe GetClientTeam(client) == 3 turns it inconsistent
1010 if (IsValidClient(client) && (GetClientTeam(client) == 3))
1011 {
1012 if (StrContains(zone, "ZONE_PREFIX_CT", false) >= 0)
1013 {
1014 //add filter on player
1015 g_bClientFilter[client] = true;
1016 return 0;
1017 }
1018 }
1019 return 0;
1020}
1021
1022//----------------------------------------------------------------------------------------------------
1023// Purpose: hooks
1024//----------------------------------------------------------------------------------------------------
1025
1026public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
1027{
1028 CreateTimer(5.0, roundsettings, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
1029}
1030
1031
1032public void Event_RoundEnd(Handle event, const char[] name, bool dontBroadcast)
1033{
1034 int winner = GetEventInt(event, "winner");
1035 int g_iWinnerAmount = 0;
1036
1037 if ((winner == 3))
1038 {
1039 for (int i = 0; i < MaxClients; i++)
1040 {
1041 if(IsValidClient(i) && g_bClientFilter[i]) //put filter here
1042 {
1043 g_iWinnerAmount += 1;
1044 int extrahealth = 10;
1045 int extraScore = 25 + ((GetClientFrags(i)) - g_iClientScore[i]);
1046 g_iclientSpawn[i] += extrahealth;
1047
1048 i_bDmgScale[i] += 1.0;
1049 g_bDmgScale[i] = true;
1050
1051 //kills + GetClientFrags(iClient)
1052 g_iClientScore[i] += extraScore;
1053 i_points[i] += 20;
1054 sendMYSQL(i);
1055 PrintToChat(i, "Won stage. Upgraded Stats!");
1056 PrintToChat(i, "Health: %i", g_iclientSpawn[i]);
1057 //PrintToChat(i, "Damage: %f", i_bDmgScale{i} * 7.0);
1058 PrintToChat(i, "Clientscore: %i", g_iClientScore[i]);
1059 PrintToChat(i, "Earned 20 Unloze Tokens! Your amount: %i", i_points[i]);
1060
1061 static char SID[32];
1062 GetClientAuthId(i, AuthId_Steam2, SID, sizeof(SID));
1063
1064 g_kZoneStats.Rewind();
1065
1066 if(g_kZoneStats.JumpToKey(SID, true))
1067 {
1068 int disabled = g_kZoneStats.GetNum("disabled", 0);
1069 if(!disabled)
1070 {
1071 g_kZoneStats.SetNum("disabled", 1);
1072 }
1073 else if (disabled == 1)
1074 {
1075 g_kZoneStats.SetNum("disabled", 2);
1076 }
1077 else if (disabled == 2)
1078 {
1079 g_kZoneStats.SetNum("disabled", 3);
1080 }
1081 else if (disabled == 3)
1082 {
1083 g_kZoneStats.SetNum("disabled", 4);
1084 }
1085 else if (disabled == 4)
1086 {
1087 g_kZoneStats.SetNum("disabled", 5);
1088 }
1089 else if (disabled == 5)
1090 {
1091 g_kZoneStats.SetNum("disabled", 6);
1092 }
1093 else if (disabled == 6)
1094 {
1095 g_kZoneStats.SetNum("disabled", 7);
1096 }
1097 else if (disabled == 7)
1098 {
1099 g_kZoneStats.SetNum("disabled", 8);
1100 }
1101 else if (disabled == 8)
1102 {
1103 g_kZoneStats.SetNum("disabled", 9);
1104 }
1105 else if (disabled == 9)
1106 {
1107 g_kZoneStats.SetNum("disabled", 10);
1108 }
1109 else if (disabled == 10)
1110 {
1111 g_kZoneStats.SetNum("disabled", 11);
1112 }
1113
1114 g_kZoneStats.Rewind();
1115 g_kZoneStats.ExportToFile(g_sKVPATH);
1116 }
1117 }
1118 }
1119
1120
1121 for (int i = 0; i < MaxClients; i++)
1122 {
1123 if(IsValidClient(i) && g_bClientFilter[i] && g_iWinnerAmount < 2)
1124 {
1125 PrintToChatAll("Solo Won stage. Upgraded Stats and extra points added %d", GetConVarInt(G_hCvar_Points_Humans));
1126 //PrintToChatAll("g_iWinnerAmount: %d", g_iWinnerAmount);
1127 char sAuthID[64];
1128 i_points[i] += 60;
1129 sendMYSQL(i);
1130 PrintToChatAll("%N Earned 60 Unloze Tokens for solo win! Their amount: %i", i, i_points[i]);
1131 if (!GetClientAuthId(i, AuthId_Steam2, sAuthID, sizeof(sAuthID)))
1132 {
1133 Format(sAuthID, sizeof(sAuthID), "UNKNOWN");
1134 }
1135 LogToGame("\"%N<%d><%s><%s>\" triggered \"human_win_%i\"", i, GetClientUserId(i), sAuthID, "CT", GetConVarInt(G_hCvar_Points_Humans));
1136 }
1137 }
1138
1139 g_iWinnerAmount = 0;
1140 }
1141}
1142
1143//----------------------------------------------------------------------------------------------------
1144// Purpose: damageHook
1145//----------------------------------------------------------------------------------------------------
1146
1147public Action OnTakeDamagePre(victim, &attacker, &inflictor, &Float:damage, &damagetype)
1148{
1149 if(IsValidClient(attacker) && IsValidClient(victim))
1150 {
1151 if (victim > 0 && attacker <= MAXPLAYERS && GetClientTeam(victim) != GetClientTeam(attacker))
1152 {
1153 if (f_2kdmgPoints[attacker] >= 2000.0)
1154 {
1155 f_2kdmgPoints[attacker] = 0.0;
1156 PrintToChat(attacker, "You earned 1 UNLOZE token for 2000 Damage on Zombies!");
1157 i_points[attacker] += 1;
1158 sendMYSQL(attacker);
1159 }
1160 if (g_bDmgScale[attacker])
1161 {
1162 if (g_bDmgOutput[attacker])
1163 {
1164 PrintToChat(attacker, "Client %N ORIGINAL Damage: %f", attacker, damage);
1165 }
1166 damage += i_bDmgScale[attacker] * 7.0;
1167 f_2kdmgPoints[attacker] += damage;
1168 if (g_bDmgOutput[attacker])
1169 {
1170 PrintToChat(attacker, "Client %N POST Damage: %f", attacker, damage);
1171 PrintToChat(attacker, "Client %N i_bDmgScale: %i", attacker, i_bDmgScale[attacker]);
1172 }
1173 return Plugin_Changed;
1174 }
1175 else
1176 {
1177 f_2kdmgPoints[attacker] += damage;
1178 return Plugin_Changed;
1179 }
1180 }
1181 }
1182 return Plugin_Continue;
1183}
1184
1185 //----------------------------------------------------------------------------------------------------
1186// Purpose: stock & clean keyvalues just MISC
1187//----------------------------------------------------------------------------------------------------
1188
1189stock bool IsValidClient(int client, bool alive = false, bool bots = false)
1190{
1191 if (client > 0 && client <= MaxClients && IsClientInGame(client) && !IsFakeClient(client) && IsPlayerAlive(client))
1192 {
1193 return true;
1194 }
1195 return false;
1196}
1197
1198stock bool IsValidClient1(int client, bool alive = false, bool bots = false)
1199{
1200 if (client > 0 && client <= MaxClients && IsClientInGame(client) && !IsFakeClient(client))
1201 {
1202 return true;
1203 }
1204 return false;
1205}
1206
1207public void DeleteAll (KeyValues kv)
1208{
1209 kv.Rewind();
1210 if (kv.GotoFirstSubKey())
1211 {
1212 //PrintToChatAll("Reached first subkey");
1213 kv.DeleteThis();
1214 while (KvGotoNextKey(kv))
1215 {
1216 kv.DeleteThis();
1217 //PrintToChatAll("Deletes something?");
1218 }
1219 kv.DeleteThis();
1220 }
1221 kv.Rewind();
1222 kv.ExportToFile(g_sKVPATH);
1223 //PrintToChatAll("End?");
1224}
1225
1226//----------------------------------------------------------------------------------------------------
1227// Purpose: MYSQL queries
1228//----------------------------------------------------------------------------------------------------
1229
1230public void SQL_StartConnection()
1231{
1232 char error[255];
1233 Database db;
1234 if (SQL_CheckConfig("unloze_tracerpref"))
1235 {
1236 db = SQL_Connect("unloze_tracerpref", true, error, sizeof(error));
1237 }
1238 if (db == null)
1239 {
1240 PrintToChatAll("{green}[Unloze] {white}Error! Could not connect to MYSQL-DB!");
1241 delete db;
1242 return;
1243 }
1244 //create tables
1245 char sQuery[255];
1246 Format(sQuery, sizeof(sQuery), "CREATE TABLE IF NOT EXISTS `unloze_zonepoints` (`steam_id` VARCHAR(254) NOT NULL, `points` VARCHAR(254) NOT NULL, `storestats` VARCHAR(254) NOT NULL, PRIMARY KEY (`steam_id`))");
1247 SQL_TQuery(db, DummyCallbackSimple, sQuery);
1248
1249 delete db;
1250}
1251
1252
1253public void receiveMYSQL(int client)
1254{
1255 if (IsValidClient1(client))
1256 {
1257 char error[255];
1258 Database db;
1259 //the points not related to hlstats are stored together with tracer prefferences but have
1260 //their own table
1261 if (SQL_CheckConfig("unloze_tracerpref"))
1262 {
1263 db = SQL_Connect("unloze_tracerpref", true, error, sizeof(error));
1264 }
1265 if (db == null)
1266 {
1267 PrintToChat(client, "{green}[Unloze] {white}Error! Could not connect to MYSQL-DB!");
1268 delete db;
1269 return;
1270 }
1271 char sSID[64];
1272 GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
1273 char sQuery[512];
1274 Format(sQuery, sizeof(sQuery), "SELECT points FROM `unloze_zonepoints`WHERE `steam_id` = '%s'", sSID);
1275
1276 DBResultSet rs;
1277
1278 if ((rs = SQL_Query(db, sQuery)) == null)
1279 {
1280 delete db;
1281 delete rs;
1282 return;
1283 }
1284
1285 if (rs.FetchRow())
1286 {
1287 char points[512];
1288 SQL_FetchString(rs, 0, points, sizeof(points));
1289 i_points[client] = StringToInt(points);
1290 //PrintToChat(client, "Fetched row!");
1291 //PrintToChat(client, "%i", i_points[client]);
1292 }
1293 delete rs;
1294 delete db;
1295 }
1296}
1297
1298public void sendMYSQL(int client)
1299{
1300 if (IsValidClient1(client))
1301 {
1302 char error[255];
1303 Database db;
1304 //the points not related to hlstats are stored together with tracer prefferences but have
1305 //their own table
1306 if (SQL_CheckConfig("unloze_tracerpref"))
1307 {
1308 db = SQL_Connect("unloze_tracerpref", true, error, sizeof(error));
1309 }
1310 if (db == null)
1311 {
1312 PrintToChat(client, "{green}[Unloze] {white}Error! Could not connect to MYSQL-DB!");
1313 delete db;
1314 return;
1315 }
1316 char sSID[64];
1317 GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
1318 char sQuery[512];
1319 Format(sQuery, sizeof(sQuery), "INSERT INTO `unloze_zonepoints` (`steam_id`,`points`) VALUES ('%s','%i') ON DUPLICATE KEY UPDATE `points` = '%i'", sSID, i_points[client], i_points[client]);
1320 SQL_TQuery(db, DummyCallbackSimple, sQuery);
1321 delete db;
1322 }
1323}
1324
1325
1326public void storeEntryMYSQL(int client, int purchaseEntry)
1327{
1328 if (IsValidClient1(client))
1329 {
1330 char error[255];
1331 Database db;
1332 //the points not related to hlstats are stored together with tracer prefferences but have
1333 //their own table
1334 if (SQL_CheckConfig("unloze_tracerpref"))
1335 {
1336 db = SQL_Connect("unloze_tracerpref", true, error, sizeof(error));
1337 }
1338 if (db == null)
1339 {
1340 PrintToChat(client, "{green}[Unloze] {white}Error! Could not connect to MYSQL-DB!");
1341 delete db;
1342 return;
1343 }
1344 char sSID[64];
1345 GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
1346 char sQuery[512];
1347
1348 if (purchaseEntry == 1)
1349 {
1350 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, '1') WHERE `steam_id` = '%s'", sSID);
1351 //PrintToChat(client, "%s", sQuery);
1352 }
1353 else if (purchaseEntry == 2)
1354 {
1355 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'a') WHERE `steam_id` = '%s'", sSID);
1356 }
1357 else if (purchaseEntry == 3)
1358 {
1359 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, '2') WHERE `steam_id` = '%s'", sSID);
1360 }
1361 else if (purchaseEntry == 4)
1362 {
1363 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'b') WHERE `steam_id` = '%s'", sSID);
1364 }
1365 else if (purchaseEntry == 5)
1366 {
1367 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'c') WHERE `steam_id` = '%s'", sSID);
1368 }
1369 else if (purchaseEntry == 6)
1370 {
1371 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'd') WHERE `steam_id` = '%s'", sSID);
1372 }
1373 else if (purchaseEntry == 7)
1374 {
1375 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'e') WHERE `steam_id` = '%s'", sSID);
1376 }
1377 else if (purchaseEntry == 8)
1378 {
1379 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'f') WHERE `steam_id` = '%s'", sSID);
1380 }
1381 else if (purchaseEntry == 9)
1382 {
1383 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'g') WHERE `steam_id` = '%s'", sSID);
1384 }
1385 else if (purchaseEntry == 10)
1386 {
1387 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'h') WHERE `steam_id` = '%s'", sSID);
1388 }
1389 else if (purchaseEntry == 11)
1390 {
1391 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'i') WHERE `steam_id` = '%s'", sSID);
1392 }
1393 else if (purchaseEntry == 12)
1394 {
1395 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'j') WHERE `steam_id` = '%s'", sSID);
1396 }
1397 else if (purchaseEntry == 13)
1398 {
1399 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'k') WHERE `steam_id` = '%s'", sSID);
1400 }
1401 else if (purchaseEntry == 14)
1402 {
1403 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'l') WHERE `steam_id` = '%s'", sSID);
1404 }
1405 else if (purchaseEntry == 15)
1406 {
1407 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'm') WHERE `steam_id` = '%s'", sSID);
1408 }
1409 else if (purchaseEntry == 16)
1410 {
1411 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'n') WHERE `steam_id` = '%s'", sSID);
1412 }
1413 else if (purchaseEntry == 17)
1414 {
1415 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'o') WHERE `steam_id` = '%s'", sSID);
1416 }
1417 else if (purchaseEntry == 18)
1418 {
1419 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'p') WHERE `steam_id` = '%s'", sSID);
1420 }
1421 else if (purchaseEntry == 19)
1422 {
1423 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'q') WHERE `steam_id` = '%s'", sSID);
1424 }
1425 else if (purchaseEntry == 20)
1426 {
1427 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'r') WHERE `steam_id` = '%s'", sSID);
1428 }
1429 else if (purchaseEntry == 21)
1430 {
1431 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 's') WHERE `steam_id` = '%s'", sSID);
1432 }
1433 else if (purchaseEntry == 22)
1434 {
1435 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 't') WHERE `steam_id` = '%s'", sSID);
1436 }
1437 else if (purchaseEntry == 23)
1438 {
1439 Format(sQuery, sizeof(sQuery), "UPDATE unloze_zonepoints SET storestats = CONCAT(storestats, 'u') WHERE `steam_id` = '%s'", sSID);
1440 }
1441 DBResultSet rs;
1442
1443 if ((rs = SQL_Query(db, sQuery)) == null)
1444 {
1445 Format(sQuery, sizeof(sQuery), "ALTER TABLE `unloze_zonepoints` ADD COLUMN `storestats` VARCHAR(254) NOT NULL");
1446 SQL_TQuery(db, DummyCallbackSimple, sQuery);
1447 delete db;
1448 delete rs;
1449 return;
1450 }
1451
1452 SQL_TQuery(db, DummyCallbackSimple, sQuery);
1453
1454 delete rs;
1455 delete db;
1456 }
1457}
1458
1459public void CheckFlagsMYSQL(int client)
1460{
1461 char error[255];
1462 Database db;
1463 //the points not related to hlstats are stored together with tracer prefferences but have
1464 //their own table
1465 if (SQL_CheckConfig("unloze_tracerpref"))
1466 {
1467 db = SQL_Connect("unloze_tracerpref", true, error, sizeof(error));
1468 }
1469 if (db == null)
1470 {
1471 PrintToChat(client, "{green}[Unloze] {white}Error! Could not connect to MYSQL-DB!");
1472 delete db;
1473 return;
1474 }
1475 char sSID[64];
1476 GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
1477 char sQuery[512];
1478 Format(sQuery, sizeof(sQuery), "SELECT storestats FROM `unloze_zonepoints` WHERE `steam_id` = '%s'", sSID);
1479
1480 DBResultSet rs;
1481
1482 if ((rs = SQL_Query(db, sQuery)) == null)
1483 {
1484 delete db;
1485 delete rs;
1486 return;
1487 }
1488
1489 if (rs.FetchRow())
1490 {
1491 SQL_FetchString(rs, 0, c_storestats[client], MAX_NAME_LENGTH);
1492 }
1493 delete rs;
1494 delete db;
1495}
1496
1497//----------------------------------------------------------------------------------------------------
1498// Purpose: stock by zacade, stock by botox & MYSQL callback
1499//----------------------------------------------------------------------------------------------------
1500stock void ApplyGroupFlags(int client, const char[] group)
1501{
1502 AdminId AdmID;
1503 GroupId GrpID;
1504
1505 if ((AdmID = GetUserAdmin(client)) == INVALID_ADMIN_ID)
1506 {
1507 //PrintToChatAll("Creating new user for %L", client);
1508
1509 AdmID = CreateAdmin("");
1510 SetUserAdmin(client, AdmID, true);
1511 }
1512
1513 if ((GrpID = FindAdmGroup(group)) != INVALID_GROUP_ID)
1514 {
1515 if (AdminInheritGroup(AdmID, GrpID))
1516 {
1517 //PrintToChat(client, "%L added to group %s", client, group);
1518 }
1519 }
1520 else
1521 {
1522 //PrintToChatAll("%L group not found %s", client, group);
1523 }
1524}
1525
1526public void DummyCallbackSimple(Handle hOwner, Handle hChild, const char[] err, DataPack pack1)
1527{
1528 if (hOwner == null || hChild == null)
1529 {
1530 LogError("Query error. (%s)", err);
1531 }
1532}
1533
1534stock any clamp(any input, any min, any max)
1535{
1536 any retval = input < min ? min : input;
1537
1538 return retval > max ? max : retval;
1539}