This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Correct safety remove entity


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Arje
Senior Member
Join Date: Apr 2020
Location: Córdoba, Argentina
Old 10-02-2023 , 00:09   Correct safety remove entity
Reply With Quote #1

PHP Code:
new g_black_player[SH_MAXSLOTS+1];

new const 
gBlackHoleModel[] = "models/shmod/blackhole.mdl"

new const gBlackHole_EntName[] = "black_hole"
//------------------------------------------------------------------------------------------------
//                Black Create and Remove                        //
//------------------------------------------------------------------------------------------------
public black_create(id)    
{     
    new 
Float:vOrigin[3]
    
pev(idpev_originvOrigin);

    
//This will make it so that the disk appears in front of the user
    
new Float:viewing_angles[3]
    new 
distance_from_user 70
    pev
(idpev_anglesviewing_angles)
    
vOrigin[0] += floatcos(viewing_angles[1], degrees) * distance_from_user
    vOrigin
[1] += floatsin(viewing_angles[1], degrees) * distance_from_user
    vOrigin
[2] += floatsin(-viewing_angles[0], degrees) * distance_from_user
     
    
// This is for create the entity
    
new black_hole engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
    if (!
pev_valid(black_hole)) {
        
sh_chat_message(idgHeroID"Error al crear el agujero negro.");
        return;
    }
    
g_black_player[id] = black_hole;
    
    
//sets the classname of the entity
    
set_pev(black_holepev_classnamegBlackHole_EntName); 
    
    
//This tells what the object will look like
    
engfunc(EngFunc_SetModelblack_holegBlackHoleModel); 

    
//This will set the origin of the entity 
    
engfunc(EngFunc_SetOriginblack_holevOrigin); 
    
    
//This will get the velocity of the entity 
    
new Float:vAim[3]
    
velocity_by_aim(idrandom_num(24), vAim);
    
    
//Sets the size of the entity
    
new FloatminBound[3] = {-2.5, -2.5, -2.5};  //sets the minimum bound of entity
    
new FloatmaxBound[3] = {2.52.52.5};    //sets the maximum bound of entity
    
set_pev(black_holepev_minsminBound);
    
set_pev(black_holepev_maxsmaxBound);
    
    
//Sets who the owner of the entity is
    
set_pev(black_holepev_ownerid);
    
    
//This will set the movetype of the entity 
    
set_pev(black_holepev_movetypeMOVETYPE_FLY); 

    
//This makes the entity touchable
    
set_pev(black_holepev_solidSOLID_BBOX);
    
    
//Sets who the owner of the entity is
    
set_pev(black_holepev_ownerid);
    
    
//This is for a make safety remove ?
    // set_pev(ent, pev_nextthink, get_gametime() + 8.0)
}

public 
remove_all_bh(id)
{
    new 
ent 33;
    
    while((
ent find_ent_by_class(entgBlackHoleModel)) != 0) {
        if( 
entity_get_edict(entEV_ENT_owner) != id )
            continue;
            
        
set_pev(entpev_flagsFL_KILLME)
        
remove_entity(ent);
    }

This is the correct form to delete a entity ? i dont understand how to use this "set_pev(ent, pev_flags, FL_KILLME)" but i read its necessary for safety?

Last edited by Arje; 10-02-2023 at 09:04.
Arje is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:46.


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