New Member
06-23-2012
, 00:46
Re: Hud Not Updating Properly? o.0
#3
thanks for moving, i didn't realize I posted it here. Anyway, i'm not sure what you mean by the correct id in set task. how would i know?
Also anther question:
when my xp goes over the required to level: ex. you need 100 xp and its at 105. it wont level up. from 0 to lvl 1? o.o so frustrating.
Spoiler
PHP Code:
#include <amxmodx> #include <amxmisc> #include <nvault> #include <fun> enum { PLAYERLEVEL_1 , PLAYERLEVEL_2 , PLAYERLEVEL_3 , PLAYERLEVEL_4 , PLAYERLEVEL_5 , PLAYERLEVEL_6 } new const LEVELS [ 6 ] = { 100 , 200 , 400 , 800 , 1600 , 3200 }; new PlayerXP [ 33 ], PlayerLevel [ 33 ], PlayerSkills [ 33 ]; new gCvar_Kill , gCvar_Knife , gCvar_HS , gCvar_Enable , g_Vault ; public plugin_init () { register_plugin ( "mo0d" , "1.0" , "d" ); register_event ( "DeathMsg" , "eDeath" , "a" ); gCvar_Enable = register_cvar ( "xp_save" , "1" ); gCvar_Kill = register_cvar ( "xp_per_kill" , "20" ); gCvar_HS = register_cvar ( "xp_hs_bonus" , "20" ); gCvar_Knife = register_cvar ( "xp_Knife_bonus" , "20" ); g_Vault = nvault_open ( "mo0d" ); register_clcmd ( "say /xp" , "ShowHud" ); register_clcmd ( "say_team /xp" , "ShowHud" ); register_concmd ( "amx_give_xp" , "cmd_give_exp" , ADMIN_KICK , "<target> <amount>" ); set_task ( 0.1 , "ShowHud" , id , "" , 0 , "b" ) } public ShowHud ( id ) { set_hudmessage ( 255 , 0 , 0 , 0.75 , 0.01 , 0 , 6.0 , 15.0 ); show_hudmessage ( id , "Level: %i^nXP: %i^nSkill Points: %i" , PlayerLevel [ id ], PlayerXP [ id ], PlayerSkills [ id ]); } public eDeath () { new attacker = read_data ( 1 ); new headshot = read_data ( 3 ); new clip , ammo , weapon = get_user_weapon ( attacker , clip , ammo ); PlayerXP [ attacker ] += get_pcvar_num ( gCvar_Kill ); if( headshot ) PlayerXP [ attacker ] += get_pcvar_num ( gCvar_HS ); if( weapon == CSW_KNIFE ) PlayerXP [ attacker ] += get_pcvar_num ( gCvar_Knife ); while( PlayerXP [ attacker ] >= LEVELS [ PlayerLevel [ attacker ]]) { client_print ( attacker , print_chat , "[%s] Congratulations! You are level %i !" , PlayerLevel [ attacker ]); PlayerLevel [ attacker ] += 1 ; PlayerSkills [ attacker ] += 1 ; } ShowHud ( attacker ); SaveData ( attacker ); } public client_connect ( id ) if( get_pcvar_num ( gCvar_Enable ) == 1 ) LoadData ( id ); public client_disconnect ( id ) { if( get_pcvar_num ( gCvar_Enable ) == 1 ) SaveData ( id ); PlayerXP [ id ] = 0 ; PlayerLevel [ id ] = 0 ; PlayerSkills [ id ] = 0 ; } public SaveData ( id ) { new AuthID [ 35 ]; get_user_authid ( id , AuthID , 34 ); new vaultkey [ 64 ], vaultdata [ 256 ]; format ( vaultkey , 63 , "%s-Mod" , AuthID ); format ( vaultdata , 255 , "%i#%i#" , PlayerXP [ id ], PlayerLevel [ id ], PlayerSkills [ id ]); nvault_set ( g_Vault , vaultkey , vaultdata ); return PLUGIN_CONTINUE ; } public LoadData ( id ) { new AuthID [ 35 ]; get_user_authid ( id , AuthID , 34 ); new vaultkey [ 64 ], vaultdata [ 256 ]; format ( vaultkey , 63 , "%s-Mod" , AuthID ); format ( vaultdata , 255 , "%i#%i#" , PlayerXP [ id ], PlayerLevel [ id ], PlayerSkills [ id ]); nvault_get ( g_Vault , vaultkey , vaultdata , 255 ); replace_all ( vaultdata , 255 , "#" , " " ); new playerxp [ 32 ], playerlevel [ 32 ]; parse ( vaultdata , playerxp , 31 , playerlevel , 31 ); PlayerXP [ id ] = str_to_num ( playerxp ); PlayerLevel [ id ] = str_to_num ( playerlevel ); return PLUGIN_CONTINUE ; } public cmd_give_exp ( id , level , cid ) { if( ! cmd_access ( id , level , cid , 3 ) ) return PLUGIN_HANDLED ; new target [ 32 ], amount [ 21 ], reason [ 21 ]; read_argv ( 1 , target , 31 ); read_argv ( 2 , amount , 20 ); read_argv ( 3 , reason , 20 ); new player = cmd_target ( id , target , 8 ); if( ! player ) return PLUGIN_HANDLED ; new admin_name [ 32 ], player_name [ 32 ]; get_user_name ( id , admin_name , 31 ); get_user_name ( player , player_name , 31 ); new expnum = str_to_num ( amount ); PlayerXP [ player ] += expnum ; switch( get_cvar_num ( "amx_show_activity" ) ) { case 1 : client_print ( 0 , print_chat , "ADMIN: gave %i EXP to %s." , expnum , player_name ); case 2 : client_print ( 0 , print_chat , "ADMIN %s: gave %i EXP to %s." , admin_name , expnum , player_name ); } client_print ( player , print_chat , "[AMXX] You received %i EXP. (Total: %d)" , expnum , PlayerXP [ player ] ); SaveData ( id ) return PLUGIN_CONTINUE ; }
Last edited by ConnorMcLeod; 06-23-2012 at 11:23 .