Quote:
Originally Posted by olj
And I actually trust Exvel in whats he doing with this stock function. And i dont want to loop through incredible amount of entities on the map, especially if i want only 4 of them. Copy pasting is fine, you dont want to invent a wheel, because its already invented. You haven't provided any help, except for some mysterious "DONT USE HACKY FUNCTIONS", lol, i know what I'm doing usually. And If I dont, I browse scripting forums and development section to find answers and adjust code untill it works.
|
I never said anything was wrong with his functions. Although you are using his function for a purpose not intended - it's designed to find the first instance of a given entity starting from -1 for a single usage, not for a while loop that only breaks out when -1 is returned.
In short, his function works by rewinding back to -1 when it receives a higher than -1 number and whilst those numbers are valid entities, and FindEntityByClassname returns the entity index of the given class (or -1 if it doesn't find any). The point is, your loop only breaks out when it cannot find any more medkits, except, because the stock function 'rewinds' back to the start, it will always find medkits.
For example, if I have only three entities, 0 is the spawn point, 1 is a medkit that is nearby, and 2 is a medkit is far away, and it keeps restarting from 0 and removes 1 (but is still searching for valid medkits) and 2 is a valid medkit - it's going to keep returning 2 until 2 is removed, if you catch my drift.
I would take the liberty of testing that specific code, but I'm going to have to be content with people believing the mathematical distance to be at fault and wondering why the problem still exists even after reducing it (FYI 800 is a relatively 'small' distance, in ZPS 500 would heal zombies within a '4 man' radius).
I would have suspected distance but a lot of the finales in the standard campaigns are a good distance away.