What I tend to do with this type of thing (Classic nicks/ratings/hp/map display etc) is store each display object as a dynamically named variable according to the players account, store each account to an array on the display being created, add each player to a hash each frame while updating the coordinates of the already existing display objects, then simply loop through the array of stored accounts and remove the display objects for where the hash of the account isn't true.
Basic example:
PHP Code:
//#CLIENTSIDE
function onCreated(){
this.display = new TStaticVar();
this.onTimeout();
}
function onTimeout(){
if(this.disabled){
if(this.storedaccounts != NULL){
this.hideimgs(200, 200 + this.displayindex);
this.displayindex = 0;
this.display.clearVars();
this.storedaccounts = NULL;
}
this.setTimer(0.05);
return;
}
temp.hash = new TStaticVar();
for(temp.pl : players){
temp.hash.(@ temp.pl.account) = true;
if(this.display.(@ temp.pl.account) == NULL){
this.displayedaccounts.add(temp.pl.account);
this.display.(@ temp.pl.account) = this.showimg(200 + this.displayindex, "light2.png", temp.pl.x - 2.5, temp.pl.y - 2);
this.changeimgvis(200 + this.displayindex, 0);
this.changeimgcolors(200 + this.displayindex, 1, 8, 8, .8);
this.displayindex ++;
}
else{
this.display.(@ temp.pl.account).x = temp.pl.x - 2.5;
this.display.(@ temp.pl.account).y = temp.pl.y - 2;
}
}
//could also use this.display.getdynamicvarnames to accomplish the same thing, but while easier it's slower
for(temp.a : this.displayedaccounts){
if(!temp.hash.(@ temp.a)){
this.hideimg(this.display.(@ temp.a).imageindex);
this.displayedaccounts.delete(temp.i);
}
else{
temp.i ++;
}
}
this.setTimer(0.05);
}
When it comes to things like nicknames instead of storing the singular display object I store an array such as {player.nick, player.ap, player.ispaused, displayobject} then use this to check for a change in order to update text or colour.
I suppose in the instance of a light effect this method would be more consuming than a gani attr, but it does provide you with a few advantages.
This prevents the problem of the light being affected by something such as player zoom/red/green/blue/alpha/rotation, it also allows you to easily disable it on your own client.