AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Setting/removing invisibility and godmode. Tasks. (https://forums.alliedmods.net/showthread.php?t=129641)

t3hNox 06-15-2010 05:30

Setting/removing invisibility and godmode. Tasks.
 
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,kRenderTransAlpha10);
        
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(idgodmode 0) {
    
set_pev(idpev_takedamagegodmode == 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.

NiHiLaNTh 06-15-2010 05:49

Re: Setting/removing invisibility and godmode. Tasks.
 
I think it should be like this:
Code:

public eDeath ( )
{
    new iVictim = read_data(2)

    removeGodmode ( iVictim )
    removeInvis ( iVictim )
}


t3hNox 06-15-2010 06:15

Re: Setting/removing invisibility and godmode. Tasks.
 
Thanks. This might be a part of the problem. I'll check to be sure.


All times are GMT -4. The time now is 14:45.

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