· 9 years ago · Jan 21, 2017, 05:44 AM
1#include "gunxpmod.cfg"
2
3#if defined ZOMBIE_BIOHAZARD
4 #include <biohazard>
5#endif
6#if defined ZOMBIE_PLAGUE
7 #include <zombieplague>
8#endif
9
10#include <amxmodx>
11#include <amxmisc>
12#include <fakemeta>
13#include <fun>
14#include <csdm>
15#include <cstrike>
16#include <nvault>
17#include <sqlx>
18#include <hamsandwich>
19#include <acg>
20
21#define PLUGIN "Gun Xp Mod"
22#define AUTHOR "xbatista Edited By Infractem for MW2 Style GXM"
23#define VERSION "2.3"
24
25
26#define OFFSET_PRIMARYWEAPON 116
27#define TASK_SHOW_LEVEL 10113
28#define fm_cs_set_user_nobuy(%1) set_pdata_int(%1, 235, get_pdata_int(%1, 235) & ~(1<<0) ) //no weapon buy
29
30new PlayerXp[33];
31new PlayerLevel[33];
32new Float:timekill[33]
33
34new g_Vault;
35new g_remember_selection[33], g_kills[33], g_remember_selection_pistol[33];
36new g_maxplayers, g_msgHudSync1, SayTxT, enable_grenades;
37new show_level_text, show_rank;
38new savexp, save_type, xp_kill, xp_double, enable_double, double_kills, xp_triple, enable_triple, triple_kills, xp_ultra, ultra_kills, enable_ultra, p_Enabled, level_style;
39new enable_admin_xp, admin_xp;
40new maxAmmo[31]={
41 0,
42 30, //CSW_P228
43 0,
44 10, //CSW_SCOUT
45 1, //CSW_HEGRENADE
46 24, //CSW_XM1014
47 1, //CSW_C4
48 66, //CSW_MAC10
49 84, //CSW_AUG
50 1, //CSW_SMOKEGRENADE
51 24, //CSW_ELITE
52 14, //CSW_FIVESEVEN
53 60, //CSW_UMP45
54 18, //CSW_SG550
55 60, //CSW_GALIL
56 60, //CSW_FAMAS
57 24, //CSW_USP
58 40, //CSW_GLOCK18
59 20, //CSW_AWP
60 64, //CSW_MP5NAVY
61 100, //CSW_M249
62 24, //CSW_M3
63 60, //CSW_M4A1
64 30, //CSW_TMP
65 20, //CSW_G3SG1
66 2, //CSW_FLASHBANG
67 14, //CSW_DEAGLE
68 60, //CSW_SG552
69 60, //CSW_AK47
70 0, //CSW_KNIFE
71 100 //CSW_P90
72};
73
74/*================================================================================
75 [MySQLx Vars, other]
76=================================================================================*/
77new Handle:g_hTuple;
78
79new mysqlx_host, mysqlx_user, mysqlx_db, mysqlx_pass;
80
81new const szTables[][] =
82{
83 "CREATE TABLE IF NOT EXISTS `mytable` ( `player_id` varchar(32) NOT NULL,`player_level` int(8) default NULL,`player_xp` int(16) default NULL,PRIMARY KEY (`player_id`) ) TYPE=MyISAM;"
84}
85
86new WEAPONCONST[MAXLEVEL][] = { "weapon_glock18", "weapon_usp", "weapon_p228", "weapon_fiveseven", "weapon_deagle", "weapon_elite", "weapon_tmp",
87"weapon_mac10", "weapon_ump45", "weapon_mp5navy", "weapon_p90", "weapon_scout", "weapon_awp", "weapon_famas", "weapon_galil", "weapon_m3", "weapon_xm1014",
88"weapon_ak47", "weapon_m4a1", "weapon_aug", "weapon_sg552", "weapon_sg550", "weapon_g3sg1", "weapon_m249", "NULL"
89}; // Give Weapons
90
91new WEAPONMDL[MAXLEVEL][] = { "models/w_glock18.mdl", "models/w_usp.mdl", "models/w_p228.mdl", "models/w_fiveseven.mdl", "models/w_deagle.mdl", "models/w_elite.mdl", "models/w_tmp.mdl",
92"models/w_mac10.mdl", "models/w_ump45.mdl", "models/w_mp5.mdl", "models/w_p90.mdl", "models/w_scout.mdl", "models/w_awp.mdl", "models/w_famas.mdl", "models/w_galil.mdl", "models/w_m3.mdl", "models/w_xm1014.mdl",
93"models/w_ak47.mdl", "models/w_m4a1.mdl", "models/w_aug.mdl", "models/w_sg552.mdl", "models/w_sg550.mdl", "models/w_g3sg1.mdl", "models/w_m249.mdl", "94"
94}; // Blocks pick up weapon, don't change!
95
96/*================================================================================
97 [Plugin natives,precache,init]
98=================================================================================*/
99public plugin_init()
100{
101 register_plugin(PLUGIN, VERSION, AUTHOR);
102 register_cvar("gxm_version", VERSION, FCVAR_SPONLY|FCVAR_SERVER)
103 set_cvar_string("gxm_version", VERSION)
104
105 register_concmd("set_level", "cmd_give_level", ADMIN_RCON, "set_level <name> <amount>" );
106 register_clcmd("say level", "showlevel");
107 register_clcmd("say /level", "showlevel");
108 register_clcmd("say /top20","showtop20");
109 register_clcmd("say /menu","show_main_menu_info");
110 register_clcmd("say menu","show_main_menu_info");
111
112 p_Enabled = register_cvar( "gxm_enable", "1" ); // Plugin enabled? 1 = Yes, 0 = No.
113 save_type = register_cvar("gxm_savetype","1"); // Save Xp to : 1 = MySQL, 0 = NVault.
114 savexp = register_cvar("gxm_save","0"); // Save Xp by : 1 = SteamID, 0 = IP.
115 xp_kill = register_cvar("gxm_xp","10"); // How much xp gain if you killed someone?
116 show_level_text = register_cvar("gxm_level_text","0"); // Show your level by : 1 = HUD message, 0 = Simple colored text message.
117 show_rank = register_cvar("gxm_show_rank","1"); // Show rank in /top20? 1 = Yes, 0 = No.
118 level_style = register_cvar("gxm_level_style","0"); // You will gain each level new gun : 1 = Yes, 0 = No,select your gun by menu.
119 enable_grenades = register_cvar("gxm_grenades","1"); // Give to player grenades? 1 = Yes, 0 = No.
120
121 enable_double = register_cvar("gxm_double","1");
122 xp_double = register_cvar("gxm_double_xp","2");
123 double_kills = register_cvar("gxm_double_kills","2");
124 enable_triple = register_cvar("gxm_triple","1"); // Enable Triple Kill bonus xp? 1 = Yes, 0 = No.
125 xp_triple = register_cvar("gxm_triple_xp","3"); // How much bonus xp give for Triple Kill?
126 triple_kills = register_cvar("gxm_triple_kills","3"); // How much kills needed to give bonus xp?
127 enable_ultra = register_cvar("gxm_ultra","1"); // Enable Ultra Kill bonus xp? 1 = Yes, 0 = No.
128 xp_ultra = register_cvar("gxm_ultra_xp","5"); // How much bonus xp give for Ultra Kill?
129 ultra_kills = register_cvar("gxm_ultra_kills","6"); // How much kills needed to give bonus xp?
130
131 enable_admin_xp = register_cvar("gxm_admin_xp","1"); // Enable Extra xp for killing? 1 = Yes, 0 = No.
132 admin_xp = register_cvar("gxm_extra_xp","10"); // How much extra xp give to admins?
133
134 // SQLx cvars
135 mysqlx_host = register_cvar ("gxm_host", ""); // The host from the db
136 mysqlx_user = register_cvar ("gxm_user", ""); // The username from the db login
137 mysqlx_pass = register_cvar ("gxm_pass", ""); // The password from the db login
138 mysqlx_db = register_cvar ("gxm_dbname", ""); // The database name
139
140 // Events //
141 register_event("DeathMsg", "event_deathmsg", "a");
142 //register_event("StatusValue", "Event_StatusValue", "bd", "1=2")
143
144 // Forwards //
145 RegisterHam(Ham_Spawn, "player", "fwd_PlayerSpawn", 1);
146
147 register_forward(FM_Touch, "fwd_Touch");
148
149 // Messages //
150 #if defined NORMAL_MOD || defined ZOMBIE_SWARM
151 register_message(get_user_msgid("StatusIcon"), "Message_StatusIcon")
152 #endif
153
154 // Other //
155 register_menucmd(register_menuid("Main Menu"), 1023, "main_menu_info")
156
157 register_dictionary("gunxpmod.txt");
158 MySQLx_Init()
159
160 SayTxT = get_user_msgid("SayText");
161
162 g_msgHudSync1 = CreateHudSyncObj()
163 g_maxplayers = get_maxplayers();
164}
165public plugin_natives()
166{
167 // Player natives //
168 register_native("get_user_xp", "native_get_user_xp", 1);
169 register_native("set_user_xp", "native_set_user_xp", 1);
170 register_native("get_user_level", "native_get_user_level", 1);
171 register_native("set_user_level", "native_set_user_level", 1);
172 register_native("get_user_max_level", "native_get_user_max_level", 1);
173}
174public plugin_precache()
175{
176 precache_sound("sound/mw/levelup.wav");
177 precache_model("sprites/ACG_EK/defaultkill.spr")
178 precache_model("sprites/ACG_EK/doublekill.spr")
179 precache_model("sprites/ACG_EK/triplekill.spr")
180 precache_model("sprites/ACG_EK/multikill.spr")
181 precache_generic("gfx/promotion.tga");
182
183}
184public plugin_cfg()
185{
186 new ConfDir[32], File[192];
187
188 get_configsdir( ConfDir, charsmax( ConfDir ) );
189 formatex( File, charsmax( File ), "%s/gunxpmod.cfg", ConfDir );
190
191 if( !file_exists( File ) )
192 {
193 server_print( "File %s doesn't exist!", File );
194 write_file( File, " ", -1 );
195 }
196 else
197 {
198 server_print( "%s successfully loaded.", File );
199 server_cmd( "exec %s", File );
200 }
201
202 //Open our vault and have g_Vault store the handle.
203 g_Vault = nvault_open( "gunxpmod" );
204
205 //Make the plugin error if vault did not successfully open
206 if ( g_Vault == INVALID_HANDLE )
207 set_fail_state( "Error opening GunXpMod nVault, file does not exist!" );
208}
209public plugin_end()
210{
211 //Close the vault when the plugin ends (map change\server shutdown\restart)
212 nvault_close( g_Vault );
213}
214public client_connect(id)
215{
216 g_remember_selection[id] = MAX_PISTOLS_MENU;
217 g_remember_selection_pistol[id] = 0;
218
219 LoadLevel(id)
220}
221public client_disconnect(id)
222{
223 SaveLevel(id)
224
225 PlayerXp[id] = 0;
226 PlayerLevel[id] = 0;
227
228 remove_task( TASK_SHOW_LEVEL + id );
229}
230public Message_StatusIcon(iMsgId, MSG_DEST, id)
231{
232 if( !get_pcvar_num(p_Enabled) )
233 return PLUGIN_HANDLED;
234
235 static szIcon[5]
236 get_msg_arg_string(2, szIcon, 4)
237 if( szIcon[0] == 'b' && szIcon[2] == 'y' && szIcon[3] == 'z' )
238 {
239 if( get_msg_arg_int(1))
240 {
241 fm_cs_set_user_nobuy(id)
242 return PLUGIN_HANDLED;
243 }
244 }
245
246 return PLUGIN_CONTINUE;
247}
248public fwd_Touch(ent, id)
249{
250 if (!is_user_alive(id) || !pev_valid( ent ) )
251 return FMRES_IGNORED;
252
253 static szEntModel[32];
254 pev( ent , pev_model , szEntModel , 31 );
255
256 for (new level_equip_id = PlayerLevel[id] + 1; level_equip_id < MAXLEVEL; level_equip_id++)
257 {
258 if ( equali( szEntModel , WEAPONMDL[level_equip_id] ) )
259 {
260 return FMRES_SUPERCEDE;
261 }
262 }
263
264 return FMRES_IGNORED;
265}
266public fwd_PlayerSpawn(id)
267{
268 if( !get_pcvar_num(p_Enabled) || !is_user_alive(id) )
269 return;
270
271 g_kills[id] = 0
272
273
274 #if defined ZOMBIE_SWARM
275 if ( !get_pcvar_num(level_style) && cs_get_user_team(id) == CS_TEAM_CT )
276 {
277 StripPlayerWeapons(id);
278
279 set_task(0.3, "show_main_menu_level", id)
280 }
281 #endif
282
283 #if defined NORMAL_MOD || defined ZOMBIE_INFECTION
284 if ( !get_pcvar_num(level_style))
285 {
286 StripPlayerWeapons(id);
287
288 set_task(0.3, "show_main_menu_level", id)
289 }
290 #endif
291
292 if( get_pcvar_num(show_level_text) )
293 {
294 remove_task( TASK_SHOW_LEVEL + id );
295
296 set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)
297 }
298
299 #if defined ZOMBIE_SWARM
300 if ( get_pcvar_num(level_style) && cs_get_user_team(id) == CS_TEAM_CT )
301 {
302 set_task(0.3, "give_weapon", id);
303 }
304 #endif
305
306 #if defined NORMAL_MOD || defined ZOMBIE_INFECTION
307 if ( get_pcvar_num(level_style) )
308 {
309 set_task(0.3, "give_weapon", id);
310 }
311 #endif
312
313}
314
315#if defined ZOMBIE_PLAGUE
316public zp_user_humanized_post(id, survivor)
317{
318 if( !get_pcvar_num(p_Enabled) || !is_user_alive(id) )
319 return;
320
321 set_task(1.0, "show_main_menu_level", id);
322}
323#endif
324
325#if defined ZOMBIE_BIOHAZARD
326public event_infect(g_victim, g_attacker)
327{
328 if( !get_pcvar_num(p_Enabled) )
329 return;
330
331 new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple) + get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0
332 new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra) + get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0
333
334 if((1 <= g_attacker <= g_maxplayers))
335 {
336 if(g_victim != g_attacker)
337 {
338 g_kills[g_attacker]++;
339 if(PlayerLevel[g_attacker] < MAXLEVEL-1)
340 {
341 if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
342 {
343 PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
344 }
345
346 if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
347 {
348
349 PlayerXp[g_attacker] += counted_triple
350
351 set_hudmessage(255, 255, 0, 0.50, 0.33, 1, 2.0, 2.0)
352 show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
353 }
354 else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
355 {
356 PlayerXp[g_attacker] += counted_ultra
357
358 set_hudmessage(255, 255, 0, 0.50, 0.33, 1, 2.0, 2.0)
359 show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
360 }
361 else
362 {
363 PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
364
365 set_hudmessage(255, 255, 0, 0.50, 0.33, 1, 2.0, 2.0)
366 show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
367 }
368
369 check_level(g_attacker)
370 }
371 }
372 }
373}
374#endif
375
376#if defined ZOMBIE_PLAGUE
377public zp_user_infected_post(g_victim, g_attacker)
378{
379 if( !get_pcvar_num(p_Enabled) )
380 return;
381
382 new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
383 new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
384
385 if((1 <= g_attacker <= g_maxplayers))
386 {
387 if(g_victim != g_attacker)
388 {
389 g_kills[g_attacker]++;
390 if(PlayerLevel[g_attacker] < MAXLEVEL-1)
391 {
392 if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
393 {
394 PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
395 }
396
397 if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
398 {
399 PlayerXp[g_attacker] += counted_triple
400
401 set_hudmessage(255, 255, 0, 0.50, 0.33, 1, 2.0, 2.0)
402 show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
403 }
404 else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
405 {
406 PlayerXp[g_attacker] += counted_ultra
407
408 set_hudmessage(255, 255, 0, 0.50, 0.33, 1, 2.0, 2.0)
409 show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
410 }
411 else
412 {
413 PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
414
415 set_hudmessage(255, 255, 0, 0.50, 0.33, 1, 2.0, 2.0)
416 show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
417 }
418
419 check_level(g_attacker)
420 }
421 }
422 }
423}
424#endif
425
426public event_deathmsg()
427{
428 if( !get_pcvar_num(p_Enabled) )
429 return;
430
431 new g_attacker = read_data(1);
432 new g_victim = read_data(2);
433
434 new counted_double = get_pcvar_num(xp_kill) + get_pcvar_num(xp_double)
435 new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
436 new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
437
438 if((1 <= g_attacker <= g_maxplayers))
439 {
440 if(g_victim != g_attacker)
441 {
442 new Float:timeleft = get_gametime()-timekill[g_attacker]
443 if (timeleft <= 4.0) g_kills[g_attacker] +=1
444 else g_kills[g_attacker] = 1
445 if (g_kills[g_attacker]>4) g_kills[g_attacker] = 1
446 timekill[g_attacker] = get_gametime()
447 {
448 if(PlayerLevel[g_attacker] < MAXLEVEL-1)
449 {
450 if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
451 {
452 PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
453
454 }
455
456 if ( g_kills[g_attacker] == get_pcvar_num(double_kills) && get_pcvar_num(enable_double) )
457 {
458 PlayerXp[g_attacker] += counted_double
459 acg_drawspr(g_attacker, "ACG_EK/doublekill", 255, 255, 255, 0.5, 0.35, 1, FX_FADE, 0.2, 0.4, 0.0, 1.0, DRAW_ADDITIVE, 5)
460
461 }
462
463 else if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
464 {
465 PlayerXp[g_attacker] += counted_triple
466 acg_drawspr(g_attacker, "ACG_EK/triplekill", 255, 255, 255, 0.5, 0.35, 1, FX_FADE, 0.2, 0.4, 0.0, 1.0, DRAW_ADDITIVE, 5)
467
468 }
469 else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
470 {
471 PlayerXp[g_attacker] += counted_ultra
472
473 acg_drawspr(g_attacker, "ACG_EK/multikill", 255, 255, 255, 0.5, 0.35, 1, FX_FADE, 0.2, 0.4, 0.0, 1.0, DRAW_ADDITIVE, 5)
474
475 }
476 else
477 {
478 PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
479
480 acg_drawspr(g_attacker, "ACG_EK/defaultkill", 255, 255, 255, 0.5, 0.35, 1, FX_FADE, 0.2, 0.4, 0.0, 1.0, DRAW_ADDITIVE, 8)
481
482 }
483
484 check_level(g_attacker)
485 }
486 }
487 }
488 }
489}
490
491/*public Event_StatusValue(id)
492{
493 new target = read_data(2)
494 if(target != id && target != 0 && get_pcvar_num(p_Enabled))
495 {
496 static sName[32];
497 get_user_name(target, sName, 31)
498
499 set_hudmessage(255, 255, 255, 0.6, -1.0, 0, 0.0, 6.0, 0.0, 0.0, 2)
500 ShowSyncHudMsg(id, g_msgHudSync1, "%L", LANG_SERVER, "LEVEL_TEXT", sName, PlayerLevel[target], RANKLEVELS[PlayerLevel[target]])
501 }
502}*/
503public task_show_level(task)
504{
505 new id = task - TASK_SHOW_LEVEL
506
507 if(!is_user_alive(id) || !get_pcvar_num(show_level_text) || !get_pcvar_num(p_Enabled) )
508 return;
509
510 set_hudmessage(0, 200, 0, 0.02, 0.7, 0, 0.0, 0.3, 0.0, 0.0)
511 ShowSyncHudMsg(id, g_msgHudSync1 , "%L", LANG_SERVER, "LEVEL_HUD_TEXT", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]], RANK[PlayerLevel[id]], RANKLEVELS[PlayerLevel[id]])
512
513 set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)
514}
515public showlevel(id)
516{
517 if ( !get_pcvar_num(p_Enabled) || get_pcvar_num(show_level_text) )
518 return PLUGIN_HANDLED;
519
520 client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT2", PlayerLevel[id] , PlayerXp[id], LEVELS[PlayerLevel[id]]);
521 client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT3", RANK[PlayerLevel[id]], RANKLEVELS[PlayerLevel[id]]);
522
523 return PLUGIN_HANDLED;
524}
525public descriptionx(id)
526{
527 new szMotd[2048], szTitle[64], iPos = 0
528 format(szTitle, 63, "Info")
529 iPos += format(szMotd[iPos], 2047-iPos, "<html><head><style type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-top:0px;}</style></head><pre><body>")
530 iPos += format(szMotd[iPos], 2047-iPos, "^n^n<b>%s</b>^n^n", szTitle)
531 iPos += format(szMotd[iPos], 2047-iPos, "%L^n", LANG_SERVER, "DESCRIPTION")
532
533 iPos += format(szMotd[iPos], 2047-iPos, "%L", LANG_SERVER, "DESCRIPTION2")
534
535 show_motd(id, szMotd, szTitle)
536 return PLUGIN_HANDLED;
537}
538public check_level(id)
539{
540 if(PlayerLevel[id] < MAXLEVEL-1 && get_pcvar_num(p_Enabled))
541 {
542 while(PlayerXp[id] >= LEVELS[PlayerLevel[id]])
543 {
544 PlayerLevel[id]++;
545
546 if(is_user_alive(id))
547 {
548 if ( get_pcvar_num(level_style) )
549 {
550 give_weapon(id);
551 }
552 }
553 client_cmd(id, "spk sound/MW/levelup.wav");
554 set_task(0.3, "promotion_display", id)
555 static name[32] ; get_user_name(id, name, charsmax(name));
556 client_printcolor(0, "%L", LANG_SERVER, "LEVEL_UP", name, PlayerLevel[id]);
557 }
558 }
559}
560// Main Menu Info
561
562public promotion_display(id)
563{
564 acg_drawtga(id, "gfx/promotion.tga", 255, 255, 255, 255, 0.55, 0.2, 1, FX_FADE, 0.4, 0.4, 0.0, 4.0, 0, 0, 6)
565 //native acg_drawtga(id, const szTGA[], red, green, blue, alpha, Float:x, Float:y, center, effects, Float:fadeintime, Float:fadeouttime, Float:fxtime, Float:holdtime, bfullscreen, align, channel)
566}
567
568public show_main_menu_info(id)
569{
570 if ( !get_pcvar_num(p_Enabled) )
571 return;
572
573 static menu[510], len;
574 len = 0;
575
576 new xKeys3 = MENU_KEY_0|MENU_KEY_1;
577
578 // Title
579 len += formatex(menu[len], sizeof menu - 1 - len, "%L", LANG_SERVER, "TITLE_MENU_INFO")
580
581 len += formatex(menu[len], sizeof menu - 1 - len, "\r1. \w%L", id, "INFO")
582 if ( get_pcvar_num(show_rank) )
583 {
584 xKeys3 |= (MENU_KEY_2)
585
586 len += formatex(menu[len], sizeof menu - 1 - len, "^n\r2. \wTop 20^n")
587 }
588 else
589 {
590 len += formatex(menu[len], sizeof menu - 1 - len, "^n\d2. Top 20^n")
591 }
592
593 if(find_plugin_byfile("gunxpmod_shop.amxx") != INVALID_PLUGIN_ID)
594 {
595 xKeys3 |= (MENU_KEY_3)
596
597 len += formatex(menu[len], sizeof menu - 1 - len, "\r3. \w%L^n", id, "ITEM_LIST")
598 if ( is_user_alive(id) )
599 {
600 xKeys3 |= (MENU_KEY_4)
601
602 len += formatex(menu[len], sizeof menu - 1 - len, "\r4. \w%L^n", id, "UNLOCKS_SHOP_TEXT")
603 }
604 }
605
606 len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r0.\w %L", id, "EXIT_MENU")
607
608 show_menu(id, xKeys3, menu, -1, "Main Menu")
609}
610public main_menu_info(id, key)
611{
612 switch (key)
613 {
614 case 0:
615 {
616 show_main_menu_info(id)
617
618 descriptionx(id)
619 }
620 case 1:
621 {
622 showtop20(id)
623
624 show_main_menu_info(id)
625 }
626 case 2:
627 {
628 show_main_menu_info(id)
629
630 if(callfunc_begin( "display_items","gunxpmod_shop.amxx") == 1)
631 {
632 callfunc_push_int( id );
633 callfunc_end();
634 }
635 }
636 case 3:
637 {
638 if(callfunc_begin("item_upgrades","gunxpmod_shop.amxx") == 1)
639 {
640 callfunc_push_int( id );
641 callfunc_end();
642 }
643 }
644 case 9:
645 {
646 return PLUGIN_HANDLED;
647 }
648 }
649
650 return PLUGIN_HANDLED;
651}
652// Main Menu Level Style
653public show_main_menu_level(id)
654{
655 if ( !is_user_alive(id) )
656 return;
657
658 new szInfo[60], szChooseT[40], szLastG[40];
659 formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
660
661 new menu = menu_create(szInfo , "main_menu_level");
662
663 formatex(szChooseT, charsmax(szChooseT), "%L", LANG_SERVER, "CHOOSE_TEXT");
664 menu_additem(menu, szChooseT, "1", 0);
665
666 formatex(szLastG, charsmax(szLastG), "%L", LANG_SERVER, "LAST_GUNS");
667 menu_additem(menu, szLastG, "2", 0);
668
669 new szExit[15];
670 formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
671
672 menu_setprop(menu, MPROP_EXITNAME, szExit);
673
674 menu_display(id , menu , 0);
675}
676public main_menu_level(id , menu , item, givegren)
677{
678 if ( !is_user_alive(id) )
679 {
680 return PLUGIN_HANDLED;
681 }
682
683 #if defined ZOMBIE_PLAGUE
684 if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
685 return PLUGIN_HANDLED;
686 #endif
687
688 if(item == MENU_EXIT)
689 {
690 menu_destroy(menu);
691 return PLUGIN_HANDLED;
692 }
693 new data[6], iName[64];
694 new access, callback;
695 menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
696
697 new item_id = str_to_num(data);
698
699 switch (item_id)
700 {
701 case 1: // show pistols
702 {
703 show_menu_level_pistol(id);
704 }
705 case 2: // last weapons
706 {
707 if ( PlayerLevel[id] > MAX_PISTOLS_MENU - 1)
708 {
709 give_weapon_menu(id, g_remember_selection[id], 0, 0);
710 give_weapon_menu(id, g_remember_selection_pistol[id], 0, 0);
711 give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
712 give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
713 give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
714 give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
715 }
716
717 else if ( PlayerLevel[id] < MAX_PISTOLS_MENU)
718 {
719 give_weapon_menu(id, g_remember_selection[id], 0, 0);
720 give_weapon_menu(id, g_remember_selection_pistol[id], 0, 0);
721 give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
722 give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
723 give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
724 give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
725 }
726
727
728
729 }
730 }
731
732 menu_destroy(menu);
733 return PLUGIN_HANDLED;
734}
735// Menu Level Style Pistols
736public show_menu_level_pistol(id)
737{
738 if ( !is_user_alive(id) )
739 return;
740
741 new szInfo[60];
742 formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
743
744 new menu = menu_create(szInfo , "pistol_menu");
745
746 for (new item_id = 0; item_id < MAX_PISTOLS_MENU; item_id++)
747 {
748 new szItems[60], szTempid[32];
749
750 if ( PlayerLevel[id] >= GUN_LEVELS[item_id] )
751 {
752 formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "ACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
753
754 num_to_str(item_id, szTempid, charsmax(szTempid) );
755
756 menu_additem(menu, szItems, szTempid, 0);
757 }
758
759 else
760 {
761 formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "INACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
762 menu_additem(menu, szItems, "999", 0, menu_makecallback("CallbackMenu"));
763 }
764 }
765
766 new szNext[15], szBack[15], szExit[15];
767 formatex(szBack, charsmax(szBack), "%L", LANG_SERVER, "BACK_MENU");
768 formatex(szNext, charsmax(szNext), "%L", LANG_SERVER, "NEXT_MENU");
769 formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
770
771 menu_setprop(menu, MPROP_BACKNAME, szBack)
772 menu_setprop(menu, MPROP_NEXTNAME, szNext)
773 menu_setprop(menu, MPROP_EXITNAME, szExit)
774
775 menu_display(id , menu , 0);
776}
777public pistol_menu(id , menu , item, player)
778{
779 if ( !is_user_alive(id) )
780 {
781 return PLUGIN_HANDLED;
782 }
783
784 #if defined ZOMBIE_PLAGUE
785 if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
786 return PLUGIN_HANDLED;
787 #endif
788
789 if(item == MENU_EXIT)
790 {
791 menu_destroy(menu);
792 return PLUGIN_HANDLED;
793 }
794
795 new data[6], iName[64];
796 new access, callback;
797 menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
798
799 new item_id = str_to_num(data);
800
801
802 g_remember_selection_pistol[id] = item_id;
803
804 give_weapon_menu(id, item_id, 1, 1);
805
806 show_menu_level(id);
807
808 menu_destroy(menu);
809 return PLUGIN_HANDLED;
810}
811// Menu Level Style Primary
812public show_menu_level(id)
813{
814 if ( !is_user_alive(id))
815 return;
816
817 new szInfo[100];
818 formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
819
820 new menu = menu_create(szInfo , "level_menu");
821
822 for (new item_id = MAX_PISTOLS_MENU; item_id < MAXLEVEL; item_id++)
823 {
824 new szItems[512], szTempid[32];
825
826 if ( PlayerLevel[id] >= GUN_LEVELS[item_id] )
827 {
828 formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "ACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
829
830 num_to_str(item_id, szTempid, charsmax(szTempid) );
831
832 menu_additem(menu, szItems, szTempid, 0);
833 }
834 else
835 {
836 formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "INACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
837 menu_additem(menu, szItems, "999", 0, menu_makecallback("CallbackMenu"));
838 }
839 }
840
841 new szNext[15], szBack[15], szExit[15];
842 formatex(szBack, charsmax(szBack), "%L", LANG_SERVER, "BACK_MENU");
843 formatex(szNext, charsmax(szNext), "%L", LANG_SERVER, "NEXT_MENU");
844 formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
845
846 menu_setprop(menu, MPROP_BACKNAME, szBack)
847 menu_setprop(menu, MPROP_NEXTNAME, szNext)
848 menu_setprop(menu, MPROP_EXITNAME, szExit)
849
850 menu_display(id , menu , 0);
851}
852public level_menu(id , menu , item)
853{
854 if ( !is_user_alive(id))
855 {
856 return PLUGIN_HANDLED;
857 }
858
859 #if defined ZOMBIE_PLAGUE
860 if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
861 return PLUGIN_HANDLED;
862 #endif
863
864 if(item == MENU_EXIT)
865 {
866 menu_destroy(menu);
867 return PLUGIN_HANDLED;
868 }
869 new data[6], iName[64];
870 new access, callback;
871 menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
872
873 new item_id = str_to_num(data);
874
875 g_remember_selection[id] = item_id;
876
877 give_weapon_menu(id, item_id, 0, 0);
878
879 menu_destroy(menu);
880 return PLUGIN_HANDLED;
881}
882public CallbackMenu(id, menu, item)
883{
884 return ITEM_DISABLED;
885}
886
887// Selected by menu or remember selection and give item
888public give_weapon_menu(id, selection, strip, givegren)
889{
890 #if defined ZOMBIE_SWARM
891 if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && get_pcvar_num(p_Enabled) )
892 {
893 if ( strip )
894 {
895 StripPlayerWeapons(id);
896 }
897
898 if ( get_pcvar_num(enable_grenades) && givegren )
899 {
900 give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
901 give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
902 give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
903 give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
904 }
905
906 give_item(id, WEAPONCONST[selection]);
907 new weapons[32], weaponsnum;
908 get_user_weapons(id, weapons, weaponsnum);
909 for(new i=0; i<weaponsnum; i++)
910 if(maxAmmo[weapons[i]] > 0)
911 cs_set_user_bpammo(id, weapons[i], maxAmmo[weapons[i]]);
912 }
913 #endif
914
915 #if defined ZOMBIE_INFECTION || defined NORMAL_MOD
916 if(is_user_alive(id) && get_pcvar_num(p_Enabled))
917 {
918 if ( strip )
919 {
920 StripPlayerWeapons(id);
921 }
922
923 if ( get_pcvar_num(enable_grenades) && givegren )
924 {
925 give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
926 give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
927 give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
928 give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
929 }
930
931 give_item(id, WEAPONCONST[selection]);
932 new weapons[32], weaponsnum;
933 get_user_weapons(id, weapons, weaponsnum);
934 for(new i=0; i<weaponsnum; i++)
935 if(maxAmmo[weapons[i]] > 0)
936 cs_set_user_bpammo(id, weapons[i], maxAmmo[weapons[i]]);
937 }
938 #endif
939}
940public give_weapon(id)
941{
942 #if defined ZOMBIE_SWARM
943 if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && get_pcvar_num(p_Enabled))
944 {
945 StripPlayerWeapons(id);
946
947 if ( get_pcvar_num(enable_grenades) && get_pcvar_num(level_style) )
948 {
949 give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
950 give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
951 give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
952 give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
953 }
954
955 give_item(id, WEAPONCONST[PlayerLevel[id]]);
956
957 new weapons[32], weaponsnum;
958 get_user_weapons(id, weapons, weaponsnum);
959 for(new i=0; i<weaponsnum; i++)
960 if(maxAmmo[weapons[i]] > 0)
961 cs_set_user_bpammo(id, weapons[i], maxAmmo[weapons[i]]);
962 }
963 #endif
964
965 #if defined ZOMBIE_INFECTION || defined NORMAL_MOD
966 if(is_user_alive(id) && get_pcvar_num(p_Enabled))
967 {
968 StripPlayerWeapons(id);
969
970 if ( get_pcvar_num(enable_grenades) && get_pcvar_num(level_style) )
971 {
972 give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
973 give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
974 give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
975 give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
976 }
977
978 give_item(id, WEAPONCONST[PlayerLevel[id]]);
979 new weapons[32], weaponsnum;
980 get_user_weapons(id, weapons, weaponsnum);
981 for(new i=0; i<weaponsnum; i++)
982 if(maxAmmo[weapons[i]] > 0)
983 cs_set_user_bpammo(id, weapons[i], maxAmmo[weapons[i]]);
984 }
985 #endif
986}
987
988
989public set_sprite(p_origin[3], sprite, radius)
990{
991 // Explosion
992 message_begin(MSG_BROADCAST, SVC_TEMPENTITY, p_origin)
993 write_byte(TE_EXPLOSION)
994 write_coord(p_origin[0])
995 write_coord(p_origin[1])
996 write_coord(p_origin[2])
997 write_short(sprite)
998 write_byte(radius)
999 write_byte(15)
1000 write_byte(4)
1001 message_end()
1002}
1003//Shows Top 20
1004public showtop20(id)
1005{
1006 if( !get_pcvar_num(p_Enabled) && !get_pcvar_num(show_rank) )
1007 return;
1008
1009 static Sort[33][2];
1010 new players[32],num,count,index;
1011 get_players(players,num);
1012
1013 for(new i = 0; i < num; i++)
1014 {
1015 index = players[i];
1016 Sort[count][0] = index;
1017 Sort[count][1] = PlayerXp[index];
1018 count++;
1019 }
1020
1021 SortCustom2D(Sort,count,"CompareXp");
1022 new motd[1501],iLen;
1023 iLen = formatex(motd, sizeof motd - 1,"<body bgcolor=#000000><font color=#98f5ff><pre>");
1024 iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"%s %-22.22s %3s^n", "#", "Name", "# Experience");
1025
1026 new y = clamp(count,0,20);
1027 new name[32],kindex;
1028
1029 for(new x = 0; x < y; x++)
1030 {
1031 kindex = Sort[x][0];
1032 get_user_name(kindex,name,sizeof name - 1);
1033 iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"%d %-22.22s %d^n", x + 1, name, Sort[x][1]);
1034 }
1035 iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"</body></font></pre>");
1036 show_motd(id,motd, "GunXpMod Top 20");
1037}
1038public CompareXp(elem1[], elem2[])
1039{
1040 if(elem1[1] > elem2[1])
1041 return -1;
1042 else if(elem1[1] < elem2[1])
1043 return 1;
1044
1045 return 0;
1046}
1047// Command to set player Level
1048public cmd_give_level(id, level, cid)
1049{
1050 if( !cmd_access(id, level, cid, 3) || !get_pcvar_num(p_Enabled) )
1051 {
1052 return PLUGIN_HANDLED;
1053 }
1054
1055 new Arg1[64], Target
1056 read_argv(1, Arg1, 63)
1057 Target = cmd_target(id, Arg1, 0)
1058
1059 new iLevel[32], Value
1060 read_argv(2, iLevel, 31)
1061 Value = str_to_num(iLevel)
1062
1063 if(iLevel[0] == '-')
1064 {
1065 console_print(id, "You can't have a '-' in the value!")
1066 return PLUGIN_HANDLED;
1067 }
1068
1069 if(!Target)
1070 {
1071 console_print(id, "Target not found!")
1072 return PLUGIN_HANDLED;
1073 }
1074
1075 if(Value > MAXLEVEL-1)
1076 {
1077 console_print(id, "You can't set a more than %d!", MAXLEVEL-1)
1078 return PLUGIN_HANDLED;
1079 }
1080
1081 if(Value < 1)
1082 {
1083 console_print(id, "You can't set less than 1!")
1084 return PLUGIN_HANDLED;
1085 }
1086
1087 new AdminName[32]
1088 get_user_name(id, AdminName, 31)
1089
1090 new TargetName[32]
1091 get_user_name(Target, TargetName, 31)
1092
1093 PlayerLevel[Target] = Value - 1
1094 PlayerXp[Target] = LEVELS[PlayerLevel[Target]]
1095 check_level(Target)
1096
1097 client_printcolor(Target, "/gADMIN: /ctr%s /yhas set your level to /g%d", AdminName, Value)
1098
1099 return PLUGIN_HANDLED;
1100}
1101
1102// ============================================================//
1103// [~ Saving datas ~] //
1104// ============================================================//
1105public MySQLx_Init()
1106{
1107 if ( !get_pcvar_num(p_Enabled) || !get_pcvar_num(save_type) )
1108 return;
1109
1110 new szHost[64], szUser[32], szPass[32], szDB[128];
1111
1112 get_pcvar_string( mysqlx_host, szHost, charsmax( szHost ) );
1113 get_pcvar_string( mysqlx_user, szUser, charsmax( szUser ) );
1114 get_pcvar_string( mysqlx_pass, szPass, charsmax( szPass ) );
1115 get_pcvar_string( mysqlx_db, szDB, charsmax( szDB ) );
1116
1117 g_hTuple = SQL_MakeDbTuple( szHost, szUser, szPass, szDB );
1118
1119 for ( new i = 0; i < sizeof szTables; i++ )
1120 {
1121 SQL_ThreadQuery( g_hTuple, "QueryCreateTable", szTables[i])
1122 }
1123}
1124public QueryCreateTable( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime )
1125{
1126 if( iFailState == TQUERY_CONNECT_FAILED
1127 || iFailState == TQUERY_QUERY_FAILED )
1128 {
1129 log_amx( "%s", szError );
1130
1131 return;
1132 }
1133}
1134
1135SaveLevel(id)
1136{
1137 new szAuth[33];
1138 new szKey[64];
1139
1140 if ( get_pcvar_num(savexp) == 0 )
1141 {
1142 get_user_ip( id, szAuth , charsmax(szAuth), 1);
1143 formatex( szKey , 63 , "%s-IP" , szAuth);
1144 }
1145 else if ( get_pcvar_num(savexp) == 1 )
1146 {
1147 get_user_authid( id , szAuth , charsmax(szAuth) );
1148 formatex( szKey , 63 , "%s-ID" , szAuth);
1149 }
1150 else if ( get_pcvar_num(savexp) == 2 )
1151 {
1152 get_user_name( id, szAuth , charsmax(szAuth) );
1153 formatex( szKey , 63 , "%s-NAME" , szAuth);
1154 }
1155
1156 if ( !get_pcvar_num(save_type) )
1157 {
1158 new szData[256];
1159
1160 formatex( szData , 255 , "%i#%i#" , PlayerLevel[id], PlayerXp[id] );
1161
1162 nvault_set( g_Vault , szKey , szData );
1163 }
1164 else
1165 {
1166 static szQuery[ 128 ];
1167
1168 formatex( szQuery, 127, "REPLACE INTO `mytable` (`player_id`, `player_level`, `player_xp`) VALUES ('%s', '%d', '%d');", szAuth , PlayerLevel[id], PlayerXp[id] );
1169
1170 SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
1171 }
1172}
1173
1174LoadLevel(id)
1175{
1176 new szAuth[33];
1177 new szKey[40];
1178
1179 if ( get_pcvar_num(savexp) == 0 )
1180 {
1181 get_user_ip( id, szAuth , charsmax(szAuth), 1);
1182 formatex( szKey , 63 , "%s-IP" , szAuth);
1183 }
1184 else if ( get_pcvar_num(savexp) == 1 )
1185 {
1186 get_user_authid( id , szAuth , charsmax(szAuth) );
1187 formatex( szKey , 63 , "%s-ID" , szAuth);
1188 }
1189 else if ( get_pcvar_num(savexp) == 2 )
1190 {
1191 get_user_name( id, szAuth , charsmax(szAuth) );
1192 formatex( szKey , 63 , "%s-NAME" , szAuth);
1193 }
1194
1195 if ( !get_pcvar_num(save_type) )
1196 {
1197 new szData[256];
1198
1199 formatex(szData , 255, "%i#%i#", PlayerLevel[id], PlayerXp[id])
1200
1201 nvault_get(g_Vault, szKey, szData, 255)
1202
1203 replace_all(szData , 255, "#", " ")
1204 new xp[32], level[32]
1205 parse(szData, level, 31, xp, 31)
1206 PlayerLevel[id] = str_to_num(level)
1207 PlayerXp[id] = str_to_num(xp)
1208 }
1209 else
1210 {
1211 static szQuery[ 128 ], iData[ 1 ];
1212 formatex( szQuery, 127, "SELECT `player_level`, `player_xp` FROM `mytable` WHERE ( `player_id` = '%s' );", szAuth );
1213
1214 iData[ 0 ] = id;
1215 SQL_ThreadQuery( g_hTuple, "QuerySelectData", szQuery, iData, 1 );
1216 }
1217}
1218public QuerySelectData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime )
1219{
1220 if( iFailState == TQUERY_CONNECT_FAILED
1221 || iFailState == TQUERY_QUERY_FAILED )
1222 {
1223 log_amx( "%s", szError );
1224
1225 return;
1226 }
1227 else
1228 {
1229 new id = iData[ 0 ];
1230
1231 new ColLevel = SQL_FieldNameToNum(hQuery, "player_level")
1232 new ColXp = SQL_FieldNameToNum(hQuery, "player_xp")
1233
1234 while (SQL_MoreResults(hQuery))
1235 {
1236 PlayerLevel[id] = SQL_ReadResult(hQuery, ColLevel);
1237 PlayerXp[id] = SQL_ReadResult(hQuery, ColXp);
1238
1239 SQL_NextRow(hQuery)
1240 }
1241 }
1242}
1243public QuerySetData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime )
1244{
1245 if( iFailState == TQUERY_CONNECT_FAILED
1246 || iFailState == TQUERY_QUERY_FAILED )
1247 {
1248 log_amx( "%s", szError );
1249
1250 return;
1251 }
1252}
1253// ============================================================//
1254// [~ Natives ~] //
1255// ============================================================//
1256// Native: get_user_xp
1257public native_get_user_xp(id)
1258{
1259 return PlayerXp[id];
1260}
1261// Native: set_user_xp
1262public native_set_user_xp(id, amount)
1263{
1264 PlayerXp[id] = amount;
1265}
1266// Native: get_user_level
1267public native_get_user_level(id)
1268{
1269 return PlayerLevel[id];
1270}
1271// Native: set_user_xp
1272public native_set_user_level(id, amount)
1273{
1274 PlayerLevel[id] = amount;
1275}
1276// Native: Gets user level by Xp
1277public native_get_user_max_level(id)
1278{
1279 return LEVELS[PlayerLevel[id]];
1280}
1281// ============================================================//
1282// [~ Stocks ~] //
1283// ============================================================//
1284stock client_printcolor(const id, const input[], any:...)
1285{
1286 new count = 1, players[32];
1287 static msg[191];
1288 vformat(msg,190,input,3);
1289 replace_all(msg,190,"/g","^4");// green txt
1290 replace_all(msg,190,"/y","^1");// orange txt
1291 replace_all(msg,190,"/ctr","^3");// team txt
1292 replace_all(msg,190,"/w","^0");// team txt
1293 if (id) players[0] = id; else get_players(players,count,"ch");
1294 for (new i = 0; i < count; i++)
1295 if (is_user_connected(players[i]))
1296 {
1297 message_begin(MSG_ONE_UNRELIABLE, SayTxT, _, players[i]);
1298 write_byte(players[i]);
1299 write_string(msg);
1300 message_end();
1301 }
1302}
1303public StripPlayerWeapons(id)
1304{
1305 strip_user_weapons(id)
1306 set_pdata_int(id, OFFSET_PRIMARYWEAPON, 0)
1307 give_item(id, "weapon_knife");
1308}