· 9 years ago · Dec 20, 2016, 08:44 PM
1#include <sourcemod>
2#include <sdktools>
3#include <cstrike>
4#include <sdkhooks>
5#include <colors>
6
7#define IDAYS 26
8
9#undef REQUIRE_PLUGIN
10
11new Handle:db;
12
13#define MAX_PAINTS 800
14
15enum Listados
16{
17 String:Nombre[64],
18 index,
19 Float:wear,
20 stattrak,
21 quality,
22 pattern,
23 String:flag[8]
24}
25
26new Handle:menuw = INVALID_HANDLE;
27new g_paints[MAX_PAINTS][Listados];
28new g_paintCount = 0;
29new String:path_paints[PLATFORM_MAX_PATH];
30
31new bool:g_hosties = false;
32
33new bool:g_c4;
34new Handle:cvar_c4;
35
36new Handle:arbol[MAXPLAYERS+1] = INVALID_HANDLE;
37new Handle:menu1[MAXPLAYERS+1] = INVALID_HANDLE;
38
39new Handle:saytimer;
40new Handle:cvar_saytimer;
41new g_saytimer;
42
43new Handle:rtimer;
44new Handle:cvar_rtimer;
45new g_rtimer;
46
47new Handle:cvar_rmenu;
48new bool:g_rmenu;
49
50new Handle:cvar_onlyadmin;
51new bool:onlyadmin;
52
53new Handle:cvar_zombiesv;
54new bool:zombiesv;
55
56new String:s_arma[MAXPLAYERS+1][64];
57new s_sele[MAXPLAYERS+1];
58
59new ismysql;
60
61new Handle:array_paints;
62new Handle:array_armas;
63
64#define DATA "2.8.4 public version"
65
66//new String:base[64] = "weaponpaints";
67
68new bool:uselocal = false;
69
70new bool:comprobado41[MAXPLAYERS+1];
71
72
73public Plugin:myinfo =
74{
75 name = "WS Wizard Gaming",
76 author = "Franc1sco franug",
77 description = "",
78 version = DATA,
79 url = "http://steamcommunity.com/id/franug"
80};
81
82new String:g_sCmdLogPath[256];
83
84public OnPluginStart()
85{
86 for(new i=0;;i++)
87 {
88 BuildPath(Path_SM, g_sCmdLogPath, sizeof(g_sCmdLogPath), "logs/weaponpaints_%d.log", i);
89 if ( !FileExists(g_sCmdLogPath) )
90 break;
91 }
92
93 LoadTranslations ("franug_weaponpaints.phrases");
94
95 CreateConVar("sm_wpaints_version", DATA, "", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_CHEAT|FCVAR_DONTRECORD);
96
97 HookEvent("round_start", roundStart);
98
99 RegConsoleCmd("buyammo1", GetSkins);
100 RegConsoleCmd("sm_ws", GetSkins);
101 RegConsoleCmd("sm_wskins", GetSkins);
102 RegConsoleCmd("sm_paints", GetSkins);
103
104 RegAdminCmd("sm_reloadwskins", ReloadSkins, ADMFLAG_ROOT);
105
106 cvar_c4 = CreateConVar("sm_weaponpaints_c4", "1", "Enable or disable that people can apply paints to the C4. 1 = enabled, 0 = disabled");
107 cvar_saytimer = CreateConVar("sm_weaponpaints_saytimer", "10", "Time in seconds for block that show the plugin commands in chat when someone type a command. -1.0 = never show the commands in chat");
108 cvar_rtimer = CreateConVar("sm_weaponpaints_roundtimer", "20", "Time in seconds roundstart for can use the commands for change the paints. -1.0 = always can use the command");
109 cvar_rmenu = CreateConVar("sm_weaponpaints_rmenu", "1", "Re-open the menu when you select a option. 1 = enabled, 0 = disabled.");
110 cvar_onlyadmin = CreateConVar("sm_weaponpaints_onlyadmin", "1", "This feature is only for admins. 1 = enabled, 0 = disabled.");
111 cvar_zombiesv = CreateConVar("sm_weaponpaints_zombiesv", "1", "Enable this for prevent crashes in zombie servers. 1 = enabled, 0 = disabled.");
112
113 g_c4 = GetConVarBool(cvar_c4);
114 g_saytimer = GetConVarInt(cvar_saytimer);
115 g_rtimer = GetConVarInt(cvar_rtimer);
116 g_rmenu = GetConVarBool(cvar_rmenu);
117 onlyadmin = GetConVarBool(cvar_onlyadmin);
118 zombiesv = GetConVarBool(cvar_zombiesv);
119
120 HookConVarChange(cvar_c4, OnConVarChanged);
121 HookConVarChange(cvar_saytimer, OnConVarChanged);
122 HookConVarChange(cvar_rtimer, OnConVarChanged);
123 HookConVarChange(cvar_rmenu, OnConVarChanged);
124 HookConVarChange(cvar_onlyadmin, OnConVarChanged);
125 HookConVarChange(cvar_zombiesv, OnConVarChanged);
126
127 array_paints = CreateArray(64);
128 ReadPaints();
129
130 new String:Items[64];
131
132 if(array_armas != INVALID_HANDLE) CloseHandle(array_armas);
133
134 array_armas = CreateArray(128);
135
136 Format(Items, 64, "negev");
137 //Format(Items[desc], 64, "Negev");
138 PushArrayString(array_armas, Items);
139
140 Format(Items, 64, "m249");
141 //Format(Items[desc], 64, "M249");
142 PushArrayString(array_armas, Items);
143
144 Format(Items, 64, "bizon");
145 //Format(Items[desc], 64, "PP-Bizon");
146 PushArrayString(array_armas, Items);
147
148 Format(Items, 64, "p90");
149 //Format(Items[desc], 64, "P90");
150 PushArrayString(array_armas, Items);
151
152 Format(Items, 64, "scar20");
153 //Format(Items[desc], 64, "SCAR-20");
154 PushArrayString(array_armas, Items);
155
156 Format(Items, 64, "g3sg1");
157 //Format(Items[desc], 64, "G3SG1");
158 PushArrayString(array_armas, Items);
159
160 Format(Items, 64, "m4a1");
161 //Format(Items[desc], 64, "M4A1");
162 PushArrayString(array_armas, Items);
163
164 Format(Items, 64, "m4a1_silencer");
165 //Format(Items[desc], 64, "M4A1-S");
166 PushArrayString(array_armas, Items);
167
168 Format(Items, 64, "ak47");
169 //Format(Items[desc], 64, "AK-47");
170 PushArrayString(array_armas, Items);
171
172 Format(Items, 64, "aug");
173 //Format(Items[desc], 64, "AUG");
174 PushArrayString(array_armas, Items);
175
176 Format(Items, 64, "galilar");
177 //Format(Items[desc], 64, "Galil AR");
178 PushArrayString(array_armas, Items);
179
180 Format(Items, 64, "awp");
181 //Format(Items[desc], 64, "AWP");
182 PushArrayString(array_armas, Items);
183
184 Format(Items, 64, "sg556");
185 //Format(Items[desc], 64, "SG 553");
186 PushArrayString(array_armas, Items);
187
188 Format(Items, 64, "ump45");
189 //Format(Items[desc], 64, "UMP-45");
190 PushArrayString(array_armas, Items);
191
192 Format(Items, 64, "mp7");
193 //Format(Items[desc], 64, "MP7");
194 PushArrayString(array_armas, Items);
195
196 Format(Items, 64, "famas");
197 //Format(Items[desc], 64, "FAMAS");
198 PushArrayString(array_armas, Items);
199
200 Format(Items, 64, "mp9");
201 //Format(Items[desc], 64, "MP9");
202 PushArrayString(array_armas, Items);
203
204 Format(Items, 64, "mac10");
205 //Format(Items[desc], 64, "MAC-10");
206 PushArrayString(array_armas, Items);
207
208 Format(Items, 64, "ssg08");
209 //Format(Items[desc], 64, "SSG 08");
210 PushArrayString(array_armas, Items);
211
212 Format(Items, 64, "nova");
213 //Format(Items[desc], 64, "Nova");
214 PushArrayString(array_armas, Items);
215
216 Format(Items, 64, "xm1014");
217 //Format(Items[desc], 64, "XM1014");
218 PushArrayString(array_armas, Items);
219
220 Format(Items, 64, "sawedoff");
221 //Format(Items[desc], 64, "Sawed-Off");
222 PushArrayString(array_armas, Items);
223
224 Format(Items, 64, "mag7");
225 //Format(Items[desc], 64, "MAG-7");
226 PushArrayString(array_armas, Items);
227
228
229
230 // Secondary weapons
231 Format(Items, 64, "elite");
232 //Format(Items[desc], 64, "Dual Berettas");
233 PushArrayString(array_armas, Items);
234
235 Format(Items, 64, "deagle");
236 //Format(Items[desc], 64, "Desert Eagle");
237 PushArrayString(array_armas, Items);
238
239 Format(Items, 64, "tec9"); // 26
240 //Format(Items[desc], 64, "Tec-9");
241 PushArrayString(array_armas, Items);
242
243 Format(Items, 64, "fiveseven");
244 //Format(Items[desc], 64, "Five-SeveN");
245 PushArrayString(array_armas, Items);
246
247 Format(Items, 64, "cz75a");
248 //Format(Items[desc], 64, "CZ75-Auto");
249 PushArrayString(array_armas, Items);
250
251 Format(Items, 64, "glock");
252 PushArrayString(array_armas, Items);
253
254 Format(Items, 64, "usp_silencer");
255 //Format(Items[desc], 64, "USP-S");
256 PushArrayString(array_armas, Items);
257
258 Format(Items, 64, "p250");
259 //Format(Items[desc], 64, "P250");
260 PushArrayString(array_armas, Items);
261
262 Format(Items, 64, "hkp2000");
263 //Format(Items[desc], 64, "P2000");
264 PushArrayString(array_armas, Items);
265
266 Format(Items, 64, "bayonet");
267 PushArrayString(array_armas, Items);
268
269 Format(Items, 64, "knife_gut");
270 PushArrayString(array_armas, Items);
271
272 Format(Items, 64, "knife_flip");
273 PushArrayString(array_armas, Items);
274
275 Format(Items, 64, "knife_m9_bayonet");
276 PushArrayString(array_armas, Items);
277
278 Format(Items, 64, "knife_karambit");
279 PushArrayString(array_armas, Items);
280
281 Format(Items, 64, "knife_tactical");
282 PushArrayString(array_armas, Items);
283
284 Format(Items, 64, "knife_butterfly");
285 PushArrayString(array_armas, Items);
286
287 Format(Items, 64, "c4");
288 PushArrayString(array_armas, Items);
289
290 Format(Items, 64, "knife_falchion");
291 PushArrayString(array_armas, Items);
292
293 Format(Items, 64, "knife_push");
294 PushArrayString(array_armas, Items);
295
296 Format(Items, 64, "revolver");
297 PushArrayString(array_armas, Items);
298
299 Format(Items, 64, "knife_survival_bowie");
300 PushArrayString(array_armas, Items);
301
302 for (new client = 1; client <= MaxClients; client++)
303 {
304 if (!IsClientInGame(client))
305 continue;
306
307 OnClientPutInServer(client);
308
309 }
310
311 ComprobarDB(true, "weaponpaints");
312}
313
314public OnConVarChanged(Handle:convar, const String:oldValue[], const String:newValue[])
315{
316 if (convar == cvar_c4)
317 {
318 g_c4 = bool:StringToInt(newValue);
319 }
320 else if (convar == cvar_saytimer)
321 {
322 g_saytimer = StringToInt(newValue);
323 }
324 else if (convar == cvar_rtimer)
325 {
326 g_rtimer = StringToInt(newValue);
327 }
328 else if (convar == cvar_rmenu)
329 {
330 g_rmenu = bool:StringToInt(newValue);
331 }
332 else if (convar == cvar_onlyadmin)
333 {
334 onlyadmin = bool:StringToInt(newValue);
335 }
336 else if (convar == cvar_zombiesv)
337 {
338 zombiesv = bool:StringToInt(newValue);
339 }
340}
341
342ComprobarDB(bool:reconnect = false,String:basedatos[64] = "weaponpaints")
343{
344 if(uselocal) basedatos = "clientprefs";
345 if(reconnect)
346 {
347 if (db != INVALID_HANDLE)
348 {
349 //LogMessage("Reconnecting DB connection");
350 CloseHandle(db);
351 db = INVALID_HANDLE;
352 }
353 }
354 else if (db != INVALID_HANDLE)
355 {
356 return;
357 }
358
359 if (!SQL_CheckConfig( basedatos ))
360 {
361 if(StrEqual(basedatos, "clientprefs")) SetFailState("Databases not found");
362 else
363 {
364 //base = "clientprefs";
365 ComprobarDB(true,"clientprefs");
366 uselocal = true;
367 }
368
369 return;
370 }
371 SQL_TConnect(OnSqlConnect, basedatos);
372}
373
374public OnSqlConnect(Handle:owner, Handle:hndl, const String:error[], any:data)
375{
376 if (hndl == INVALID_HANDLE)
377 {
378 LogToFileEx(g_sCmdLogPath, "Database failure: %s", error);
379
380 SetFailState("Databases dont work");
381 }
382 else
383 {
384 db = hndl;
385 decl String:buffer[3096];
386
387 SQL_GetDriverIdent(SQL_ReadDriver(db), buffer, sizeof(buffer));
388 ismysql = StrEqual(buffer,"mysql", false) ? 1 : 0;
389
390 new String:temp[64][44];
391 for(new i=0;i<GetArraySize(array_armas);++i)
392 {
393 GetArrayString(array_armas, i, temp[i], 64);
394 }
395 if (ismysql == 1)
396 {
397 Format(buffer, sizeof(buffer), "CREATE TABLE IF NOT EXISTS `weaponpaints` (`playername` varchar(128) NOT NULL, `steamid` varchar(32) NOT NULL, `last_accountuse` int(64) NOT NULL, `%s` varchar(64) NOT NULL DEFAULT 'none', `%s` varchar(64) NOT NULL DEFAULT 'none', `%s` varchar(64) NOT NULL DEFAULT 'none', `%s` varchar(64) NOT NULL DEFAULT 'none', `%s` varchar(64) NOT NULL DEFAULT 'none', `%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`favorite1` varchar(64) NOT NULL DEFAULT 'none',`favorite2` varchar(64) NOT NULL DEFAULT 'none',`favorite3` varchar(64) NOT NULL DEFAULT 'none',`favorite4` varchar(64) NOT NULL DEFAULT 'none',`favorite5` varchar(64) NOT NULL DEFAULT 'none',`favorite6` varchar(64) NOT NULL DEFAULT 'none',`favorite7` varchar(64) NOT NULL DEFAULT 'none',PRIMARY KEY (`steamid`))",temp[0],temp[1],temp[2],temp[3],temp[4],temp[5],temp[6],temp[7],temp[8],temp[9],temp[10],temp[11],temp[12],temp[13],temp[14],temp[15],temp[16],temp[17],temp[18],temp[19],temp[20],temp[21],temp[22],temp[23],temp[24],temp[25],temp[26],temp[27],temp[28],temp[29],temp[30],temp[31],temp[32],temp[33],temp[34],temp[35],temp[36],temp[37],temp[38],temp[39],temp[40], temp[41], temp[42], temp[43]);
398
399 LogToFileEx(g_sCmdLogPath, "Query %s", buffer);
400 SQL_TQuery(db, tbasicoC, buffer);
401
402 }
403 else
404 {
405 Format(buffer, sizeof(buffer), "CREATE TABLE IF NOT EXISTS weaponpaints (playername varchar(128) NOT NULL, steamid varchar(32) NOT NULL, last_accountuse int(64) NOT NULL, %s varchar(64) NOT NULL DEFAULT 'none', %s varchar(64) NOT NULL DEFAULT 'none', %s varchar(64) NOT NULL DEFAULT 'none', %s varchar(64) NOT NULL DEFAULT 'none', %s varchar(64) NOT NULL DEFAULT 'none', %s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',favorite1 varchar(64) NOT NULL DEFAULT 'none',favorite2 varchar(64) NOT NULL DEFAULT 'none',favorite3 varchar(64) NOT NULL DEFAULT 'none',favorite4 varchar(64) NOT NULL DEFAULT 'none',favorite5 varchar(64) NOT NULL DEFAULT 'none',favorite6 varchar(64) NOT NULL DEFAULT 'none',favorite7 varchar(64) NOT NULL DEFAULT 'none',PRIMARY KEY (steamid))",temp[0],temp[1],temp[2],temp[3],temp[4],temp[5],temp[6],temp[7],temp[8],temp[9],temp[10],temp[11],temp[12],temp[13],temp[14],temp[15],temp[16],temp[17],temp[18],temp[19],temp[20],temp[21],temp[22],temp[23],temp[24],temp[25],temp[26],temp[27],temp[28],temp[29],temp[30],temp[31],temp[32],temp[33],temp[34],temp[35],temp[36],temp[37],temp[38],temp[39],temp[40],temp[41], temp[42], temp[43]);
406
407 LogToFileEx(g_sCmdLogPath, "Query %s", buffer);
408 SQL_TQuery(db, tbasicoC, buffer);
409 }
410 }
411}
412
413public OnClientDisconnect(client)
414{
415 if(comprobado41[client] && !IsFakeClient(client)) SaveCookies(client);
416 comprobado41[client] = false;
417 if(arbol[client] != INVALID_HANDLE)
418 {
419 ClearTrie(arbol[client]);
420 CloseHandle(arbol[client]);
421 arbol[client] = INVALID_HANDLE;
422 }
423 if(menu1[client] != INVALID_HANDLE)
424 {
425 CloseHandle(menu1[client]);
426 menu1[client] = INVALID_HANDLE;
427 }
428}
429
430public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
431{
432
433public OnLibraryAdded(const String:name[])
434{
435 if (StrEqual(name, "hosties"))
436 {
437 g_hosties = true;
438 }
439}
440
441public OnLibraryRemoved(const String:name[])
442{
443 if (StrEqual(name, "hosties"))
444 {
445 g_hosties = false;
446 }
447
448
449}
450
451public Action:ReloadSkins(client, args)
452{
453 ReadPaints();
454 ReplyToCommand(client, " \x04[WP]\x01 %T","Weapon paints reloaded", client);
455
456 return Plugin_Handled;
457}
458
459ShowMenu(client, item)
460{
461 SetMenuTitle(menuw, "%T","Menu title 1", client);
462
463 //RemoveMenuItem(menuw, 2);
464 RemoveMenuItem(menuw, 1);
465 RemoveMenuItem(menuw, 0);
466 decl String:tdisplay[64];
467 //Format(tdisplay, sizeof(tdisplay), "%T", "Escolhe as tuas skins favoritas!", client);
468 //InsertMenuItem(menuw, 0, "-2", tdisplay);
469 Format(tdisplay, sizeof(tdisplay), "%T", "Random skin", client);
470 InsertMenuItem(menuw, 0, "0", tdisplay);
471 Format(tdisplay, sizeof(tdisplay), "%T", "Sem skin", client);
472 InsertMenuItem(menuw, 1, "-1", tdisplay);
473
474 DisplayMenuAtItem(menuw, client, item, 0);
475}
476
477ShowMenuM(client)
478{
479 if(onlyadmin && GetUserAdmin(client) == INVALID_ADMIN_ID) return;
480
481 new Handle:menu2 = CreateMenu(DIDMenuHandler_2);
482 SetMenuTitle(menu2, "!ws - Wizard Gaming","Menu title 2", client, DATA);
483
484 decl String:tdisplay[64];
485 Format(tdisplay, sizeof(tdisplay), "%T", "Escolhe a skin para a arma que tens na mao", client);
486 AddMenuItem(menu2, "1", tdisplay);
487 Format(tdisplay, sizeof(tdisplay), "%T", "Escolhe a skin para cada arma", client);
488 AddMenuItem(menu2, "2", tdisplay);
489 //Format(tdisplay, sizeof(tdisplay), "%T", "Skins favoritas", client);
490 //AddMenuItem(menu2, "3", tdisplay);
491
492 DisplayMenu(menu2, client, 0);
493}
494
495public Action:GetSkins(client, args)
496{
497 Format(s_arma[client], 64, "none");
498 ShowMenuM(client);
499
500 return Plugin_Handled;
501}
502
503public Action:OnClientSayCommand(client, const String:command[], const String:sArgs[])
504{
505 if(StrEqual(sArgs, "!wskins", false) || StrEqual(sArgs, "!ws", false) || StrEqual(sArgs, "!paints", false))
506 {
507 Format(s_arma[client], 64, "none");
508 //ShowMenuM(client);
509
510 if(saytimer != INVALID_HANDLE || g_saytimer == -1) return Plugin_Handled;
511 saytimer = CreateTimer(1.0*g_saytimer, Tsaytimer);
512 return Plugin_Continue;
513
514 }
515 else if(StrEqual(sArgs, "!ss", false) || StrEqual(sArgs, "!showskin", false))
516 {
517 ShowSkin(client);
518
519 if(saytimer != INVALID_HANDLE || g_saytimer == -1) return Plugin_Handled;
520 saytimer = CreateTimer(1.0*g_saytimer, Tsaytimer);
521 return Plugin_Continue;
522 }
523
524 return Plugin_Continue;
525}
526
527ShowSkin(client)
528{
529 new weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
530 if(weapon < 1 || !IsValidEdict(weapon) || !IsValidEntity(weapon))
531 {
532 CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T", "Pintura nao encontrada", client);
533 return;
534 }
535
536 new buscar = GetEntProp(weapon,Prop_Send,"m_nFallbackPaintKit");
537 for(new i=1; i<g_paintCount;i++)
538 {
539 if(buscar == g_paints[i][index])
540 {
541 CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T", "Skin encontrada", client, g_paints[i][Nombre]);
542 return;
543 }
544 }
545
546 CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T", "Skin nao encontrada", client);
547}
548
549public Action:Tsaytimer(Handle:timer)
550{
551 saytimer = INVALID_HANDLE;
552}
553
554public Action:roundStart(Handle:event, const String:name[], bool:dontBroadcast)
555{
556 if(g_rtimer == -1) return;
557
558 if(rtimer != INVALID_HANDLE)
559 {
560 KillTimer(rtimer);
561 rtimer = INVALID_HANDLE;
562 }
563
564 rtimer = CreateTimer(1.0*g_rtimer, Rtimer);
565}
566
567public Action:Rtimer(Handle:timer)
568{
569 rtimer = INVALID_HANDLE;
570}
571
572public DIDMenuHandler_2(Handle:menu, MenuAction:action, client, itemNum)
573{
574 if ( action == MenuAction_Select )
575 {
576
577
578 decl String:info[4];
579
580 GetMenuItem(menu, itemNum, info, sizeof(info));
581 new theindex = StringToInt(info);
582 if(theindex == 1) ShowMenu(client, 0);
583 else if(theindex == 2 && comprobado41[client]) ShowMenuArmas(client, 0);
584 //else if(theindex == 3) ShowMenuFav(client);
585 }
586 else if (action == MenuAction_End)
587 {
588 CloseHandle(menu);
589 }
590}
591
592ShowMenuArmas(client, item)
593{
594 if(menu1[client] == INVALID_HANDLE) CrearMenu1(client);
595 DisplayMenuAtItem(menu1[client], client, item, 0);
596}
597
598public DIDMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
599{
600 if ( action == MenuAction_Select )
601 {
602 if(!comprobado41[client])
603 {
604 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
605 return;
606 }
607
608 decl String:Classname[64];
609 decl String:info[4];
610
611 GetMenuItem(menu, itemNum, info, sizeof(info));
612 new theindex = StringToInt(info);
613
614 if(StrEqual(s_arma[client], "none"))
615 {
616 if(GetUserAdmin(client) == INVALID_ADMIN_ID && rtimer == INVALID_HANDLE && g_rtimer != -1)
617 {
618 CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T", "You can use this command only the first seconds", client, g_rtimer);
619 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
620 return;
621 }
622 if(!IsPlayerAlive(client))
623 {
624 CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T", "You cant use this when you are dead", client);
625 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
626 return;
627 }
628
629 if(theindex != -1 && !StrEqual(g_paints[theindex][flag], "0"))
630 {
631 if(!CheckCommandAccess(client, "weaponpaints_override", ReadFlagString(g_paints[theindex][flag]), true))
632 {
633 CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T", "You dont have access to this paint", client);
634 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
635 return;
636 }
637 }
638
639
640 new windex = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
641 if(windex < 1)
642 {
643 CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T", "Nao podes usar uma skin neste item", client);
644 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
645 return;
646 }
647
648
649 if(!GetEdictClassname(windex, Classname, 64) || StrEqual(Classname, "weapon_taser") || (!g_c4 && StrEqual(Classname, "weapon_c4")))
650 {
651 CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T", "Nao podes usar uma skin neste item", client);
652 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
653 return;
654 }
655 ReplaceString(Classname, 64, "weapon_", "");
656 new weaponindex = GetEntProp(windex, Prop_Send, "m_iItemDefinitionIndex");
657 if(weaponindex == 42 || weaponindex == 59)
658 {
659 CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T", "Nao podes usar uma skin neste item", client);
660 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
661 return;
662 }
663 if(GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY) == windex || GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY) == windex || GetPlayerWeaponSlot(client, CS_SLOT_KNIFE) == windex || (g_c4 && GetPlayerWeaponSlot(client, CS_SLOT_C4) == windex))
664 {
665 switch (weaponindex)
666 {
667 case 60: strcopy(Classname, 64, "m4a1_silencer");
668 case 61: strcopy(Classname, 64, "usp_silencer");
669 case 63: strcopy(Classname, 64, "cz75a");
670 case 500: strcopy(Classname, 64, "bayonet");
671 case 506: strcopy(Classname, 64, "knife_gut");
672 case 505: strcopy(Classname, 64, "knife_flip");
673 case 508: strcopy(Classname, 64, "knife_m9_bayonet");
674 case 507: strcopy(Classname, 64, "knife_karambit");
675 case 509: strcopy(Classname, 64, "knife_tactical");
676 case 515: strcopy(Classname, 64, "knife_butterfly");
677 case 512: strcopy(Classname, 64, "knife_falchion");
678 case 516: strcopy(Classname, 64, "knife_push");
679 case 64: strcopy(Classname, 64, "revolver");
680 case 514: strcopy(Classname, 64, "knife_survival_bowie");
681 }
682
683 if(arbol[client] == INVALID_HANDLE)
684 {
685 OnClientPostAdminCheck(client);
686 return;
687 }
688 else
689 {
690 new valor = 0;
691 if(!GetTrieValue(arbol[client], Classname, valor))
692 {
693 CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T", "Nao podes usar uma skin neste item", client);
694 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
695 return;
696 }
697
698 decl String:buffer[1024], String:nombres[64];
699 if(theindex == -1) Format(nombres, sizeof(nombres), "default");
700 else Format(nombres, sizeof(nombres), g_paints[theindex][Nombre]);
701 decl String:steamid[32];
702 GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid) );
703 Format(buffer, sizeof(buffer), "UPDATE weaponpaints SET %s = '%s' WHERE steamid = '%s';", Classname,nombres,steamid);
704 LogToFileEx(g_sCmdLogPath, "Query %s", buffer);
705 SQL_TQuery(db, tbasico, buffer, GetClientUserId(client));
706 SetTrieValue(arbol[client], Classname, theindex);
707 }
708
709 //ChangePaint(client, windex, Classname, weaponindex, true);
710 decl String:Classname2[64];
711 Format(Classname2, 64, "weapon_%s", Classname);
712 Restore(client, windex, Classname2, weaponindex);
713 FakeClientCommand(client, "use %s", Classname2);
714 if(theindex == -1) CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T","Escolheste a skin original para a tua",client, Classname);
715 else if(theindex == 0) CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T","Escolheste uma skin random para a tua",client, Classname);
716 else CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T", "Escolheste uma arma",client, g_paints[theindex][Nombre], Classname);
717
718 decl String:temp[128], String:temp1[64];
719 if(theindex == -1) Format(temp, 128, "%s", Classname);
720 else if (theindex == 0)
721 {
722
723 Format(temp1, sizeof(temp1), "%T", "Random paint", client);
724 Format(temp, 128, "%s - %s", Classname, temp1);
725 }
726 else Format(temp, 128, "%s - %s", Classname, g_paints[theindex][Nombre]);
727 if(menu1[client] == INVALID_HANDLE) CrearMenu1(client);
728 new imenu = FindStringInArray(array_armas, Classname);
729 InsertMenuItem(menu1[client], imenu, Classname, temp);
730 FindStringInArray(array_armas, Classname);
731 RemoveMenuItem(menu1[client], imenu+1);
732 }
733 else CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T", "Nao podes usar uma skin neste item",client);
734
735
736 }
737 else
738 {
739 Format(Classname, 64, s_arma[client]);
740
741 if(arbol[client] == INVALID_HANDLE)
742 {
743 OnClientPostAdminCheck(client);
744 return;
745 }
746 else
747 {
748 decl String:buffer[1024], String:nombres[64];
749 if(theindex == -1) Format(nombres, sizeof(nombres), "default");
750 else Format(nombres, sizeof(nombres), g_paints[theindex][Nombre]);
751 decl String:steamid[32];
752 GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid) );
753 Format(buffer, sizeof(buffer), "UPDATE weaponpaints SET %s = '%s' WHERE steamid = '%s';", Classname,nombres,steamid);
754 LogToFileEx(g_sCmdLogPath, "Query %s", buffer);
755 SQL_TQuery(db, tbasico, buffer, GetClientUserId(client));
756 SetTrieValue(arbol[client], Classname, theindex);
757 }
758
759 if(theindex == -1) CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T","Escolheste a skin original para a tua",client, Classname);
760 else if(theindex == 0) CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T","Escolheste uma skin random para a tua",client, Classname);
761 else CPrintToChat(client, " {green}[{blue}WizardGaming{green}]{default} %T", "Escolheste uma arma",client, g_paints[theindex][Nombre], Classname);
762
763 decl String:temp[128], String:temp1[64];
764 if(theindex == -1) Format(temp, 128, "%s", Classname);
765 else if (theindex == 0)
766 {
767
768 Format(temp1, sizeof(temp1), "%T", "Random paint", client);
769 Format(temp, 128, "%s - %s", Classname, temp1);
770 }
771 else Format(temp, 128, "%s - %s", Classname, g_paints[theindex][Nombre]);
772 new imenu = FindStringInArray(array_armas, Classname);
773 InsertMenuItem(menu1[client], imenu, Classname, temp);
774 FindStringInArray(array_armas, Classname);
775 RemoveMenuItem(menu1[client], imenu+1);
776 Format(s_arma[client], 64, "none");
777 ShowMenuArmas(client, s_sele[client]);
778 return;
779 }
780
781 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
782
783 }
784}
785
786/* public Action:RestoreItemID(Handle:timer, Handle:pack)
787{
788 new entity;
789 new m_iItemIDHigh;
790 new m_iItemIDLow;
791
792 ResetPack(pack);
793 entity = EntRefToEntIndex(ReadPackCell(pack));
794 m_iItemIDHigh = ReadPackCell(pack);
795 m_iItemIDLow = ReadPackCell(pack);
796
797 if(entity != INVALID_ENT_REFERENCE)
798 {
799 SetEntProp(entity,Prop_Send,"m_iItemIDHigh",m_iItemIDHigh);
800 SetEntProp(entity,Prop_Send,"m_iItemIDLow",m_iItemIDLow);
801 }
802} */
803
804ReadPaints()
805{
806 BuildPath(Path_SM, path_paints, sizeof(path_paints), "configs/csgo_wpaints.cfg");
807
808 decl Handle:kv;
809 g_paintCount = 1;
810 ClearArray(array_paints);
811 PushArrayString(array_paints, "random");
812 Format(g_paints[0][Nombre], 64, "random")
813
814 kv = CreateKeyValues("Paints");
815 FileToKeyValues(kv, path_paints);
816
817 if (!KvGotoFirstSubKey(kv)) {
818
819 SetFailState("CFG File not found: %s", path_paints);
820 CloseHandle(kv);
821 }
822 do {
823
824 KvGetSectionName(kv, g_paints[g_paintCount][Nombre], 64);
825 g_paints[g_paintCount][index] = KvGetNum(kv, "paint", 0);
826 g_paints[g_paintCount][wear] = KvGetFloat(kv, "wear", 0.01);
827 g_paints[g_paintCount][stattrak] = KvGetNum(kv, "stattrak", -2);
828 g_paints[g_paintCount][quality] = KvGetNum(kv, "quality", 3);
829 g_paints[g_paintCount][pattern] = KvGetNum(kv, "pattern", 0);
830 KvGetString(kv, "flag", g_paints[g_paintCount][flag], 8, "0");
831
832 PushArrayString(array_paints, g_paints[g_paintCount][Nombre]);
833 g_paintCount++;
834 } while (KvGotoNextKey(kv));
835 CloseHandle(kv);
836
837 if(menuw != INVALID_HANDLE) CloseHandle(menuw);
838 menuw = INVALID_HANDLE;
839
840 menuw = CreateMenu(DIDMenuHandler);
841
842 // TROLLING
843 SetMenuTitle(menuw, "( ͡° ͜ʖ ͡°)");
844 decl String:item[4];
845 AddMenuItem(menuw, "0", "Random paint");
846 AddMenuItem(menuw, "-1", "Default paint");
847 // FORGET THIS
848
849 for (new i=g_paintCount; i<MAX_PAINTS; ++i) {
850
851 g_paints[i][index] = 0;
852 }
853 //decl String:menuitem[192];
854 for (new i=1; i<g_paintCount; ++i) {
855 Format(item, 4, "%i", i);
856 AddMenuItem(menuw, item, g_paints[i][Nombre]);
857
858/* if(StrEqual(g_paints[g_paintCount][flag], "public", false))
859 {
860 AddMenuItem(menuw, item, g_paints[i][Nombre]);
861 }
862 else
863 {
864 Format(menuitem, 192, "%s (flag %s)", g_paints[i][Nombre],g_paints[i][flag]);
865 AddMenuItem(menuw, item, menuitem);
866 } */
867 }
868 SetMenuExitButton(menuw, true);
869}
870
871/* stock GetReserveAmmo(client, weapon)
872{
873 new ammotype = GetEntProp(weapon, Prop_Send, "m_iPrimaryAmmoType");
874 if(ammotype == -1) return -1;
875
876 return GetEntProp(client, Prop_Send, "m_iAmmo", _, ammotype);
877}
878
879stock SetReserveAmmo(client, weapon, ammo)
880{
881 new ammotype = GetEntProp(weapon, Prop_Send, "m_iPrimaryAmmoType");
882 if(ammotype == -1) return;
883
884 SetEntProp(client, Prop_Send, "m_iAmmo", ammo, _, ammotype);
885} */
886
887stock GetReserveAmmo(weapon)
888{
889 new ammotype = GetEntProp(weapon, Prop_Send, "m_iPrimaryReserveAmmoCount");
890 if(ammotype == -1) return -1;
891
892 return ammotype;
893}
894
895stock SetReserveAmmo(weapon, ammo)
896{
897 SetEntProp(weapon, Prop_Send, "m_iPrimaryReserveAmmoCount", ammo);
898 //PrintToChatAll("fijar es %i", ammo);
899}
900
901Restore(client, windex, String:Classname[64], weaponindex)
902{
903 new bool:knife = false;
904 if(StrContains(Classname, "weapon_knife", false) == 0 || StrContains(Classname, "weapon_bayonet", false) == 0)
905 {
906 knife = true;
907 }
908
909 //PrintToChat(client, "weapon %s", Classname);
910 new ammo, clip;
911 if(!knife)
912 {
913 ammo = GetReserveAmmo(windex);
914 clip = GetEntProp(windex, Prop_Send, "m_iClip1");
915 }
916 RemovePlayerItem(client, windex);
917 AcceptEntityInput(windex, "Kill");
918
919 new entity;
920 if(zombiesv && knife) GivePlayerItem(client, "weapon_knife");
921 else entity = GivePlayerItem(client, Classname);
922
923 if(knife)
924 {
925 if (weaponindex != 42 && weaponindex != 59 && !zombiesv)
926 EquipPlayerWeapon(client, entity);
927 }
928 else
929 {
930 SetReserveAmmo(entity, ammo);
931 SetEntProp(entity, Prop_Send, "m_iClip1", clip);
932 }
933}
934
935ChangePaint(entity, theindex)
936{
937 if(theindex == 0)
938 {
939 theindex = GetRandomInt(1, g_paintCount-1);
940 }
941 else if(theindex == -1) return;
942
943/* new m_iItemIDHigh = GetEntProp(entity, Prop_Send, "m_iItemIDHigh");
944 new m_iItemIDLow = GetEntProp(entity, Prop_Send, "m_iItemIDLow"); */
945
946 SetEntProp(entity,Prop_Send,"m_iItemIDLow",-1);
947 //SetEntProp(entity,Prop_Send,"m_iItemIDHigh",0);
948
949 SetEntProp(entity,Prop_Send,"m_nFallbackPaintKit",g_paints[theindex][index]);
950 if(g_paints[theindex][wear] >= 0.0) SetEntPropFloat(entity,Prop_Send,"m_flFallbackWear",g_paints[theindex][wear]);
951 if(g_paints[theindex][pattern] >= 0) SetEntProp(entity,Prop_Send,"m_nFallbackSeed",g_paints[theindex][pattern]);
952 if(g_paints[theindex][stattrak] != -2) SetEntProp(entity,Prop_Send,"m_nFallbackStatTrak",g_paints[theindex][stattrak]);
953 if(g_paints[theindex][quality] != -2) SetEntProp(entity,Prop_Send,"m_iEntityQuality",g_paints[theindex][quality]);
954
955/* new Handle:pack;
956
957 CreateDataTimer(0.2, RestoreItemID, pack);
958 WritePackCell(pack,EntIndexToEntRef(entity));
959 WritePackCell(pack,m_iItemIDHigh);
960 WritePackCell(pack,m_iItemIDLow); */
961}
962
963public OnClientPutInServer(client)
964{
965 if(!IsFakeClient(client)) SDKHook(client, SDKHook_WeaponEquipPost, OnPostWeaponEquip);
966}
967
968public Action:OnPostWeaponEquip(client, weapon)
969{
970 if(onlyadmin && GetUserAdmin(client) == INVALID_ADMIN_ID) return;
971
972 if(weapon < 1 || !IsValidEdict(weapon) || !IsValidEntity(weapon)) return;
973
974 if (GetEntProp(weapon, Prop_Send, "m_hPrevOwner") > 0)
975 return;
976
977 decl String:Classname[64];
978 if(!GetEdictClassname(weapon, Classname, 64) || StrEqual(Classname, "weapon_taser") || (!g_c4 && StrEqual(Classname, "weapon_c4")))
979 {
980 return;
981 }
982 ReplaceString(Classname, 64, "weapon_", "");
983 new weaponindex = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
984 if(weaponindex == 42 || weaponindex == 59)
985 {
986 return;
987 }
988
989 switch (weaponindex)
990 {
991 case 60: strcopy(Classname, 64, "m4a1_silencer");
992 case 61: strcopy(Classname, 64, "usp_silencer");
993 case 63: strcopy(Classname, 64, "cz75a");
994 case 500: strcopy(Classname, 64, "bayonet");
995 case 506: strcopy(Classname, 64, "knife_gut");
996 case 505: strcopy(Classname, 64, "knife_flip");
997 case 508: strcopy(Classname, 64, "knife_m9_bayonet");
998 case 507: strcopy(Classname, 64, "knife_karambit");
999 case 509: strcopy(Classname, 64, "knife_tactical");
1000 case 515: strcopy(Classname, 64, "knife_butterfly");
1001 case 512: strcopy(Classname, 64, "knife_falchion");
1002 case 516: strcopy(Classname, 64, "knife_push");
1003 case 64: strcopy(Classname, 64, "revolver");
1004 case 514: strcopy(Classname, 64, "knife_survival_bowie");
1005 }
1006 if(arbol[client] == INVALID_HANDLE) return;
1007 new valor = 0;
1008 if(!GetTrieValue(arbol[client], Classname, valor)) return;
1009 if(valor == -1 || (valor != 0 && g_paints[valor][index] == 0)) return;
1010 //PrintToChat(client, "prueba");
1011 ChangePaint(weapon, valor);
1012}
1013
1014SaveCookies(client)
1015{
1016 decl String:steamid[32];
1017 GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid) );
1018 new String:Name[MAX_NAME_LENGTH+1];
1019 new String:SafeName[(sizeof(Name)*2)+1];
1020 if (!GetClientName(client, Name, sizeof(Name)))
1021 Format(SafeName, sizeof(SafeName), "<noname>");
1022 else
1023 {
1024 TrimString(Name);
1025 SQL_EscapeString(db, Name, SafeName, sizeof(SafeName));
1026 }
1027
1028 decl String:buffer[3096];
1029 Format(buffer, sizeof(buffer), "UPDATE weaponpaints SET last_accountuse = %d, playername = '%s' WHERE steamid = '%s';",GetTime(), SafeName,steamid);
1030 LogToFileEx(g_sCmdLogPath, "Query %s", buffer);
1031 SQL_TQuery(db, tbasico2, buffer);
1032}
1033
1034CrearMenu1(client)
1035{
1036
1037 menu1[client] = CreateMenu(DIDMenuHandler_armas);
1038 SetMenuTitle(menu1[client], "%T","Menu title 1", client);
1039
1040 new String:Items[64];
1041
1042 decl String:temp[128], String:temp1[64];
1043 new valor;
1044 for(new i=0;i<GetArraySize(array_armas);++i)
1045 {
1046 GetArrayString(array_armas, i, Items, 64);
1047 if(GetTrieValue(arbol[client], Items, valor))
1048 {
1049 if(valor == -1) Format(temp, 128, "%s", Items);
1050 else if (valor == 0)
1051 {
1052 Format(temp1, sizeof(temp1), "%T", "Random paint", client);
1053 Format(temp, 128, "%s - %s", Items, temp1);
1054 }
1055 else Format(temp, 128, "%s - %s", Items, g_paints[valor][Nombre]);
1056 }
1057 else Format(temp, 128, "%s", Items);
1058 AddMenuItem(menu1[client], Items, temp);
1059 }
1060}
1061
1062public DIDMenuHandler_armas(Handle:menu, MenuAction:action, client, itemNum)
1063{
1064 if ( action == MenuAction_Select )
1065 {
1066 decl String:info[64];
1067
1068 GetMenuItem(menu, itemNum, info, sizeof(info));
1069
1070 Format(s_arma[client], 64, info);
1071 s_sele[client] = GetMenuSelectionPosition();
1072 ShowMenu(client, 0);
1073 }
1074}
1075
1076public OnClientPostAdminCheck(client)
1077{
1078 if(!IsFakeClient(client)) CheckSteamID(client);
1079 //PrintToChatAll("algo");
1080}
1081
1082CheckSteamID(client)
1083{
1084 decl String:query[255], String:steamid[32];
1085 GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid) );
1086
1087 Format(query, sizeof(query), "SELECT * FROM weaponpaints WHERE steamid = '%s'", steamid);
1088 LogToFileEx(g_sCmdLogPath, "Query %s", query);
1089 SQL_TQuery(db, T_CheckSteamID, query, GetClientUserId(client));
1090}
1091
1092public T_CheckSteamID(Handle:owner, Handle:hndl, const String:error[], any:data)
1093{
1094 new client;
1095
1096 /* Make sure the client didn't disconnect while the thread was running */
1097 if ((client = GetClientOfUserId(data)) == 0)
1098 {
1099 return;
1100 }
1101 if (hndl == INVALID_HANDLE)
1102 {
1103 ComprobarDB();
1104 return;
1105 }
1106 //PrintToChatAll("comprobado41");
1107 if (!SQL_GetRowCount(hndl) || !SQL_FetchRow(hndl))
1108 {
1109 Nuevo(client);
1110 return;
1111 }
1112
1113 arbol[client] = CreateTrie();
1114
1115 new String:Items[64];
1116
1117 new String:temp[64];
1118 new contar = 3;
1119 for(new i=0;i<GetArraySize(array_armas);++i)
1120 {
1121 GetArrayString(array_armas, i, Items, 64);
1122 SQL_FetchString(hndl, contar, temp, 64);
1123 SetTrieValue(arbol[client], Items, FindStringInArray(array_paints, temp));
1124
1125 //LogMessage("Sacado %i del arma %s", FindStringInArray(array_paints, temp),Items);
1126
1127 contar++;
1128 }
1129
1130/* SQL_FetchString(hndl, contar, temp, 64);
1131 SetTrieValue(arbol[client], "favorite1", FindStringInArray(array_paints, temp));
1132 contar++;
1133
1134 SQL_FetchString(hndl, contar, temp, 64);
1135 SetTrieValue(arbol[client], "favorite2", FindStringInArray(array_paints, temp));
1136 contar++;
1137
1138 SQL_FetchString(hndl, contar, temp, 64);
1139 SetTrieValue(arbol[client], "favorite3", FindStringInArray(array_paints, temp));
1140 contar++;
1141
1142 SQL_FetchString(hndl, contar, temp, 64);
1143 SetTrieValue(arbol[client], "favorite4", FindStringInArray(array_paints, temp));
1144 contar++;
1145
1146 SQL_FetchString(hndl, contar, temp, 64);
1147 SetTrieValue(arbol[client], "favorite5", FindStringInArray(array_paints, temp));
1148 contar++;
1149
1150 SQL_FetchString(hndl, contar, temp, 64);
1151 SetTrieValue(arbol[client], "favorite6", FindStringInArray(array_paints, temp));
1152 contar++;
1153
1154 SQL_FetchString(hndl, contar, temp, 64);
1155 SetTrieValue(arbol[client], "favorite7", FindStringInArray(array_paints, temp));
1156 contar++; */
1157
1158
1159 comprobado41[client] = true;
1160/* new String:equipo[64];
1161 SQL_FetchString( hndl, 0, equipo, 64);
1162 PrintToChatAll(equipo);
1163
1164 SQL_FetchString( hndl, 1, equipo, 64);
1165 PrintToChatAll(equipo);
1166
1167 SQL_FetchString( hndl, 2, equipo, 64);
1168 PrintToChatAll(equipo);
1169
1170 SQL_FetchString( hndl, 3, equipo, 64); // este
1171 PrintToChatAll(equipo); */
1172
1173 //PrintToChatAll("pasado");
1174
1175/* new String:equipo[4];
1176 SQL_FetchString( hndl, 0, equipo, 4);
1177
1178 if(StrEqual(equipo, "CT", false))
1179 {
1180 ft[client] = CS_TEAM_CT;
1181 }
1182 else if(StrEqual(equipo, "T", false))
1183 {
1184 ft[client] = CS_TEAM_T;
1185 } */
1186}
1187
1188Nuevo(client)
1189{
1190 //PrintToChatAll("metido");
1191 decl String:query[255], String:steamid[32];
1192 GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid) );
1193 new userid = GetClientUserId(client);
1194
1195 new String:Name[MAX_NAME_LENGTH+1];
1196 new String:SafeName[(sizeof(Name)*2)+1];
1197 if (!GetClientName(client, Name, sizeof(Name)))
1198 Format(SafeName, sizeof(SafeName), "<noname>");
1199 else
1200 {
1201 TrimString(Name);
1202 SQL_EscapeString(db, Name, SafeName, sizeof(SafeName));
1203 }
1204
1205 Format(query, sizeof(query), "INSERT INTO weaponpaints(playername, steamid, last_accountuse) VALUES('%s', '%s', '%d');", SafeName, steamid, GetTime());
1206 LogToFileEx(g_sCmdLogPath, "Query %s", query);
1207 SQL_TQuery(db, tbasico3, query, userid);
1208}
1209
1210
1211public PruneDatabase()
1212{
1213 if (db == INVALID_HANDLE)
1214 {
1215 LogToFileEx(g_sCmdLogPath, "Prune Database: No connection");
1216 ComprobarDB();
1217 return;
1218 }
1219
1220 new maxlastaccuse;
1221 maxlastaccuse = GetTime() - (IDAYS * 86400);
1222
1223 decl String:buffer[1024];
1224
1225 if (ismysql == 1)
1226 Format(buffer, sizeof(buffer), "DELETE FROM `weaponpaints` WHERE `last_accountuse`<'%d' AND `last_accountuse`>'0';", maxlastaccuse);
1227 else
1228 Format(buffer, sizeof(buffer), "DELETE FROM weaponpaints WHERE last_accountuse<'%d' AND last_accountuse>'0';", maxlastaccuse);
1229
1230 LogToFileEx(g_sCmdLogPath, "Query %s", buffer);
1231 SQL_TQuery(db, tbasicoP, buffer);
1232}
1233
1234public tbasico(Handle:owner, Handle:hndl, const String:error[], any:data)
1235{
1236 if (hndl == INVALID_HANDLE)
1237 {
1238 LogToFileEx(g_sCmdLogPath, "Query failure: %s", error);
1239 }
1240 new client;
1241
1242 /* Make sure the client didn't disconnect while the thread was running */
1243 if ((client = GetClientOfUserId(data)) == 0)
1244 {
1245 return;
1246 }
1247 comprobado41[client] = true;
1248
1249}
1250
1251public tbasico2(Handle:owner, Handle:hndl, const String:error[], any:data)
1252{
1253 if (hndl == INVALID_HANDLE)
1254 {
1255 LogToFileEx(g_sCmdLogPath, "Query failure: %s", error);
1256 ComprobarDB();
1257 }
1258}
1259
1260public tbasico3(Handle:owner, Handle:hndl, const String:error[], any:data)
1261{
1262 if (hndl == INVALID_HANDLE)
1263 {
1264 LogToFileEx(g_sCmdLogPath, "Query failure: %s", error);
1265 ComprobarDB();
1266 }
1267 new client;
1268
1269 /* Make sure the client didn't disconnect while the thread was running */
1270 if ((client = GetClientOfUserId(data)) == 0)
1271 {
1272 return;
1273 }
1274
1275 arbol[client] = CreateTrie();
1276
1277 new String:Items[64];
1278
1279 for(new i=0;i<GetArraySize(array_armas);++i)
1280 {
1281 GetArrayString(array_armas, i, Items, 64);
1282 SetTrieValue(arbol[client], Items, -1);
1283 }
1284
1285 SetTrieValue(arbol[client], "favorite1", -1);
1286 SetTrieValue(arbol[client], "favorite2", -1);
1287 SetTrieValue(arbol[client], "favorite3", -1);
1288 SetTrieValue(arbol[client], "favorite4", -1);
1289 SetTrieValue(arbol[client], "favorite5", -1);
1290 SetTrieValue(arbol[client], "favorite6", -1);
1291 SetTrieValue(arbol[client], "favorite7", -1);
1292
1293 comprobado41[client] = true;
1294}
1295
1296public tbasicoC(Handle:owner, Handle:hndl, const String:error[], any:data)
1297{
1298 if (hndl == INVALID_HANDLE)
1299 {
1300 LogToFileEx(g_sCmdLogPath, "Query failure: %s", error);
1301 }
1302 //LogMessage("Database connection successful");
1303
1304 for(new client = 1; client <= MaxClients; client++)
1305 {
1306 if(IsClientInGame(client))
1307 {
1308 OnClientPostAdminCheck(client);
1309 }
1310 }
1311}
1312
1313public tbasicoP(Handle:owner, Handle:hndl, const String:error[], any:data)
1314{
1315 if (hndl == INVALID_HANDLE)
1316 {
1317 LogToFileEx(g_sCmdLogPath, "Query failure: %s", error);
1318 ComprobarDB();
1319 }
1320 //LogMessage("Prune Database successful");
1321}