View Full Version : How to Remove Entity by Classname
SamuraiBarbi
08-28-2007, 01:15
I'm trying to remove weapon_c4 and hostage_entity but SourceMod is still kinda new and no one has made a thread with useful info about removing ents by classname. How could I use SourceMod to remove them?
I am not complety sure, but I think it would go something like this:
stock RemoveByClassname(const String:classname[])
new String:name[32];
for(new i=0;i<= GetMaxEntities() ;i++){
if(!IsValidEntity(i))
continue;
if(GetEdictClassname(i, name, sizeof(name))){
if(StrEqual(classname, name,false))
RemoveEdict(i);
}
}
}
EDIT:
NVM, you can use:
new ent; ent = GetPlayerWeaponSlot(client, *Slot*)
RemovePlayerItem(client, ent);
You could try this too:
new ent = -1
while (ent = FindEntityByClassname(ent,"classname"))
{
if (IsValidEntity(ent))
{
RemoveEdict(ent)
}
}
No idea if it's any more efficient way of finding entities or not..
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.