View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-18-2016 , 18:50   Re: cvar doesnt work
Reply With Quote #4

Why do you have -1 here, that is essentially making the multiplier do nothing when the cvar is set to 2.

new xp = ( (Poke_PlayerLevel( victim, -1 ) ) * (get_cvar_num("pm_xpmultiplier") - 1) )

I fixed some other things too. Untested.
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <pokemod>
 
#define MAX_PLAYERS    32

new bool:g_happytimecvar_hh_startcvar_hh_endcvar_multiplierg_expMAX_PLAYERS ];

public 
plugin_init()  
{
    
cvar_hh_start register_cvar("Happy Hour Start","21")
    
cvar_hh_end register_cvar("Happy Hour End","22")
    
cvar_multiplier register_cvar("pm_xpmultiplier""2")
    
    
RegisterHam(Ham_Killed"player""fw_playerkilled_post"1)
    
    
set_task180.0"ev_Start", .flags="b" )
}
 
public 
ev_Start( )  
{  
    new 
data];
    
get_time"%H" data charsmaxdata ) );
    
    if ( 
get_pcvar_num(cvar_hh_end) > str_to_numdata ) >= get_pcvar_numcvar_hh_start ) )
    {
        
g_happytime true;
        
client_printprint_chat"Happy Hour is Active! Double XP per Kill")
    }
}
 
public 
fw_playerkilled_post(victimattacker)
{
    if( ( 
victim == attacker ) || !is_user_connectedattacker ) )
        return 
HAM_IGNORED;
    
    if ( 
g_happytime 
    { 
        new 
xp = ( ( Poke_PlayerLevelvictim, -) ) * get_pcvar_numcvar_multiplier ) )
        
        
Poke_Give_XPattacker , -xp );
    }
    else
    {
        
g_expattacker ]++ // example happyhour off
    
}
    
    return 
HAM_IGNORED;

__________________

Last edited by Bugsy; 07-18-2016 at 18:53.
Bugsy is offline