Raised This Month: $ Target: $400
 0% 

set_task problems (I think)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 01-01-2007 , 23:00   set_task problems (I think)
Reply With Quote #1

I'm not sure if my set_tasks are the problem but I can't figure out what the actual problem is. When the server starts up, the cvar is defaultly set to 1 and when I change it to 0. It works but when I want to set it back to 1 again. Nothing works apparently.
PHP Code:
new zomb_lightning

public plugin_init() {
    
zomb_lightning register_cvar("zs_lightning","1")

    
set_task(1.0,"lightning_effects")
}

public 
lightning_effects() {
    if(
get_pcvar_num(zomb_lightning))
    {    
        
set_lights("a")
        
set_task(random_float(10.0,17.0),"thunder_clap",12175)
    }
    else if (!
get_pcvar_num(zomb_lightning))
    {
        
set_lights("b")
        
remove_task(12175)
    }
    return 
PLUGIN_HANDLED
}
    
public 
thunder_clap()
{
    
set_lights("s")
    
client_cmd(0,"speak ambience/thunder_clap.wav")
    
    
set_task(1.0,"lightning_effects",12175)

__________________
It's a mystery.
Mini_Midget is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-02-2007 , 00:04   Re: set_task problems (I think)
Reply With Quote #2

Are you saying if you turn it off and then on, nothing happens? It's probably because if lightning_effects is called when the cvar is 0, the function never gets called again to check if it is now 1.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 01-02-2007 , 00:07   Re: set_task problems (I think)
Reply With Quote #3

Quote:
Originally Posted by XxAvalanchexX View Post
Are you saying if you turn it off and then on, nothing happens? It's probably because if lightning_effects is called when the cvar is 0, the function never gets called again to check if it is now 1.
Yes thats true (bold words)

So what I should do exactly? Make another one of those if statements somewhere?
__________________
It's a mystery.
Mini_Midget is offline
allenwr
Veteran Member
Join Date: Jan 2006
Location: The place where the karm
Old 01-02-2007 , 01:26   Re: set_task problems (I think)
Reply With Quote #4

I dont mean to be dence, but what isnt working?
__________________
Don't ever place an order with Vee Servers. This is why.
allenwr is offline
Send a message via ICQ to allenwr Send a message via Yahoo to allenwr
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 01-02-2007 , 02:56   Re: set_task problems (I think)
Reply With Quote #5

Thanks
XxAvalanchexX

It works now
__________________
It's a mystery.
Mini_Midget is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-02-2007 , 01:30   Re: set_task problems (I think)
Reply With Quote #6

After remove_task, you could add this:
Code:
set_task(30.0,"lightning_effects")

Then, if it isn't on, it'll check every 30 seconds to see if it is back on. Use any value you want.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX 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 22:25.


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