AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   native error (native "remove_entity") (https://forums.alliedmods.net/showthread.php?t=319724)

Kristina 11-16-2019 15:24

native error (native "remove_entity")
 
native error (native "remove_entity")
L 11/16/2019 - 01:487: [AMXX] [0] Parachute.sma:: off_model (line 112)
L 11/16/2019 - 01:487: [AMXX] [1] Parachute.sma::client_PreThink (line 73)
L 11/16/2019 - 01:488: [ENGINE] Entity 0 can not be removed
L 11/16/2019 - 01:488: [AMXX] Displaying debug trace (plugin "Parachute.amxx", version "1.0")
Code:

#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <fun>

new PL[] = "[MG] Parachute"
new VE[] = "1.0"
new AU[] = "Remake Nikron"

#pragma tabsize 0
 
new g_bParashute[33];

new gTrail;
new para_ent[33]

public plugin_precache()
{
        precache_model("models/parachute.mdl")
}

public plugin_init()
{
                register_plugin(PL, VE, AU)
}
 
public client_connect(id)
{
        g_bParashute[id] = false;
        entity_set_float(id, EV_FL_gravity, 1.0);
}
 
public client_PreThink(id)
{
        if(!is_user_alive(id)) return;
        new Float:fallspeed = 100 * -1.0;
        if(g_bParashute[id] && get_entity_flags(id) & FL_ONGROUND)
        {
                entity_set_float(id, EV_FL_gravity, 1.0);
                g_bParashute[id] = false;
                return;
        }
 
        if(get_user_button(id) & IN_USE)
        {
                new Float:velocity[3];
                get_user_velocity(id, velocity);
 
                if(velocity[2] < 0.0)
                {
                        g_bParashute[id] = true;
                        entity_set_int(id, EV_INT_sequence, 3);
                        entity_set_int(id, EV_INT_gaitsequence, 1);
                        entity_set_float(id, EV_FL_frame, 1.0);
                        entity_set_float(id, EV_FL_framerate, 1.0);
                        entity_set_float(id, EV_FL_gravity, 0.1);
                        velocity[2] = (velocity[2] + 40.0 < fallspeed) ? velocity[2] + 40.0 : fallspeed;
                        set_user_velocity(id, velocity);
                                                modelsss(id)
                                                set_user_rendering(id,kRenderFxGlowShell,random_num(0,255),random_num(0,255),random_num(0,255),kRenderNormal,25)
                }
                else if(g_bParashute[id])
                {
                        entity_set_float(id, EV_FL_gravity, 1.0);
                        g_bParashute[id] = false;
                }
        }
        else if(get_user_oldbutton(id) & IN_USE)
        {
                entity_set_float(id, EV_FL_gravity, 1.0);
                g_bParashute[id] = false;
                                off_model(id)
        }
}

public Kill_Trail(id)
{
        message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
        write_byte(99); // TE_KILLBEAM
        write_short(id)
        message_end()
}

public modelsss(id)
{
        new Float:velocity[3]
        entity_get_vector(id, EV_VEC_velocity, velocity)

        if (velocity[2] < 0.0) {

                if(para_ent[id] <= 0) {
                        para_ent[id] = create_entity("info_target")
                        if(para_ent[id] > 0) {
                                entity_set_string(para_ent[id],EV_SZ_classname,"parachute")
                                entity_set_edict(para_ent[id], EV_ENT_aiment, id)
                                entity_set_edict(para_ent[id], EV_ENT_owner, id)
                                entity_set_int(para_ent[id], EV_INT_movetype, MOVETYPE_FOLLOW)
                                entity_set_model(para_ent[id], "models/parachute.mdl")
                                entity_set_int(para_ent[id], EV_INT_sequence, 0)
                                entity_set_int(para_ent[id], EV_INT_gaitsequence, 1)
                                entity_set_float(para_ent[id], EV_FL_frame, 0.0)
                                entity_set_float(para_ent[id], EV_FL_fuser1, 0.0)
                                set_rendering (para_ent[id],kRenderFxNone,255,255,255,kRenderNormal,25);
                                }
                        }
                }       
}

public off_model(id)
{
        remove_entity(para_ent[id])
        para_ent[id] = 0
        Kill_Trail(id)
        rendering_off(id)
}

public rendering_off(id)
{
        set_user_rendering(id, kRenderFxGlowShell,0,0,0,kRenderNormal,25)
}


OciXCrom 11-16-2019 15:56

Re: native error (native "remove_entity")
 
Check if the entity is valid before removing it.

Kristina 11-16-2019 16:17

Re: native error (native "remove_entity")
 
Quote:

Originally Posted by OciXCrom (Post 2673147)
Check if the entity is valid before removing it.

How do it?

OciXCrom 11-16-2019 16:43

Re: native error (native "remove_entity")
 
By checking "pev_valid()" before using "remove_entity()".

Fuck For Fun 11-17-2019 03:47

Re: native error (native "remove_entity")
 
Quote:

Originally Posted by Kristina (Post 2673150)
How do it?

Code:

    if( !pev_valid( id ) )
        return;


Xalus 11-17-2019 04:20

Re: native error (native "remove_entity")
 
Replace

PHP Code:

public off_model(id)
{
    if(
pev_valid(para_ent[id]))
    {
        
remove_entity(para_ent[id])
    }
    
para_ent[id] = 0
    Kill_Trail
(id)
    
rendering_off(id)



DJEarthQuake 11-17-2019 15:08

Re: native error (native "remove_entity")
 
1 Attachment(s)
There's a much larger issue. Only the backpack shows when parachute is enabled. I fixed it up. Thank you for starting this. I wanted a smaller parachute plugin. Parachuting glow I set it to only happen when low on HP. There was much strobe with other plugin I use. It was tested and made stable. Once bots entered game random crashes. That should be resolved now too.

Code:
    new Float:frame = entity_get_float(para_ent[id],EV_FL_fuser1) + 2.0     //Insert to fix no animation     if( (is_valid_ent(para_ent[id])) && (entity_get_int(para_ent[id],EV_INT_sequence) == 0) ){         frame = entity_get_float(para_ent[id],EV_FL_fuser1) + 1.0     entity_set_float(para_ent[id],EV_FL_fuser1,frame)     entity_set_float(para_ent[id],EV_FL_frame,frame)         if (frame > 100.0) {     entity_set_float(para_ent[id], EV_FL_animtime, 0.0)     entity_set_float(para_ent[id], EV_FL_framerate, 0.4)     entity_set_int(para_ent[id], EV_INT_sequence, 1)     entity_set_int(para_ent[id], EV_INT_gaitsequence, 1)     entity_set_float(para_ent[id], EV_FL_frame, 0.0)     entity_set_float(para_ent[id], EV_FL_fuser1, 0.0)     }     }     //End insert. Had backpack only. Working now.
Code:
    if(is_valid_ent(para_ent[id]) ){     remove_entity(para_ent[id])
Checksum dad0030778c2f12c1b527ebea7525158 Simple_parachute.sma


All times are GMT -4. The time now is 02:40.

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