Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Mouse over for names and info (https://forums.graalonline.com/forums/showthread.php?t=134264471)

Gunderak 09-04-2011 10:58 AM

Mouse over for names and info
 
It basically just shows their nick, account and if there staff their position :)
add accounts in this.staffposition for their names to have a rank.
PHP Code:

//#CLIENTSIDE
function onCreated() {
//This is a list of ranks, add graal accounts to it as you please.
  
this.lats = {
    
"Graal######"
  
};
  
this.admins = {
    
"Graal######"
  
};
  
this.nats = {
    
"Graal######"
  
};
  
this.gfx = {
    
"Graal######"
  
};
  
this.sfx = {
    
"Graal######"
  
};
  
this.eventsteam = {
    
"Graal######"
  
};
  
onTimeout();
}

function 
onTimeout() {
//Hides the info so that if your mouse isnt over players they wont show.
  
Player_Name.hide();
  
Player_Account.hide();
  
Admin_Ranks.hide();
  
LAT_Ranks.hide();
  
NAT_Ranks.hide();
  
GFX_Ranks.hide();
  
Events_Team_Ranks.hide();
  
SFX_Ranks.hide();
//Checks if your mouse is over a player.
  
for (temp.pl: findNearestPlayers(mousex, mousey)) {
    if (
mousex in | pl.x, pl.x + 2.5 | && mousey in | pl.y, pl.y + 3 | ) {
//Creates the gui's to show.
      
new GuiTextCtrl("Player_Name") {
        
profile = GuiBlueTextProfile;
        
height = 20;
        
text = "Name:       " @ temp.pl.nick;
        
width = 200;
        
x = mousescreenx + 15;
        
y = mousescreeny - 5;
        
red = 1;
        
green = 1;
        
blue = 1;
        
alpha = 1;
      }
      new 
GuiTextCtrl("Player_Account") {
        
profile = GuiBlueTextProfile;
        
height = 20;
        
text = "Account:   " @ temp.pl;
        
width = 200;
        
x = mousescreenx + 15;
        
y = mousescreeny + 10;
        
red = 1;
        
green = 1;
        
blue = 1;
        
alpha = 1;
      }
//Shows "Rank: Staffrank" if your account is listed above.
      
if (temp.pl.account in this.admins) {
        new 
GuiTextCtrl("Admin_Ranks") {
          
profile = GuiBlueTextProfile;
          
height = 20;
          
text = "Rank:         Admin";
          
width = 200;
          
x = mousescreenx + 15;
          
y = mousescreeny + 25;
          
red = 1;
          
green = 1;
          
blue = 1;
          
alpha = 1;
          
Admin_Ranks.show();
        }
      }
      if (
temp.pl.account in this.lats) {
        new 
GuiTextCtrl("LAT_Ranks") {
          
profile = GuiBlueTextProfile;
          
height = 20;
          
text = "Rank:        LAT";
          
width = 200;
          
x = mousescreenx + 15;
          
y = mousescreeny + 25;
          
red = 1;
          
green = 1;
          
blue = 1;
          
alpha = 1;
          
LAT_Ranks.show();
        }
      }
      if (
temp.pl.account in this.nats) {
        new 
GuiTextCtrl("NAT_Ranks") {
          
profile = GuiBlueTextProfile;
          
height = 20;
          
text = "Rank:        NAT";
          
width = 200;
          
x = mousescreenx + 15;
          
y = mousescreeny + 25;
          
red = 1;
          
green = 1;
          
blue = 1;
          
alpha = 1;
          
NAT_Ranks.show();
        }
      }
      if (
temp.pl.account in this.gfx) {
        new 
GuiTextCtrl("GFX_Ranks") {
          
profile = GuiBlueTextProfile;
          
height = 20;
          
text = "Rank:        GFX";
          
width = 200;
          
x = mousescreenx + 15;
          
y = mousescreeny + 25;
          
red = 1;
          
green = 1;
          
blue = 1;
          
alpha = 1;
          
GFX_Ranks.show();
        }
      }
      if (
temp.pl.account in this.sfx) {
        new 
GuiTextCtrl("SFX_Ranks") {
          
profile = GuiBlueTextProfile;
          
height = 20;
          
text = "Rank:        SFX";
          
width = 200;
          
x = mousescreenx + 15;
          
y = mousescreeny + 25;
          
red = 1;
          
green = 1;
          
blue = 1;
          
alpha = 1;
          
SFX_Ranks.show();
        }
      }
      if (
temp.pl.account in this.eventsteam) {
        new 
GuiTextCtrl("Events_Team_Ranks") {
          
profile = GuiBlueTextProfile;
          
height = 20;
          
text = "Rank:         Events Team";
          
width = 200;
          
x = mousescreenx + 15;
          
y = mousescreeny + 25;
          
red = 1;
          
green = 1;
          
blue = 1;
          
alpha = 1;
          
Events_Team_Ranks.show();
        }
      }
//Shows players name and account regardless of it there staff.
      
Player_Name.show();
      
Player_Account.show();
    }
  }
//Loops it so its checking constantly if your mouse is on a player.
  
settimer(0.05);
} 

Any feedback is appreciated :D

fowlplay4 09-04-2011 04:44 PM

Constantly re-creating the GUIs is not a good idea.

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
// list stuff
  
createGUIs();
}

function 
createGUIs() {
  
// create GUIs here
    // set visible to false in each GUI
}

function 
onTimeout() {
  
// make the GUI you need visible
  // set it's X and Y position
} 

You really only need one GUI object for Staff Rank and should just change the text based on what list they're in.

Gunderak 09-05-2011 01:05 AM

ah i see what your going at, only making them visible when needed.
so create them all in on created and then on a timeout choose weather to show them or not.


All times are GMT +2. The time now is 10:56 PM.

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