· 7 years ago · Nov 08, 2018, 05:38 PM
1#include <amxmodx>
2#include <amxmisc>
3#include <fakemeta>
4#include <sqlx>
5
6#pragma semicolon 1
7
8#define PLUGIN_NAME "[JB] SupriseBox Event"
9#define PLUGIN_VERSION "1.0"
10
11#define SQL_DATABASE "elohell"
12#define SQL_TABLE "Hats"
13
14#define IsClientValid(%1) (1 <= %1 <= g_MaxClients)
15
16new const g_SupriseBoxModel[] = "models/jb_elohell/suprisebox.mdl";
17new const g_SupriseBoxClassName[] = "jb_suprisebox";
18
19enum
20{
21 Death,
22 Suprise
23};
24
25enum _:Hats
26{
27 None,
28 Afro,
29 Angel,
30 CheeseHead,
31 Devil,
32 FootBall,
33 HeadPhones,
34 Joker,
35 NarutoHead,
36 Spartan,
37 Popeye
38};
39
40enum _:Trade
41{
42 Sender,
43 Reciever
44}
45
46new const g_HatsInfo[Hats][][] =
47{
48 {"None", "", ""},
49 {"Afro", "90", "Easy"},
50 {"Angel", "85", "Easy"},
51 {"CheeseHead", "80", "Easy"},
52 {"Devil", "75", "Easy"},
53 {"FootBall", "70", "Meduim"},
54 {"HeadPhones", "65", "Meduim"},
55 {"Joker", "50", "Meduim"},
56 {"NarutoHead", "10", "Hard"},
57 {"Spartan", "7", "Insane"},
58 {"Popeye", "5", "Insane"}
59};
60
61new const g_HatsModel[Hats][] =
62{
63 "",
64 "models/jb_elohell/hat_afro.mdl",
65 "models/jb_elohell/hat_angel.mdl",
66 "models/jb_elohell/hat_cheesehead.mdl",
67 "models/jb_elohell/hat_devil.mdl",
68 "models/jb_elohell/hat_football.mdl",
69 "models/jb_elohell/hat_headphones.mdl",
70 "models/jb_elohell/hat_joker.mdl",
71 "models/jb_elohell/hat_narutohead.mdl",
72 "models/jb_elohell/hat_spartan.mdl",
73 "models/jb_elohell/hat_popeye.mdl"
74};
75
76new g_MaxClients;
77new g_Admin;
78new g_TradePlayers[Trade];
79new g_TradeInvetory[Trade];
80new Handle:g_Tuple;
81
82new bool:g_HaveHat[33][Hats];
83new g_ClientName[33][32];
84new g_ClientSteamID[33][32];
85new g_ChoosenMod[33];
86new g_EntityMod[2046];
87new g_ChoosenHat[33];
88new g_HatEntity[33];
89new g_Hats[33];
90new g_Boxes[33];
91new g_Chance[33];
92new Float:g_ClientOrigin[33][3];
93
94/*
95 Plugin Configs
96 */
97
98public plugin_init()
99{
100 register_plugin(PLUGIN_NAME, PLUGIN_VERSION, "DeagLe.Studio (Special for ELOHELL Community)");
101
102 register_saycmd("store", "Command_Store");
103 register_saycmd("trade", "Command_Trade");
104 register_saycmd("invetory", "Command_Invetory");
105
106 register_concmd("jb_suprisebox", "Command_SupriseBox", ADMIN_BAN);
107
108 register_forward(FM_Touch, "Hook_Touch");
109
110 g_MaxClients = get_maxplayers();
111
112 ConnectToDatabase();
113}
114
115public plugin_precache()
116{
117 static Iterator;
118
119 precache_model(g_SupriseBoxModel);
120
121 for (Iterator = Afro; Iterator <= Popeye; Iterator++)
122 {
123 precache_model(g_HatsModel[Iterator]);
124 }
125}
126
127public plugin_end()
128{
129 SQL_FreeHandle(g_Tuple);
130}
131
132public client_putinserver(Client)
133{
134 get_user_name(Client, g_ClientName[Client], charsmax(g_ClientName[]));
135 get_user_authid(Client, g_ClientSteamID[Client], charsmax(g_ClientSteamID[]));
136
137 LoadClientInfo(Client);
138}
139
140public client_disconnect(Client)
141{
142 SaveClientInfo(Client);
143}
144
145/*
146 Commands
147 */
148
149public Command_Store(Client)
150{
151 if (!g_Boxes[Client])
152 {
153 client_print(Client, print_chat, "You don't have box!");
154 return;
155 }
156
157 Menu_Store(Client);
158}
159
160public Command_Invetory(Client)
161{
162 if (!g_Hats[Client])
163 {
164 client_print(Client, print_chat, "You don't have hat!");
165 return;
166 }
167
168 Menu_Invetory(Client);
169}
170
171public Command_Trade(Client)
172{
173 if (!g_Hats[Client])
174 {
175 client_print(Client, print_chat, "You don't have hat!");
176 return;
177 }
178
179 Menu_Trade(Client);
180}
181
182public Command_SupriseBox(Client, Level, Cid)
183{
184 if (!cmd_access(Client, Level, Cid, 1))
185 {
186 return PLUGIN_CONTINUE;
187 }
188
189 Menu_Admin(Client);
190 return PLUGIN_CONTINUE;
191}
192
193/*
194 Menus
195 */
196
197public Menu_Store(Client)
198{
199 static Menu, Buffer[32];
200 Menu = menu_create("Store Menu", "MenuHandle_Store");
201
202 formatex(Buffer, charsmax(Buffer), "SupriseBox (%d)", g_Boxes[Client]);
203 menu_additem(Menu, Buffer);
204
205 menu_setprop(Menu, MPROP_NUMBER_COLOR, "\y");
206 menu_display(Client, Menu);
207}
208
209public MenuHandle_Store(Client, Menu, Item)
210{
211 switch (Item)
212 {
213 case 0:
214 {
215 if (!IsClientValid(g_Admin))
216 {
217 return PLUGIN_CONTINUE;
218 }
219
220 g_Boxes[Client]--;
221 g_Chance[Client] = random(100);
222
223 if (g_Chance[Client] >= str_to_num(g_HatsInfo[g_ChoosenHat[g_Admin]][1]))
224 {
225 if (g_HaveHat[Client][g_ChoosenHat[g_Admin]])
226 {
227 return PLUGIN_CONTINUE;
228 }
229
230 g_HaveHat[Client][g_ChoosenHat[g_Admin]] = true;
231
232 RemoveClientHat(Client);
233 SetClientHat(Client, g_ChoosenHat[g_Admin]);
234
235 client_print(Client, print_chat, "You won a hat: %s", g_HatsInfo[g_ChoosenHat[g_Admin]][0]);
236 }
237 else
238 {
239 client_print(Client, print_chat, "You lose a hat: %s", g_HatsInfo[g_ChoosenHat[g_Admin]][0]);
240 }
241
242 Menu_Store(Client);
243 }
244 case MENU_EXIT:
245 {
246 menu_destroy(Menu);
247 return PLUGIN_HANDLED;
248 }
249 }
250
251 return PLUGIN_CONTINUE;
252}
253
254public Menu_Invetory(Client)
255{
256 static Menu, Iterator;
257 Menu = menu_create("Invetory Menu", "MenuHandle_Invetory");
258
259 for (Iterator = Afro; Iterator <= Popeye; Iterator++)
260 {
261 if (!g_HaveHat[Client][Iterator])
262 {
263 continue;
264 }
265
266 menu_additem(Menu, g_HatsInfo[Iterator][0]);
267 }
268
269 menu_setprop(Menu, MPROP_NUMBER_COLOR, "\y");
270 menu_display(Client, Menu);
271}
272
273public MenuHandle_Invetory(Client, Menu, Item)
274{
275 switch (Item)
276 {
277 case MENU_EXIT:
278 {
279 menu_destroy(Menu);
280 return PLUGIN_HANDLED;
281 }
282 default:
283 {
284 RemoveClientHat(Client);
285 SetClientHat(Client, Item + 1);
286 }
287 }
288
289 menu_destroy(Menu);
290 return PLUGIN_HANDLED;
291}
292
293public Menu_Trade(Client)
294{
295 static Menu, Buffer[64];
296 Menu = menu_create("Trade Menu", "MenuHandle_Trade");
297
298 formatex(Buffer, charsmax(Buffer), "Your Invetory: %s", g_HatsInfo[g_TradeInvetory[Sender]][0]);
299 menu_addtext(Menu, Buffer);
300
301 formatex(Buffer, charsmax(Buffer), "His Invetory: %s", g_HatsInfo[g_TradeInvetory[Reciever]][0]);
302 menu_addtext(Menu, Buffer);
303
304 menu_addtext(Menu, "Choose Player");
305 menu_addtext(Menu, "\rStart Trade");
306
307 menu_setprop(Menu, MPROP_NUMBER_COLOR, "\y");
308 menu_display(Client, Menu);
309}
310
311public MenuHandle_Trade(Client, Menu, Item)
312{
313 switch (Item)
314 {
315 case 0:
316 {
317 Menu_TradeHats(Client);
318 }
319 case 1:
320 {
321 Menu_TradeHats2(Client);
322 }
323 case 2:
324 {
325 Menu_TradePlayers(Client);
326 }
327 case 3:
328 {
329 g_TradePlayers[Sender] = Client;
330 Menu_TradeGuide(g_TradePlayers[Reciever]);
331 }
332 case MENU_EXIT:
333 {
334 menu_destroy(Menu);
335 return PLUGIN_HANDLED;
336 }
337 }
338
339 menu_destroy(Menu);
340 return PLUGIN_HANDLED;
341}
342
343public Menu_TradeGuide(Client)
344{
345 static Menu, Buffer[64];
346 formatex(Buffer, charsmax(Buffer), "Trade From %s", g_ClientName[g_TradePlayers[Sender]]);
347
348 Menu = menu_create(Buffer, "MenuHandle_TradeGuide");
349
350 formatex(Buffer, charsmax(Buffer), "His Invetory: %s", g_HatsInfo[g_TradeInvetory[Sender]][0]);
351 menu_addtext(Menu, Buffer);
352
353 formatex(Buffer, charsmax(Buffer), "Your Invetory: %s", g_HatsInfo[g_TradeInvetory[Reciever]][0]);
354 menu_addtext(Menu, Buffer);
355
356 menu_addtext(Menu, "\yAgree");
357 menu_addtext(Menu, "\rDon't agree");
358
359 menu_setprop(Menu, MPROP_NUMBER_COLOR, "\y");
360 menu_display(Client, Menu);
361}
362
363public MenuHandle_TradeGuide(Client, Menu, Item)
364{
365 switch (Item)
366 {
367 case 2:
368 {
369 g_HaveHat[g_TradePlayers[Sender]][g_TradeInvetory[Sender]] = false;
370 g_HaveHat[g_TradePlayers[Sender]][g_TradeInvetory[Reciever]] = true;
371
372 g_HaveHat[g_TradePlayers[Reciever]][g_TradeInvetory[Reciever]] = false;
373 g_HaveHat[g_TradePlayers[Reciever]][g_TradeInvetory[Sender]] = true;
374
375 RemoveClientHat(g_TradePlayers[Sender]);
376 RemoveClientHat(g_TradePlayers[Reciever]);
377
378 SetClientHat(g_TradePlayers[Sender], g_TradeInvetory[Reciever]);
379 SetClientHat(g_TradePlayers[Reciever], g_TradeInvetory[Sender]);
380 }
381 case 3:
382 {
383 client_print(g_TradePlayers[Sender], print_chat, "%s didn't accept your trade!", g_ClientName[g_TradePlayers[Reciever]]);
384 return PLUGIN_HANDLED;
385 }
386 case MENU_EXIT:
387 {
388 menu_destroy(Menu);
389 return PLUGIN_HANDLED;
390 }
391 }
392
393 menu_destroy(Menu);
394 return PLUGIN_HANDLED;
395}
396
397public Menu_TradePlayers(Client)
398{
399 static Menu, Iterator;
400 Menu = menu_create("Choose Player", "MenuHandle_TradePlayers");
401
402 for (Iterator = 1; Iterator <= g_MaxClients; Iterator++)
403 {
404 if (!g_Hats[Iterator])
405 {
406 continue;
407 }
408
409 menu_additem(Menu, g_ClientName[Iterator]);
410 }
411
412 menu_setprop(Menu, MPROP_NUMBER_COLOR, "\y");
413 menu_display(Client, Menu);
414}
415
416public MenuHandle_TradePlayers(Client, Menu, Item)
417{
418 switch (Item)
419 {
420 case MENU_EXIT:
421 {
422 menu_destroy(Menu);
423 Menu_Trade(Client);
424 return PLUGIN_HANDLED;
425 }
426 default:
427 {
428 g_TradePlayers[Reciever] = Item;
429 Menu_Trade(Client);
430 }
431 }
432
433 menu_destroy(Menu);
434 return PLUGIN_HANDLED;
435}
436
437public Menu_TradeHats(Client)
438{
439 static Menu, Iterator;
440 Menu = menu_create("Choose Hat", "MenuHandle_TradeHats");
441
442 for (Iterator = Afro; Iterator <= Popeye; Iterator++)
443 {
444 if (!g_HaveHat[Client][Iterator])
445 {
446 continue;
447 }
448
449 menu_additem(Menu, g_HatsInfo[Iterator][0]);
450 }
451
452 menu_setprop(Menu, MPROP_NUMBER_COLOR, "\y");
453 menu_display(Client, Menu);
454}
455
456public MenuHandle_TradeHats(Client, Menu, Item)
457{
458 switch (Item)
459 {
460 case MENU_EXIT:
461 {
462 menu_destroy(Menu);
463 Menu_Trade(Client);
464 return PLUGIN_HANDLED;
465 }
466 default:
467 {
468 g_TradeInvetory[g_TradePlayers[Sender]] = Item;
469 Menu_Trade(Client);
470 }
471 }
472
473 menu_destroy(Menu);
474 return PLUGIN_HANDLED;
475}
476
477public Menu_TradeHats2(Client)
478{
479 static Menu, Iterator;
480 Menu = menu_create("Choose Hat", "MenuHandle_TradeHats2");
481
482 for (Iterator = Afro; Iterator <= Popeye; Iterator++)
483 {
484 if (!g_HaveHat[Client][Iterator])
485 {
486 continue;
487 }
488
489 menu_additem(Menu, g_HatsInfo[Iterator][0]);
490 }
491
492 menu_setprop(Menu, MPROP_NUMBER_COLOR, "\y");
493 menu_display(Client, Menu);
494}
495
496public MenuHandle_TradeHats2(Client, Menu, Item)
497{
498 switch (Item)
499 {
500 case MENU_EXIT:
501 {
502 menu_destroy(Menu);
503 Menu_Trade(Client);
504 return PLUGIN_HANDLED;
505 }
506 default:
507 {
508 g_TradeInvetory[g_TradePlayers[Reciever]] = Item;
509 Menu_Trade(Client);
510 }
511 }
512
513 menu_destroy(Menu);
514 return PLUGIN_HANDLED;
515}
516
517public Menu_Admin(Client)
518{
519 static Menu, Buffer[32];
520 Menu = menu_create("SupriseBox Admin Menu", "MenuHandle_Admin");
521
522 formatex(Buffer, charsmax(Buffer), "Mod of %s", g_ChoosenMod[Client] == Death ? "Death" : "Suprise");
523 menu_additem(Menu, Buffer);
524
525 formatex(Buffer, charsmax(Buffer), "%sSupriseBox of %s", g_ChoosenMod[Client] == Death ? "\d" : "\w", g_HatsInfo[g_ChoosenHat[Client]][0]);
526 menu_additem(Menu, Buffer);
527
528 menu_additem(Menu, "\rSpawn SupriseBox");
529
530 menu_setprop(Menu, MPROP_NUMBER_COLOR, "\y");
531 menu_display(Client, Menu);
532}
533
534public MenuHandle_Admin(Client, Menu, Item)
535{
536 switch (Item)
537 {
538 case 0:
539 {
540 g_ChoosenMod[Client] = g_ChoosenMod[Client] == Death ? Suprise : Death;
541 Menu_Admin(Client);
542 }
543 case 1:
544 {
545 if (g_ChoosenMod[Client] == Death)
546 {
547 Menu_Admin(Client);
548 return PLUGIN_HANDLED;
549 }
550
551 Menu_Hats(Client);
552 }
553 case 2:
554 {
555 g_Admin = Client;
556
557 pev(Client, pev_origin, g_ClientOrigin[Client]);
558 set_task(2.0, "Task_CreateBox", Client);
559
560 Menu_Admin(Client);
561 }
562 case MENU_EXIT:
563 {
564 menu_destroy(Menu);
565 return PLUGIN_HANDLED;
566 }
567 }
568
569 return PLUGIN_CONTINUE;
570}
571
572public Menu_Hats(Client)
573{
574 static Menu, Iterator, Buffer[32];
575 Menu = menu_create("Choose Hat", "MenuHandle_Hats");
576
577 for (Iterator = Afro; Iterator <= Popeye; Iterator++)
578 {
579 formatex(Buffer, charsmax(Buffer), "%s - %s% Chance - %s", g_HatsInfo[Iterator][0], g_HatsInfo[Iterator][1], g_HatsInfo[Iterator][2]);
580 menu_additem(Menu, Buffer);
581 }
582
583 menu_setprop(Menu, MPROP_NUMBER_COLOR, "\y");
584 menu_display(Client, Menu);
585}
586
587public MenuHandle_Hats(Client, Menu, Item)
588{
589 switch (Item)
590 {
591 case MENU_EXIT:
592 {
593 menu_destroy(Menu);
594 Menu_Admin(Client);
595 return PLUGIN_HANDLED;
596 }
597 default:
598 {
599 g_ChoosenHat[Client] = Item + 1;
600 Menu_Admin(Client);
601 }
602 }
603
604 menu_destroy(Menu);
605 return PLUGIN_HANDLED;
606}
607
608/*
609 Tasks
610 */
611
612public Task_CreateBox(Client)
613{
614 static Entity;
615
616 Entity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
617
618 if (pev_valid(Entity))
619 {
620 set_pev(Entity, pev_classname, g_SupriseBoxClassName);
621 set_pev(Entity, pev_solid, SOLID_BBOX);
622 set_pev(Entity, pev_movetype, MOVETYPE_TOSS);
623 set_pev(Entity, pev_origin, g_ClientOrigin[Client]);
624
625 engfunc(EngFunc_SetModel, Entity, g_SupriseBoxModel);
626 engfunc(EngFunc_SetSize, Entity, {-2.0, -2.0, -2.0}, {5.0, 5.0, 5.0});
627
628 g_EntityMod[Entity] = g_ChoosenMod[Client];
629 }
630}
631
632
633/*
634 Hooks
635 */
636
637public Hook_Touch(Entity, Touched)
638{
639 if (!pev_valid(Entity) || !pev_valid(Touched))
640 {
641 return FMRES_IGNORED;
642 }
643
644 static ClassName[32], TouchedClassName[32];
645 pev(Entity, pev_classname, ClassName, charsmax(ClassName));
646 pev(Touched, pev_classname, TouchedClassName, charsmax(TouchedClassName));
647
648 if (equal(ClassName, "player") && equal(TouchedClassName, g_SupriseBoxClassName))
649 {
650 if (g_EntityMod[Touched] == Death)
651 {
652 user_silentkill(Entity);
653 }
654 else
655 {
656 g_Boxes[Entity]++;
657 }
658
659 engfunc(EngFunc_RemoveEntity, Touched);
660 return FMRES_SUPERCEDE;
661 }
662
663 return FMRES_IGNORED;
664}
665
666/*
667 Main Functions
668 */
669SetClientHat(Client, Hat)
670{
671 g_HatEntity[Client] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
672
673 if (pev_valid(g_HatEntity[Client]))
674 {
675 set_pev(g_HatEntity[Client], pev_movetype, MOVETYPE_FOLLOW);
676 set_pev(g_HatEntity[Client], pev_aiment, Client);
677
678 engfunc(EngFunc_SetModel, g_HatEntity[Client], g_HatsModel[Hat]);
679 }
680
681 g_Hats[Client]++;
682}
683
684RemoveClientHat(Client)
685{
686 if (!pev_valid(g_HatEntity[Client]))
687 {
688 return;
689 }
690
691 engfunc(EngFunc_RemoveEntity, g_HatEntity[Client]);
692}
693
694LoadClientInfo(Client)
695{
696 static Buffer[512], Data[2];
697 formatex(Buffer, charsmax(Buffer), "SELECT * FROM `%s` WHERE (`%s`.`SteamID` = '%s')", SQL_TABLE, SQL_TABLE, g_ClientSteamID[Client]);
698 num_to_str(Client, Data, charsmax(Data));
699
700 SQL_ThreadQuery(g_Tuple, "LoadQuery", Buffer, Data, charsmax(Data));
701}
702
703public LoadQuery(FailState, Handle:Query, Error[], ErrorCode, Data[], Length)
704{
705 static Client, Buffer[1024];
706
707 switch(FailState)
708 {
709 case TQUERY_CONNECT_FAILED:
710 {
711 log_amx("Load - Could not connect to MySql database. [%d] %s", ErrorCode, Error);
712 }
713 case TQUERY_QUERY_FAILED:
714 {
715 log_amx("Load query failed. [%d] %s", ErrorCode, Error);
716 }
717 }
718
719 Client = Data[0];
720
721 if (SQL_NumResults(Query) < 10)
722 {
723 formatex(Buffer, charsmax(Buffer), "INSERT INTO `%s` (`SteamID`, `Afro`, `Angel`, `CheeseHead`, `Devil`, `Joker`, `NarutoHead`, `Spartan`, `Popeye`) VALUES ('%s', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');", SQL_TABLE, g_ClientSteamID[Client]);
724 SQL_ThreadQuery(g_Tuple, "IgnoreQuery", Buffer);
725 }
726 else
727 {
728 g_HaveHat[Client][Afro] = SQL_ReadResult(Query, 1) ? true : false;
729 g_HaveHat[Client][Angel] = SQL_ReadResult(Query, 2) ? true : false;
730 g_HaveHat[Client][CheeseHead] = SQL_ReadResult(Query, 3) ? true : false;
731 g_HaveHat[Client][Devil] = SQL_ReadResult(Query, 4) ? true : false;
732 g_HaveHat[Client][FootBall] = SQL_ReadResult(Query, 5) ? true : false;
733 g_HaveHat[Client][HeadPhones] = SQL_ReadResult(Query, 6) ? true : false;
734 g_HaveHat[Client][Joker] = SQL_ReadResult(Query, 7) ? true : false;
735 g_HaveHat[Client][NarutoHead] = SQL_ReadResult(Query, 8) ? true : false;
736 g_HaveHat[Client][Spartan] = SQL_ReadResult(Query, 9) ? true : false;
737 g_HaveHat[Client][Popeye] = SQL_ReadResult(Query, 10) ? true : false;
738 }
739}
740
741SaveClientInfo(Client)
742{
743 static Buffer[512];
744 formatex(Buffer, charsmax(Buffer), "UPDATE `%s` SET `Afro` = '%d', `Angel` = '%d', `CheeseHead` = '%d', `Devil` = '%d', `Joker` = '%d', `NarutoHead` = '%d', `Spartan` = '%d', `Popeye` = '%d' WHERE `%s`.`SteamID` = '%s';",
745 SQL_TABLE, g_HaveHat[Client][Afro] ? 1 : 0, g_HaveHat[Client][Angel] ? 1 : 0, g_HaveHat[Client][CheeseHead] ? 1 : 0,
746 g_HaveHat[Client][Devil] ? 1 : 0, g_HaveHat[Client][FootBall] ? 1 : 0, g_HaveHat[Client][HeadPhones] ? 1 : 0,
747 g_HaveHat[Client][Joker] ? 1 : 0, g_HaveHat[Client][NarutoHead] ? 1 : 0, g_HaveHat[Client][Spartan] ? 1 : 0,
748 g_HaveHat[Client][Popeye] ? 1 : 0, g_ClientSteamID[Client]);
749
750 SQL_ThreadQuery(g_Tuple, "IgnoreQuery", Buffer);
751}
752
753public IgnoreQuery(FailState, Handle:Query, Error[], ErrorCode, Data[], Length)
754{
755 SQL_FreeHandle(Query);
756}
757
758ConnectToDatabase()
759{
760 static Handle:Connection, Handle:Query, Error[256], ErrorCode;
761
762 g_Tuple = SQL_MakeDbTuple("", "", "", SQL_DATABASE);
763 Connection = SQL_Connect(g_Tuple, ErrorCode, Error, charsmax(Error));
764
765 if (!Connection)
766 {
767 set_fail_state(Error);
768 }
769
770 Query = SQL_PrepareQuery(Connection, "CREATE TABLE IF NOT EXISTS %s (SteamID varchar(32), Afro INT(1), Angel INT(1), CheeseHead INT(1), Devil INT(1), FootBall INT(1), HeadPhones INT(1), Joker INT(1), NarutoHead INT(1), Spartan INT(1), Popeye INT(1))", SQL_TABLE);
771
772 if (!SQL_Execute(Query))
773 {
774 SQL_QueryError(Query, Error, charsmax(Error));
775 set_fail_state(Error);
776 }
777
778 SQL_FreeHandle(Query);
779 SQL_FreeHandle(Connection);
780}
781
782/*
783 Stocks
784 */
785
786stock register_saycmd(const Command[], const Function[])
787{
788 static Buffer[32];
789
790 formatex(Buffer, charsmax(Buffer), "say %s", Command);
791 register_clcmd(Buffer, Function);
792
793 formatex(Buffer, charsmax(Buffer), "say /%s", Command);
794 register_clcmd(Buffer, Function);
795
796 formatex(Buffer, charsmax(Buffer), "say .%s", Command);
797 register_clcmd(Buffer, Function);
798
799 formatex(Buffer, charsmax(Buffer), "say_team %s", Command);
800 register_clcmd(Buffer, Function);
801
802 formatex(Buffer, charsmax(Buffer), "say_team /%s", Command);
803 register_clcmd(Buffer, Function);
804
805 formatex(Buffer, charsmax(Buffer), "say_team .%s", Command);
806 register_clcmd(Buffer, Function);
807}