Raised This Month: $ Target: $400
 0% 

Help for randomisation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MiniBrackeur
Senior Member
Join Date: Oct 2010
Old 04-10-2011 , 05:37   Help for randomisation
Reply With Quote #1

Hello, I need help for this plugin,
I would like to know how to make this plugin (below), an hour is chosen at random, rather than to be the same time every day. I would also like the happy hour occurs only once a day.

Here is the original code:
PHP Code:
/*

Happy Hour by fiendshard

CVARS: 
    zp_hhstart < number > - time when to start happy hour
    zp_hhend < number > - time when to end happy hour
    zp_hhx < number > - how many times to multiply happy hour rewards


*/
#include <amxmodx>

new cvar_start,cvar_endcvar_multizmhm

public plugin_init()
 {
    
register_plugin("[ZP] Addon: Happy Hour""0.1""fiendshard")
    
register_logevent("round_start"2"1=Round_Start")
    
register_logevent("round_end"2"1=Round_End")
    
    
zm get_cvar_num("zp_zombie_infect_reward")
    
hm get_cvar_num("zp_human_damage_reward")

    
cvar_start register_cvar("zp_hhstart""18")
    
cvar_end register_cvar("zp_hhend""24")
    
cvar_multi register_cvar("zp_hhx""2"
}

public 
round_start()
{
    new 
data[3]
    
get_time("%H"data2)
    if(
get_pcvar_num(cvar_end) > str_to_num(data) >= get_pcvar_num(cvar_start))
    {
        
set_cvar_num("zp_human_damage_reward"hm / (get_cvar_num("zp_hhx")))
        
set_cvar_num ("zp_zombie_infect_reward"zm* (get_cvar_num("zp_hhx")))
        
client_print(0print_chat"Happy Hour! Starts at: %d o'clock - Ends at: %d o'clock. It multiplies AP by %d"get_pcvar_num(cvar_start), get_pcvar_num(cvar_end), get_pcvar_num(cvar_multi))
    }    
}

public 
round_end() 
{
    
set_cvar_num("zp_human_damage_reward"hm )
    
set_cvar_num ("zp_zombie_infect_reward"zm)

here's the modified code:

PHP Code:
 #include <amxmodx>

new hh_min_hourhh_max_hourhh_multiplicatorzmhm

public plugin_init()
 {
    
register_plugin("[ZP] Addon: Happy hour""1.0""Anonyme")
    
register_logevent("round_start"2"1=Round_Start")
    
register_logevent("round_end"2"1=Round_End")
    
    
zm get_cvar_num("zp_zombie_infect_reward")
    
hm get_cvar_num("zp_human_damage_reward")

    
hh_min_hour register_cvar("zp_hh_min""1")
    
hh_max_hour register_cvar("zp_hh_max""23")
    
hh_multiplicator register_cvar("zp_hh_multiplicator""2"
}

public 
round_start()
{
    new 
data[3]
    
get_time("%H"data2)
    new 
random_hour random_num(get_pcvar_num(hh_min_hour) ,  get_pcvar_num(hh_max_hour))
    new 
random_hour_end get_pcvar_num(random_hour) + 1
    
if(get_pcvar_num(random_hour_end) > str_to_num(data) >= get_pcvar_num(random_hour))
    {
        
set_cvar_num("zp_human_damage_reward"hm / (get_cvar_num("zp_hh_multiplicator")))
        
set_cvar_num ("zp_zombie_infect_reward"zm* (get_cvar_num("zp_hh_multiplicator")))
        
client_print(0print_chat"Happy Hour ! It's: %d, en of happy hour: %d o clock. multiplicator: %d"get_pcvar_num(random_hour), get_pcvar_num(random_hour_end), get_pcvar_num(hh_multiplicator))
    }    
}

public 
round_end() 
{
    
set_cvar_num("zp_human_damage_reward"hm )
    
set_cvar_num ("zp_zombie_infect_reward"zm)

I have 3 questions:
1 - Is the Time "Happy Hour" will be 1 hour at random in the day?
2 - Does the happy hour will be a once a day?
3 - Does the plugin will work?

Last edited by MiniBrackeur; 04-10-2011 at 18:48. Reason: only english
MiniBrackeur is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-10-2011 , 06:03   Re: Help for randomisation
Reply With Quote #2

English only please.
Also it would be better to put english variables names, so the code will be easier to understand, and if you make mistake, variable names can help to indentify those mistakes.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
MiniBrackeur
Senior Member
Join Date: Oct 2010
Old 04-10-2011 , 18:49   Re: Help for randomisation
Reply With Quote #3

I put everything in English can you help me somebody?
MiniBrackeur is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-10-2011 , 19:07   Re: Help for randomisation
Reply With Quote #4

Dunno if the plugin gonna work, but from what i see, the only thing that is going to happen is that, each map, you gonna have random chances to enable happy hour.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
MiniBrackeur
Senior Member
Join Date: Oct 2010
Old 04-11-2011 , 10:19   Re: Help for randomisation
Reply With Quote #5

okok
MiniBrackeur 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 19:46.


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