Raised This Month: $12 Target: $400
 3% 

cvar doesnt work


Post New Thread Reply   
 
Thread Tools Display Modes
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
Old 07-18-2016, 09:48
gabuch2
This message has been deleted by gabuch2.
sirerick
Senior Member
Join Date: Jul 2012
Location: Venezuela
Old 07-18-2016 , 12:40   Re: cvar doesnt work
Reply With Quote #2

Delete g_exp its was a example put on else you normal xp, maybe too because you give poketexp elsewhere
__________________
√ Zombie plague + greats updates. finished.
√ Surf-Mod level + greats updates Finished.
√ Zombie Scenario like cso. Finished.
Click Here
√ Call Of Duty MOD. Finished.
Click Here


Sorry for my bad english. I'm using translate.
sirerick is offline
Copper
Senior Member
Join Date: Feb 2012
Location: California
Old 07-18-2016 , 18:28   Re: cvar doesnt work
Reply With Quote #3

I dont think that is the problem. The only problem is that its that the xp given to me is not correct. "2" should be X2 xp but its not doing that.
Copper is offline
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
Old 07-18-2016, 18:57
sirerick
This message has been deleted by sirerick. Reason: bugssy fix its
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode