Quote:
Originally Posted by olj
Ok, this code deletes medkits on every round start around first found survivor in 800 radius.
|
You could run at the very least a standard debugging approach by printing out the two vectors and the given distance to figure out why.
Your uh, entity code is what I'd call 'highly bastardised' (incredibly confusing - the more so, the more likely there are to be bugs in it).
Just to pick out some peices...
Code:
new ent = -1;
while ((ent = FindEntityByClassname2(ent, "weapon_first_aid_kit_spawn")) != -1)
Code:
stock FindEntityByClassname2(startEnt, const String:classname[])
{
/* If startEnt isn't valid shifting it back to the nearest valid one */
while (startEnt > -1 && !IsValidEntity(startEnt)) startEnt--;
return FindEntityByClassname(startEnt, classname);
}
Bastardised parts highlighted. You're starting from -1, with a loop that breaks out on -1 (with a deincrementation operation), and returns ??? because FindEntity is given -1;
A better question is why is your code even able to remove medkits?
Edit: I presume FindEntity starts from -1, counts up, returns the first entity, the loop deincrements it back down, and because FindEntity only returns -1 when it -cannot find any more medkits- it gets trapped in an infinite loop until every single one is removed (which, when the player arrives at the finale spot, gets removed because the operation is still continuously operating - because there are still kits out there).
In short; Assumption and Presumption fail.
Quote:
Originally Posted by SourceMod Documentation
Return:
Entity index >= 0 if found, -1 otherwise.
|