diff --git a/modules/engine/entity.cpp b/modules/engine/entity.cpp index 48e5e642..2d572505 100644 --- a/modules/engine/entity.cpp +++ b/modules/engine/entity.cpp @@ -120,11 +120,17 @@ static cell AMX_NATIVE_CALL create_entity(AMX *amx, cell *params) static cell AMX_NATIVE_CALL remove_entity(AMX *amx, cell *params) { int id = params[1]; + if (id >= 0 && id <= gpGlobals->maxClients) + { + MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d can not be removed", id); + return 0; + } + edict_t *pEnt = INDEXENT2(id); if (FNullEnt(pEnt)) return 0; - + REMOVE_ENTITY(pEnt); return 1; diff --git a/plugins/include/engine.inc b/plugins/include/engine.inc index e355dcd4..09e2f427 100755 --- a/plugins/include/engine.inc +++ b/plugins/include/engine.inc @@ -621,6 +621,8 @@ native create_entity(const szClassname[]); * * @return 1 if entity was sucessfully removed, 0 if an invalid entity * was provided + * @error If an entity index in the range of 0 to MaxClients is + * provided, an error will be thrown. */ native remove_entity(iIndex);