Thread: Glow effect
View Single Post
  #8  
Old 07-09-2011, 01:28 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
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(200200 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.2.5temp.pl.2);
      
this.changeimgvis(200 this.displayindex0); 
      
this.changeimgcolors(200 this.displayindex188.8);
      
this.displayindex ++;
    }
    else{
      
this.display.(@ temp.pl.account).temp.pl.2.5;
      
this.display.(@ temp.pl.account).temp.pl.2;
    }
  }

  
//could also use this.display.getdynamicvarnames to accomplish the same thing, but while easier it's slower
  
for(temp.this.displayedaccounts){
    if(!
temp.hash.(@ temp.a)){
      
this.hideimg(this.display.(@ temp.a).imageindex);
      
this.displayedaccounts.delete(temp.i);
    }
    else{
      
temp.++;
    }
  }

  
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.

Last edited by ffcmike; 07-09-2011 at 10:37 PM..
Reply With Quote