How to loop all entities?
There was an idea like : "loop all entities. if movetype is follow and aiment is your player, its attached!"
It's good an idea! But i don't know how to loop all entities :D And does it slow down the server ? |
Re: How to loop all entities?
It doesn't slow it that much but it would be faster to store attached entities on creation.... unless your plugin doesn't make them, in that case, this searches for entities near players:
Code:
new g_iMaxPlayers |
Re: How to loop all entities?
I think this might do the trick. I'm not sure if you create entities or not, so put the entNum before the loops or make it a global variable and initialize at plugin_init(). If you want to reset all entities on round change, I also provided that. I honestly don't think this will slow down the server to any noticeable extent. I mean, in my base builder mod, I reset all entities origin, angles, mins, maxs and owners every round end, and I don't really feel anything (and that's usually ~200 objects). But this will slow down your server, any loop this big would.
Code:
#include <amxmodx> |
Re: How to loop all entities?
entity_count() gives the number of entities in the server, not max entities.
Instead, you should use global_get(glb_maxEntities) and loop like you would for max players, except checking if entities are valid. |
Re: How to loop all entities?
Quote:
|
Re: How to loop all entities?
Quote:
Let's say you create 300 entities and delete the first 200. That leaves 100 entities with indexes 201-300. Therefore, the number of entities is less than the max entity index. |
Re: How to loop all entities?
Hunter-digital's code is working :D
Thanks. Now i can make a player completely invisible (admin mark,admin cloak are invisible now) |
Re: How to loop all entities?
Quote:
|
Re: How to loop all entities?
Quote:
|
Re: How to loop all entities?
Quote:
|
| All times are GMT -4. The time now is 01:11. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.