View Single Post
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 03-07-2018 , 09:22   Re: [L4D2] Remove survivor dead body
Reply With Quote #8

There are times when the entity is valid and invalid at the same time. This is due to said entity being in the process of removal.

Example: Deleting an entity that is about to be removed automatically from the map.
PHP Code:
int entity FindEntityByClassname(-1"survivor_death_model");
if (
entity != -1)
{
    
AcceptEntityInput(entity"Kill"); // In case this happens, the entity here is being removed twice which leads to a crash.
}

/* unless... */

int entity FindEntityByClassname(-1"survivor_death_model");
if (
entity != -1)
{
    if (!
IsValidEntity(entity)) // Here, we delay the process to actually confirm that the entity is still valid.
    
{
        return;
    }
    
    
AcceptEntityInput(entity"Kill"); // Plugin can safely delete the entity with no chances of the game/server crashing.


Last edited by cravenge; 03-07-2018 at 09:22.
cravenge is offline