i think this works.
Code:
public AddXP(id, ammount) {
if ( g_PlayerClass[id] > 0) {
g_PlayerXP[id] += ammount
for ( new i = 0 ; i < MAXLEVELS ; i++ ) {
if ( g_PlayerLevel[id]!= MAXLEVELS + 1 ) {
if ( g_PlayerXP[id] >= LEVELS[g_PlayerLevel[id] + 1 ]) {
g_PlayerLevel[id]++
client_print(id, print_chat, "[* Mod] Congratulations! You are now level %i!", g_PlayerLevel[id])
}
if ( g_PlayerXP[id] < LEVELS[g_PlayerLevel[id]])
if ( g_PlayerLevel[id] > 0 )
g_PlayerLevel[id]--
}
}
}
if(get_cvar_num("MM_savexp") == 1) {
SaveXP(id)
}
ShowHUD(id) // Call This every time xp changes.
}
change your DeathMsg to this:
Code:
public DeathMsg() {
if(!get_cvar_num("sv_mythmod"))
return
new attacker = read_data(1)
new tempxp = get_cvar_num("MM_xp_per_kill")
AddXP(attacker, tempxp)
}
and to that other problem with set_user_health, add if ( is_user_alive(id) && is_user_connected(id) ) {
set_user_hp(id, 100 + .....
and if you got a cvar, for giving xp, do something like this:
Code:
public GiveXP(id, level, cid) {
if (! cmd_access( id, level, cid, 0 ) )
return PLUGIN_HANDLED
new arg[32], xp[10]
read_argv(1, arg, 31)
read_argv(2, xp, 9)
new player = cmd_target( id, arg, 2 )
if ( !player ) {
return PLUGIN_HANDLED
}
AddXP(player, str_to_num(xp))
client_print(player,print_chat,"An admin gave you %d xp", str_to_num(xp))
ShowHUD(id)
return PLUGIN_CONTINUE
}
hope this helps ya