SHARE
TWEET

Untitled

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