AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [FAKEMETA] Invalid entity set_pev (https://forums.alliedmods.net/showthread.php?t=324079)

Fuck For Fun 05-05-2020 18:33

[FAKEMETA] Invalid entity set_pev
 
I create a C4 game that can be seen and hovered in the air at UNITS distance, but while being shot or touched it disappears
Code:

L 05/06/2020 - 00:03:43: [FAKEMETA] Invalid entity
L 05/06/2020 - 00:03:43: [AMXX] Displaying debug trace (plugin "take_away_bomb.amxx", version "1.0")
L 05/06/2020 - 00:03:43: [AMXX] Run time error 10: native error (native "set_pev")
L 05/06/2020 - 00:03:43: [AMXX]    [0] take_away_bomb.sma::HandleUpdateOwnerTask (line 294)

Question * If anyone can add me as I shoot it, it will fly in the FLOAT air?
Code:

public pfnSetModel_Post(this, const szModel[])
{
        if (!g_bTakeAwayBomb)
                return;

        if (!FClassnameIs(this, "weaponbox"))
                return;

        new pItem = GetWeaponBoxItem(this);

        if (pItem == -1)
                return;

        if (cs_get_weapon_id(pItem) != CSW_C4)
                return;

        new iColor[3], pOwner;

        pOwner = pev(this, pev_owner);

        if (pOwner != g_pGuard && pOwner != g_pPrisoner)
                return;

        engfunc(EngFunc_SetSize, this, Float:{ -5.22, -2.94, 0.0 }, Float:{ 5.22, 2.94, 6.85 });
       
        set_pev(this, pev_takedamage, DAMAGE_YES);
        set_pev(this, pev_solid, SOLID_BBOX);
        set_pev(this, pev_iuser4, pOwner);

        switch (get_user_team(pOwner))
        {
                case 1:
                        iColor = { 200, 0, 0 };

                case 2:
                        iColor = { 0, 0, 200 };
        }

        set_rendering(this, kRenderFxGlowShell, iColor[0], iColor[1], iColor[2], kRenderNormal, 25);

        set_task(0.1, "HandleUpdateOwnerTask", this);
}

public HandleUpdateOwnerTask(this) // error here
{
        set_pev(this, pev_owner, 0);
}


Natsheh 05-05-2020 22:29

Re: [FAKEMETA] Invalid entity set_pev
 
Basically the entity is getting killed give it godmode and increase its health

Fuck For Fun 05-05-2020 22:52

Re: [FAKEMETA] Invalid entity set_pev
 
Quote:

Originally Posted by Natsheh (Post 2698428)
Basically the entity is getting killed give it godmode and increase its health

something like that? no take damage of ent
Code:

set_pev(this, pev_owner, pev_takedamage, 0.0);

Smilex_Gamer 05-06-2020 05:09

Re: [FAKEMETA] Invalid entity set_pev
 
Quote:

Originally Posted by Fuck For Fun (Post 2698430)
something like that? no take damage of ent
Code:

set_pev(this, pev_owner, pev_takedamage, 0.0);

I think this is how you set it to take no damage:

Code:

set_pev(this, pev_takedamage, DAMAGE_NO);
Check if the entity is invalid:

Code:

public HandleUpdateOwnerTask(this)
{
        if(!pev_valid(this)) return FMRES_IGNORED;

        set_pev(this, pev_owner, 0);
}


Fuck For Fun 05-06-2020 05:23

Re: [FAKEMETA] Invalid entity set_pev
 
@Smilex_Gamer
Quote:

L 05/06/2020 - 12:27:23: [FAKEMETA] Invalid entity
L 05/06/2020 - 12:27:23: [AMXX] Displaying debug trace (plugin "jb_lr_take_away_bomb.amxx", version "1.0")
L 05/06/2020 - 12:27:23: [AMXX] Run time error 10: native error (native "set_pev")
L 05/06/2020 - 12:27:23: [AMXX] [0] jb_lr_take_away_bomb.sma::HandleUpdateOwnerTa sk (line 294)
Code:

public HandleUpdateOwnerTask(this)
{
        if(!pev_valid(this)) return FMRES_IGNORED; // error
        //set_pev(this, pev_owner, 0);
        set_pev(this, pev_takedamage, DAMAGE_NO);
       
        return HAM_IGNORED;
}


Smilex_Gamer 05-06-2020 05:35

Re: [FAKEMETA] Invalid entity set_pev
 
Quote:

Originally Posted by Fuck For Fun (Post 2698452)
@Smilex_Gamer

Code:

public HandleUpdateOwnerTask(this)
{
        if(!pev_valid(this)) return FMRES_IGNORED; // error
        //set_pev(this, pev_owner, 0);
        set_pev(this, pev_takedamage, DAMAGE_NO);
       
        return HAM_IGNORED;
}


I was saying to set it to take no damage inside the function "pfnSetModel_Post".
Also, why are you returning "HAM_IGNORED" when we aren't using hamsandwich?

Fuck For Fun 05-06-2020 05:51

Re: [FAKEMETA] Invalid entity set_pev
 
Quote:

Originally Posted by Smilex_Gamer (Post 2698455)
I was saying to set it to take no damage inside the function "pfnSetModel_Post".
Also, why are you returning "HAM_IGNORED" when we aren't using hamsandwich?

I probably forgot to put what I did.
So within "pfnSetModel_Post"


You want me to undo and change DAMAGE YES.
PHP Code:

set_pev(thispev_takedamageDAMAGE_YES); 

->
PHP Code:

set_pev(thispev_takedamageDAMAGE_NO); 


Smilex_Gamer 05-06-2020 06:17

Re: [FAKEMETA] Invalid entity set_pev
 
Quote:

Originally Posted by Fuck For Fun (Post 2698456)
I probably forgot to put what I did.
So within "pfnSetModel_Post"


You want me to undo and change DAMAGE YES.
PHP Code:

set_pev(thispev_takedamageDAMAGE_YES); 

->
PHP Code:

set_pev(thispev_takedamageDAMAGE_NO); 


Yes, within "pfnSetModel_Post" change that and within "HandleUpdateOwnerTask" you need to add that little piece of code before anything in order to check if the entity is valid, preventing errors from appearing when it uses an invalid entity.

P.S: That piece of code I'm talking about is this one:
Code:

if(!pev_valid(this)) return FMRES_IGNORED;

Fuck For Fun 05-06-2020 06:24

Re: [FAKEMETA] Invalid entity set_pev
 
Quote:

Originally Posted by Smilex_Gamer (Post 2698458)
Yes, within "pfnSetModel_Post" change that and within "HandleUpdateOwnerTask" you need to add that little piece of code before anything in order to check if the entity is valid, preventing errors from appearing when it uses an invalid entity.

P.S: That piece of code I'm talking about is this one:
Code:

if(!pev_valid(this)) return FMRES_IGNORED;

Got it.
HTML Code:

public pfnSetModel_Post(this, const szModel[])
{
        if (!g_bTakeAwayBomb)
                return;

        if (!FClassnameIs(this, "weaponbox"))
                return;

        new pItem = GetWeaponBoxItem(this);

        if (pItem == -1)
                return;

        if (cs_get_weapon_id(pItem) != CSW_C4)
                return;

        new iColor[3], pOwner;

        pOwner = pev(this, pev_owner);

        if (pOwner != g_pGuard && pOwner != g_pPrisoner)
                return;

        engfunc(EngFunc_SetSize, this, Float:{ -5.22, -2.94, 0.0 }, Float:{ 5.22, 2.94, 6.85 });
       
        //set_pev(this, pev_takedamage, DAMAGE_YES);
        set_pev(this, pev_takedamage, DAMAGE_NO);
        set_pev(this, pev_solid, SOLID_BBOX);
        set_pev(this, pev_iuser4, pOwner);
       

        switch (get_user_team(pOwner))
        {
                case 1:
                        iColor = { 200, 0, 0 };

                case 2:
                        iColor = { 0, 0, 200 };
        }

        set_rendering(this, kRenderFxGlowShell, iColor[0], iColor[1], iColor[2], kRenderNormal, 25);

        set_task(0.1, "HandleUpdateOwnerTask", this);
}

public HandleUpdateOwnerTask(this)
{
        if(!pev_valid(this)) return FMRES_IGNORED;
        set_pev(this, pev_owner, 0);
}

EDIT: Thanks you, finally It doesn't go away that it touches the wall or I'm standing on it

DJEarthQuake 05-08-2020 11:17

Re: [FAKEMETA] Invalid entity set_pev
 
Quote:

Originally Posted by Fuck For Fun (Post 2698402)
Question * If anyone can add me as I shoot it, it will fly in the FLOAT air?

Do you still need the fly float in the air when attacked?


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

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