Raised This Month: $ Target: $400
 0% 

Correct safety remove entity


Post New Thread Reply   
 
Thread Tools Display Modes
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 10-15-2023 , 12:59   Re: Correct safety remove entity
Reply With Quote #21

"DLLFunc_Think" I guess it's unnecessary if the entity has been deleted before
__________________
mlibre is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 10-15-2023 , 19:38   Re: Correct safety remove entity
Reply With Quote #22

Quote:
Originally Posted by Arje View Post
Thanks lexzor and Natsheh for the help, both codes worked, although I stick with what you said that it is the best way to eliminate entities so I will use it,

On the other hand, I have a question regarding eliminating by owner, that is, it will only eliminate the entities that were created by that owner, or it will eliminate all entities independently of the owner, that is, I do not have to create a array for each entity created to correspond to each player,and then eliminate the entities that player is the owner?
Speaking of arrays. MAX_PLAYERS is for arrays. Use MaxClients. Owner code thwarts remove all. Stopping to check if ent is valid instead is safer than checking owner.
Making sure ent is not the BSP, in other words 0, or a client, whatever 1 through MaxClients is the goal.

Use FL_KILLME flag on thinking classes like weaponbox. All others appear safe to use remove_entity.
Script below attempts to help. Tested on weaponboxes.

Even brush flagged as FL_ALWAYSTHINK like from AMX Portal (c) Copyright 2005, from KleeneX uses remove_entity.

Amx_parachute has a think and remove_entity(para_ent[id]) is used safely because the original class
also started as info_target. Unless your blackhole is a weaponbox use remove_entity.

PHP Code:
static entiThinkent MaxClientsiThink 0; while( (ent find_ent(entent_type) ) > MaxClients && pev_valid(ent) ){
    
iThink pev(entpev_nextthink); iThink remove_entity(ent) : set_pev(entpev_flagsFL_KILLME);


Last edited by DJEarthQuake; 10-22-2023 at 09:51.
DJEarthQuake is offline
Reply



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 01:48.


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