AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   set_task additional info (https://forums.alliedmods.net/showthread.php?t=157174)

DeLsTer 05-17-2011 12:13

set_task additional info
 
Hey guys i'm a noob in scripting and i need some help. Here's the part of a code:
Code:

public damage_event(id) {
                new arg[2]
                arg[0] = get_user_attacker(id)
                set_task(0.5, "loop_burn", id, arg[0], 0, "a", g_p_upg[attacker][UPG_FNADE] );
}

public loop_burn(id,arg[0]){
        if(!is_user_alive(id) || pev(id, pev_flags)&FL_INWATER)
                return;
       
        static Float:originF[3];
        pev(id, pev_origin, originF);
       
        new rnd = random_num(5, 10);
       
        engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0);
        write_byte(TE_SPRITE);
        engfunc(EngFunc_WriteCoord, originF[0]+random_float(-5.0, 5.0));
        engfunc(EngFunc_WriteCoord, originF[1]+random_float(-5.0, 5.0));
        engfunc(EngFunc_WriteCoord, originF[2]+random_float(-10.0, 10.0));
        write_short(g_flameSpr);
        write_byte(rnd);
        write_byte(200);
        message_end();
        new bool:death = (rnd>=float(get_user_health(id)))?true:false;
        if( death )
        {
        new get_user_msgid_DeathMsg;
        get_user_msgid_DeathMsg = get_user_msgid("DeathMsg");
        set_msg_block(get_user_msgid_DeathMsg, BLOCK_ONCE);
        user_kill(id);
        make_deathmsg(arg[0], id, 0, "grenade")
 
        }else{
        set_user_health(id, get_user_health(id) - rnd);       
       
        }
       
        }

Now i want to fully imitate a grenade death, but the problem is i can't seem to understand how to get the killer wich attacked. Using the method above gives me a client freeze upon death

fysiks 05-17-2011 19:59

Re: set_task additional info
 
Instead of setting health, killing, then making a death message, why not inflict damage with just Ham_TakeDamage. This way all the technical stuff is handled by the engine.


All times are GMT -4. The time now is 04:17.

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