Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Help with name disaply (https://forums.graalonline.com/forums/showthread.php?t=134263962)

Arch_Angel 07-20-2011 08:32 PM

Help with name disaply
 
Okay, so I looked at a couple custom name/attribute displays to display what you want under players. Or make your own custom nick design.

But, problem is - When someone else logs in, it all goes haywire. By myself, it looks fine and such. Now I'm new to all this, so it is probably something stupid like "oh hey add this line here, done". So if someone could help me, would be much appreciated! (fowlplay, i know you're out there! )

So right now, I've just made it so it displays staff on tag, and players HP. It still needs the players nicks added to it with another line of showtext(blahblah, player[a].nick);. But, I wish to find out this problem of why its all going weird when another player logs in!

Help would be appreciated

PHP Code:

//#CLIENTSIDE
function onCreated( )
{
  
this.staff_list =
  {
    
"Manager", "Admin",
    
"Head Developer", "Developer",
    
"GAT", "LAT", "NAT", "GANI",
    
"Staff", "Working"
  
};
  
  
onTimeOut( );
}

function 
onTimeOut( )
{
  
player.attr[4] = clientr.hp@ "/" @clientr.hpmax;
  
  
hideimgs( 200 );
  for( 
a = 0; a < playerscount; a++ )
  {
    if ( 
players[a].guild in this.staff_list )
    {
      
showtext( 201 + a, players[a].x + 1.5, players[a].y + 3.0, "Arial Bold", "c", @players[a].nick );
      
changeimgcolors( 201 + a, 1, 1, 1, .7 );
      
changeimgvis( 201 + a, 1 );
      
changeimgzoom( 201 + a, .7 );
    }
    else {
      
//HP01
      
showtext( 202 + a, players[a].x - .325, player[a].y + 2.9, "Arial", "b", "HP:" SPC players[a].attr[4] );
      
changeimgcolors( 202, 0, 0, 0, .4 );
      
changeimgzoom( 202, 0.6 );
      
changeimgvis( 202, 1 );
      
//HP02
      
showtext( 203 + a, players[a].x - .2, player[a].y + 2.9, "Arial", "b", "HP:" SPC players[a].attr[4] );
      
changeimgcolors( 203, 1, .3, .3, .85 );
      
changeimgzoom( 203, 0.6 );
      
changeimgvis( 203, 1 );
    }
  }
  
  
setTimer( 0.05 );
} 


xAndrewx 07-20-2011 08:39 PM

PHP Code:

    else {
      
//HP01
      
showtext( 202 + a, players[a].x - .325, player[a].y + 2.9, "Arial", "b", "HP:" SPC players[a].attr[4] );
      
changeimgcolors( [B]202[/B], 0, 0, 0, .4 );
      
changeimgzoom( [B]202[/B], 0.6 );
      
changeimgvis( [B]202[/B], 1 );
      
//HP02
      
showtext( 203 + a, players[a].x - .2, player[a].y + 2.9, "Arial", "b", "HP:" SPC players[a].attr[4] );
      
changeimgcolors( [B]203[/B], 1, .3, .3, .85 );
      
changeimgzoom([B] 203[/B], 0.6 );
      
changeimgvis( [B]203[/B], 1 );
    } 

You are missing something in the bold area- [look for ''[B]'' stuff ]

Also only update the attr[4] when needed- (if the players health changes...)

fowlplay4 07-20-2011 08:42 PM

Let's see...

hideimgs usage:

hideimg(start_index, end_index); - Hides images with ID range specified. (Inclusive)

I.e:

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
showimg(200, "block.png", 30, 30);
  
showimg(201, "block.png", 30, 30);
  
showimg(202, "block.png", 30, 30);
  
showimg(203, "block.png", 30, 30);
  
hideimgs(200, 204); // Hides above blocks.
} 

You can just do:

hideimgs(200, 1000);

To hide all your images. The way your script is setup right now you're also drawing over existing image indexes. I.e:

a = 0
200 + a = 200
201 + a = 201

a = 1
200 + a = 201 (Overlapping here)
201 + a = 202


You can replace (GS1 Way):

PHP Code:

for( a = 0; a < playerscount; a++ ) { 
    if ( 
players[a].guild in this.staff_list ) { 

With (GS2/Object-oriented Way):

PHP Code:

temp.a = 0;
for (
temp.pl: players) {
  if (
temp.pl.guild in this.staff_list) {
    
  }
  
temp.a += 3;
} 


Arch_Angel 07-21-2011 06:25 AM

Quote:

Originally Posted by fowlplay4 (Post 1659585)
Let's see...

hideimgs usage:

hideimg(start_index, end_index); - Hides images with ID range specified. (Inclusive)

I.e:

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
showimg(200, "block.png", 30, 30);
  
showimg(201, "block.png", 30, 30);
  
showimg(202, "block.png", 30, 30);
  
showimg(203, "block.png", 30, 30);
  
hideimgs(200, 204); // Hides above blocks.
} 

You can just do:

hideimgs(200, 1000);

To hide all your images. The way your script is setup right now you're also drawing over existing image indexes. I.e:

a = 0
200 + a = 200
201 + a = 201

a = 1
200 + a = 201 (Overlapping here)
201 + a = 202


You can replace (GS1 Way):

PHP Code:

for( a = 0; a < playerscount; a++ ) { 
    if ( 
players[a].guild in this.staff_list ) { 

With (GS2/Object-oriented Way):

PHP Code:

temp.a = 0;
for (
temp.pl: players) {
  if (
temp.pl.guild in this.staff_list) {
    
  }
  
temp.a += 3;
} 


I wish I could rep+ you every day. Thanks, stay tuned for my next thread in a few days:cool:

And thank you Andrew as well, I appreciate your help.

Arch_Angel 07-21-2011 06:39 PM

I got it all working using the new for( );

What would I do if I want it to display other players' nicks as well. Right now it only shows their own clients nick and HP, not every bodies

fowlplay4 07-21-2011 07:01 PM

Quote:

Originally Posted by Arch_Angel (Post 1659686)
I got it all working using the new for( );

What would I do if I want it to display other players' nicks as well. Right now it only shows their own clients nick and HP, not every bodies

Your system is scripted to only show nicknames for people who are staff.


All times are GMT +2. The time now is 07:04 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.