View Single Post
Author Message
Copper
Senior Member
Join Date: Feb 2012
Location: California
Old 07-18-2016 , 00:26   cvar doesnt work
Reply With Quote #1

Can anyone tell what I did wrong. register_cvar("pm_xpmultiplier", "2") doesnt want to work because I have it set to 2 but it gives me 3x xp. Let me know anything please and thank you.
Code:
#include <amxmodx>
#include <hamsandwich>
#include <pokemod>
 
new bool: g_happytime, cvar_hh_start, cvar_hh_end, g_exp[33]


 public plugin_init()  
{
    
	cvar_hh_start = register_cvar("Happy Hour Start","21")
    cvar_hh_end = register_cvar("Happy Hour End","22")
    RegisterHam(Ham_Killed, "player", "fw_playerkilled_post", 1)
	set_task( 180.0, "ev_Start", .flags="b" )
	register_cvar("pm_xpmultiplier", "2")
}
 
public ev_Start( )  
{  
    static data[ 9 ];
    get_time( "%H", data, 8 );
     
    new Hour = str_to_num( data );
     
    if (get_pcvar_num(cvar_hh_end) > Hour >= get_pcvar_num(cvar_hh_start))
    {
        g_happytime = true;
        client_print(0, print_chat, "Happy Hour is Active! Double XP per Kill")
    }
}
 
public fw_playerkilled_post(victim, attacker)
{
    if(!is_user_connected(attacker))
        return HAM_IGNORED;
     
    if(victim == attacker)
        return HAM_IGNORED;
         
    if(g_happytime) 
    { 
        new xp = ( (Poke_PlayerLevel( victim, -1 ) ) * (get_cvar_num("pm_xpmultiplier") - 1) )

		Poke_Give_XP(attacker, -1, xp);
    }
	else
    {
        g_exp[attacker]++ // example happyhour off
    }
    return HAM_IGNORED;
}
Copper is offline