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

Not sure what I did wrong


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Copper
Senior Member
Join Date: Feb 2012
Location: California
Old 07-13-2016 , 19:33   Not sure what I did wrong
Reply With Quote #1

Can anyone explain what I did wrong with this plugin? The time is not counted correctly nor it gives me the Double XP during those certain times.
Code:
#include <amxmodx>
#include <pokemod>

new pcvarstartHours, pcvarendHours
new bool:g_bActive

#define XP_MULT 2

public plugin_init()
{
	register_plugin("Time XP", "1.0", "Copper")
	
	register_event("DeathMsg", "DeathMsg", "a" )

	pcvarstartHours = register_cvar("pm_hhstart", "11")
	pcvarendHours = register_cvar("pm_hhend", "12")
	
	new h, m, s;
	time( h, m, s )
	
	if( get_pcvar_num( pcvarendHours ) > h >= get_pcvar_num( pcvarstartHours ) )
		g_bActive = true;
	
	set_task( 60.0, "CheckHappy", .flags="b" )
	
}

public DeathMsg()
{
	if( !g_bActive ) return;
	
	new attacker = read_data( 1 );
	new victim = read_data( 2 );	
	new xp = floatround( float( Poke_PlayerLevel( victim, -1 ) * XP_MULT ) )
	
	Poke_Set_PlayerXP( attacker, -1, Poke_PlayerXP( attacker, -1 ) + xp );
}

public CheckHappy()
{
	static h, m, s
	time( h, m, s )
	
	if( g_bActive && get_pcvar_num( pcvarendHours ) < h )
		EndHappy( )
		
	else if( !g_bActive && get_pcvar_num( pcvarendHours ) > h >= get_pcvar_num( pcvarstartHours ) )
	{
		g_bActive = true
		client_print( 0, print_chat, "Double Xp Event has started!" )
	}
}

public EndHappy()
{
	g_bActive = false
	client_print( 0, print_chat, "Double Xp Event is now over!" )
	return PLUGIN_HANDLED;
}


public client_putinserver(id)
	set_task(30.0, "message", id, _, _,_, 0)

public message(id)
{
    static h, m, s, timeleft
    time(h, m, s)
    
    timeleft = get_pcvar_num(pcvarstartHours) - h

    if ( timeleft <= 2 && !g_bActive )
	client_print(id, print_chat,"Double Xp Event will start in about %d hours.",  timeleft)

	else
	
	if ( g_bActive ) client_print(id, print_chat, "Double Xp Event has started!")

	
}

Last edited by Copper; 07-13-2016 at 19:34.
Copper is offline
sirerick
Senior Member
Join Date: Jul 2012
Location: Venezuela
Old 07-13-2016 , 19:53   Re: Not sure what I did wrong
Reply With Quote #2

HoraFeliz first time that i see this on english version. You put code inside of you xp mod. Sorry for the bad english.

edit: this code i use on all my mod and work fine.
PHP Code:
#include <amxmodx>
#include <hamsandwich>

new boolg_happytimecvar_hh_startcvar_hh_endg_exp[33]

public 
plugin_init() 
{
    
cvar_hh_start register_cvar("Happy Hour Start","11")
    
cvar_hh_end register_cvar("Happy Hour End","12")
    
register_event"HLTV","ev_RoundStart","a","1=0","2=0" )
    
RegisterHam(Ham_Killed"player""fw_playerkilled_post"1)
}

public 
ev_RoundStart( ) 

    static 
data];
    
get_time"%H"data);
    
    new 
Hour str_to_numdata );
    
    if (
get_pcvar_num(cvar_hh_end) > Hour >= get_pcvar_num(cvar_hh_start))
    {
        
g_happytime true;
        
client_print(0print_chat"You are on Happy Hour you will be gain doble EXP")
    }
}

public 
fw_playerkilled_post(victimattacker)
{
    if(!
is_user_connected(attacker))
        return 
HAM_IGNORED;
    
    if(
victim == attacker)
        return 
HAM_IGNORED;
        
    if(
g_happytime)
    {
        
g_exp[attacker]+= // example happyhour on x2 exp
    
}
    else
    {
        
g_exp[attacker]++ // example happyhour off
    
}
    return 
HAM_IGNORED;

__________________
√ 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.

Last edited by sirerick; 07-13-2016 at 20:33. Reason: code happy hour
sirerick is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-13-2016 , 20:09   Re: Not sure what I did wrong
Reply With Quote #3

The time is army time, so 8 pm=20. Did you take that into consideration?
__________________
Bugsy is offline
Copper
Senior Member
Join Date: Feb 2012
Location: California
Old 07-13-2016 , 20:18   Re: Not sure what I did wrong
Reply With Quote #4

Yea I know. These numbers are what I had in default.
Copper is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-13-2016 , 20:30   Re: Not sure what I did wrong
Reply With Quote #5

What do you mean that it is not counting time correctly? I recommend doing some debugging to confirm things are firing where they should be; put client_print() in various places to confirm code is getting reached\fired when it should. I quickly looked at the code and it appears that it is turning on and off when it should. I think your issue is here. I don't know enough about the mod to be sure though.
PHP Code:
new xp floatroundfloatPoke_PlayerLevelvictim, -) * XP_MULT ) )
Poke_Set_PlayerXPattacker, -1Poke_PlayerXPattacker, -) + xp ); 
Add this to prevent errors
PHP Code:
public client_disconnectid )
{
     
remove_taskid );

__________________

Last edited by Bugsy; 07-13-2016 at 20:31.
Bugsy is offline
Reply



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 08:50.


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