I want to destroy all sentries owned/built by a client when they die, but it only works the first time you die. The other times you die, your sentries won't get destroyed. Any ideas?
PHP Code:
void ClearSentries(int client)
{
int maxentities = GetMaxEntities();
for (int i = MAXPLAYERS+1; i <= maxentities; i++)
{
if(IsValidEntity(i))
{
char iObject[128];
GetEntityNetClass(i, iObject, sizeof(iObject));
if(strcmp(iObject, "CObjectSentrygun") == 0)
{
if(GetEntDataEnt2(i, FindSendPropInfo("CObjectSentrygun", "m_hBuilder")) == client)
{
SetVariantInt(9999);
AcceptEntityInput(i, "RemoveHealth");
}
}
}
}
}