Quote:
Originally Posted by Gunderak
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 (a = 0; a < playerscount; a++) {
showtext(201 + a, players[a].x + 1.5, players[a].y + 3.2, "Arial Bold", "c", @players[a].nick);
changeimgcolors(201 + a, 1, 1, 1, 1);
changeimgvis(201 + a, 1);
changeimgzoom(201 + a, 1);
showtext(202 + a, players[a].x + 1.5, players[a].y + 4.5, "Arial Bold", "c", @players[a].hearts@"/"@players[a].maxhp);
changeimgcolors(202 + a, 1, 0.1, 0.1, 1);
changeimgvis(202 + a, 1);
changeimgzoom(202 + a, 0.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.pl, temp.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.i, temp.pl.x, temp.pl.y, stuff);
this.i ++;
this.showtext(200 + this.i, temp.pl.x, temp.pl.y, stuff);
this.i ++;
}
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(200, 200 + 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.