View Single Post
  #4  
Old 08-13-2011, 09:31 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
Quote:
Originally Posted by Gunderak View Post
vHere is what have been able to come up with, but im still wondering, is there any way to check if the player is staff and if so make their name gold? iv managed to achieve this clientside but not serverside, meaning it only displays as gold to your self.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
onTimeOut();
}

function 
onTimeOut() {
  
hideimg(201 a);
  
hideimg(202 a);
  for (
0playerscounta++) {
    
showtext(201 aplayers[a].1.5players[a].3.2"Arial Bold""c", @players[a].nick);
    
changeimgcolors(201 a1111);
    
changeimgvis(201 a1);
    
changeimgzoom(201 a1);
    
showtext(202 aplayers[a].1.5players[a].4.5"Arial Bold""c", @players[a].hearts@"/"@players[a].maxhp);
    
changeimgcolors(202 a10.10.11);
    
changeimgvis(202 a1);
    
changeimgzoom(202 a0.8);
  }
  
setTimer(0.05);

There's a couple of things within this script which don't really make sense, and suggest that you are still piecing things together without really understanding how they work.

First of all you do not need to use "@" to use a single variable such as how you do with "@players[a].nick", this is the type of thing you'd want to do in order to create an object from a dynamic string value, for instance:

PHP Code:
function onPlayerChats(){
  
temp.tokens player.chat.tokenize();
  
//lets say the players chat was "/dofunction heal somenoob 2"
  
if(temp.tokens[0] == "/dofunction"){
    
//temp.tokens[1] would be the function name it invokes, temp.tokens[2] + [3] would be the parameters passed
    
this.(@ temp.tokens[1])(temp.tokens[2], temp.tokens[3]);
  }
}

function 
heal(temp.pltemp.amount){
  
//stuff that heals the player supplied by the first parameter by the amount supplied in the second parameter


The 2nd parameter also does not require the first "@", it can be "players[a].hearts @ "/" @ players[a].maxhp", for the sake of read-ability it would also be better to space those separate values out.

Something more important is that when using indexes of 201 + a, and 202 + 1 and incrementing a by 1, the 2nd part of the loop will be over-writing one of the displays from the first part of the loop and so on.
For this you should be incrementing a by 2, this would do 201 and 202 for the first part of the loop, then 203 and 204 for the second part.

Having said that, it would be much better to simply do:

PHP Code:
for(temp.pl players){
  
this.showtext(200 this.itemp.pl.xtemp.pl.ystuff);
  
this.++;
  
this.showtext(200 this.itemp.pl.xtemp.pl.ystuff);
  
this.++;

Your hideimg functions are only hiding the first 2 display objects and would be ignoring any players beyond yourself.
If you keep track of the amount of displays created, you can do something simple such as :

PHP Code:
this.hideimgs(200200 this.i); 
Even then looping through all players and creating a new display every frame is a very inefficient method which consumes script time, I personally think it's better to just stick to default nicks unless you're knowledgeable enough to create an efficient system, such as storing the display objects and then simply modifying them in future frames.

I'm not 100% sure but I think the playerscount variable is a now deprecated relic of old GS1, you may for example have to use temp.s = players.size(); and refer to temp.s within the loop.
Reply With Quote