I'm trying to elminate the need for set_tasks in my mod and read
http://forums.alliedmods.net/showthread.php?t=43049
And now I ended up with this in my mod.
PHP Code:
plugin_init()
{
//...
new iEnt = fm_create_entity("info_target")
if (iEnt)
{
set_pev(iEnt, pev_classname, "zswarm_lights")
fm_DispatchSpawn(iEnt)
set_pev(iEnt, pev_nextthink, 2.0)
register_forward(FM_Think, "lightning_effects")
}
}
public lightning_effects(iEnt)
{
if(!get_pcvar_num(zomb_switch))
return set_pev(iEnt, pev_nextthink, 10.0)
if (get_pcvar_num(zomb_lightning) == 0)
{
engfunc(EngFunc_LightStyle, 0, "m")
remove_task(12175)
set_pev(iEnt, pev_nextthink, 10.0)
}
else if (get_pcvar_num(zomb_lightning) == 1)
{
engfunc(EngFunc_LightStyle, 0, "a")
set_task(random_float(10.0,17.0),"thunder_clap",12175)
}
else if (get_pcvar_num(zomb_lightning) == 2)
{
engfunc(EngFunc_LightStyle, 0, "b")
remove_task(12175)
set_pev(iEnt, pev_nextthink, 10.0)
}
return FMRES_IGNORED
}
public thunder_clap()
{
if(!get_pcvar_num(zomb_switch))
return
engfunc(EngFunc_LightStyle, 0, "p")
client_cmd(0,"speak %s", ZOMBIE_THUNDER)
//set_task(1.25, "lightning_effects", 12175)
}
Compiles with no errors and works ingame.
But the problem is that it changes the lights too fast and spams the wave file and just overloads the server.
__________________