Hi.
What I want to do is simply setting a player barely visibile or setting a godmode for a player and after some time remove it.
I've got some issue with the code and I think there is a better way how to do it.
PHP Code:
public plugin_init()
{
register_event("DeathMsg", "eDeath", "a")
}
//...
public setInvis(id) {
set_user_rendering(id,kRenderFxNone ,0,0,0,kRenderTransAlpha, 10);
set_task(10.0, "removeInvis", id);
}
public removeInvis(id) {
set_user_rendering(id,kRenderFxNone,255,255,255,kRenderNormal,16);
}
//Originally from amx_super, couldn't find any better solution..
stock fm_set_user_godmode(id, godmode = 0) {
set_pev(id, pev_takedamage, godmode == 1 ? DAMAGE_NO : DAMAGE_AIM)
return 1
}
public setGodmode(id) {
fm_set_user_godmode(id,1)
set_task(10.0, "removeGodmode", id);
}
public removeGodmode(id) {
fm_set_user_godmode(id,0)
}
public eDeath() {
//I'm aware that here should be some checking
remove_task(id) //The Idea is to remove all the tasks to make sure that there wouldn't be any unnecessary invisibility or godmode removing.
removeGodmode(id)
removeInvis(id)
}
The problem is that if I'm using this code the server is crashing. There is no info in logs. The full code completes fine so I guess I'm looking for a more sufficient way how to do these two things.
And another question is wether I am removing these tasks correctly because I have noticed that after player's death the task may be still active.