AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   set_task problems (I think) (https://forums.alliedmods.net/showthread.php?t=49333)

Mini_Midget 01-01-2007 23:00

set_task problems (I think)
 
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)



XxAvalanchexX 01-02-2007 00:04

Re: set_task problems (I think)
 
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.

Mini_Midget 01-02-2007 00:07

Re: set_task problems (I think)
 
Quote:

Originally Posted by XxAvalanchexX (Post 422628)
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?

allenwr 01-02-2007 01:26

Re: set_task problems (I think)
 
I dont mean to be dence, but what isnt working?

XxAvalanchexX 01-02-2007 01:30

Re: set_task problems (I think)
 
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.

Mini_Midget 01-02-2007 02:56

Re: set_task problems (I think)
 
Thanks
XxAvalanchexX

It works now


All times are GMT -4. The time now is 22:25.

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