Quote:
Originally Posted by Arje
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 ent, iThink; ent = MaxClients; iThink = 0; while( (ent = find_ent(ent, ent_type) ) > MaxClients && pev_valid(ent) ){
iThink = pev(ent, pev_nextthink); iThink ? remove_entity(ent) : set_pev(ent, pev_flags, FL_KILLME);
}