AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   weaponbox traceattack (https://forums.alliedmods.net/showthread.php?t=312996)

CrazY. 12-24-2018 08:41

weaponbox traceattack
 
Hello, I'm trying to hook TraceAttack of weaponbox entities, to be more specific, C4 backpack. I tried to work with its size, pev->takedamage and pev->solid, but it's not working.

Spoiler

Bugsy 12-24-2018 11:49

Re: weaponbox traceattack
 
I found it was not working only when I was spawned with the C4 (or I used the /C4 command), while if another player was spawned with it, the hook worked as expected. I attributed this to who may be set as the owner of the entity. To fix this, when the model is set, set pev_owner to 0 and now it works either way. There may be other ways to fix the issue, but this works.

Code:
public pfnSetModel_Post(this, const szModel[]) {     if (!FClassnameIs(this, "weaponbox"))         return;     new pitem = cs_get_weaponbox_item(this);     if (pitem == 0)         return;     if (get_ent_data(pitem, "CBasePlayerItem", "m_iId") != CSW_C4)         return;     set_pev(this, pev_solid, SOLID_BBOX);     set_pev(this, pev_takedamage, DAMAGE_AIM);         set_task( 0.1 , "DelaySetOwner" , this );         engfunc(EngFunc_SetSize, this, Float:{ -1.0, -1.0, -1.0 }, Float:{ 1.0, 1.0, 1.0 }); } public DelaySetOwner( this ) {     set_pev( this , pev_owner , 0 ); }

Natsheh 12-24-2018 14:35

Re: weaponbox traceattack
 
Here is the way you catch when you spawn with the bomb.
PHP Code:

register_logevent("fw_got_theBomb"3"2=Spawned_With_The_Bomb")

public 
fw_got_theBomb()
{
    new 
sName[32], sText[64]
    
read_logargv(0sTextcharsmax(sText))
    
parse_loguser(sTextsNamecharsmax(sName))
    
    new 
id get_user_index(sName)
    
        




All times are GMT -4. The time now is 07:31.

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