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>
#include <engine>
#define SetAttachedEntity(%1,%2) (entity_set_int(%1, EV_INT_iuser1, %2))
new entNum = entity_count();
public getAttachedEntities(id) {
for (new i = get_maxplayers()+1; i < entNum; i++) {
if (!is_valid_ent(i))
continue;
if (entity_get_int(i, EV_ENT_aiment) == id && entity_get_int(i, EV_INT_movetype) == MOVETYPE_FOLLOW) {
SetAttachedEntity(i,id);
}
}
}
public resetAttachedEntities() {
for (new i = get_maxplayers()+1; i < entNum; i++) {
if (!is_valid_ent(i))
continue;
SetAttachedEntity(i,0);
}
}
__________________