Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   MouseOver? (https://forums.graalonline.com/forums/showthread.php?t=134256684)

Imperialistic 10-27-2009 05:05 AM

MouseOver?
 
Chris (aka cbk1994) helped me on a custom nickname script, I was just wondering how do I go about making it hide, untill a players mouse is over their character then it will show?

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
setTimer(0.05);
}

function 
onTimeout() {
  
hideimgs(2001000); // This will need to be re-optimized as hiding then redrawing every frame is bad 
  
drawNicknames();
  
setTimer(0.05);
  
enablefeatures(allfeatures 0x200);
}

function 
drawNicknames() {
  
// Loop through Players
  
for (temp.pplayers) {
    
// Draw Text under Player
    
with (findimg(200 temp.p.id 2)) {
      
text temp.p.nick;
      
temp.p.1.5;
      
temp.p.3.2;
      
style "bc";
      
font $pref::graal::defaultfontname;
      
      
red 0;
      
green 1;
      
blue 0;
      
layer 0;
    }
    
with (findimg(201 temp.p.id 2)) {
      
text "[" temp.p.account "]";
      
temp.p.1.5;
      
temp.p.4.5;
      
style "c";
      
font $pref::graal::defaultfontname;
      
      
zoom 0.7;
      
      
red 0;
      
green 1;
      
blue 0;
      
layer 0;
    }
  }



Tigairius 10-27-2009 05:13 AM

Add a parameter to drawNicknames which is the player object of the nickname you want to show, then inside of the timeout, test the players in the level and check if the mousex and y are in the player's x and y, if it is, then drawNicknames(pl). Then inside of drawNicknames(pl), inside of the for loop, add a check for the player object, like if (temp.p == pl).

Inside of drawNicknames you could be removing extra images that aren't used by adding
hideimg(200, 300); at the top of the function or so.

DustyPorViva 10-27-2009 05:26 AM

You don't even need a loop for that.

PHP Code:

temp.findnearestplayer(mousex,mousey);
if (
p.x in |mousex+.5,mousex+2.5| && p.y in |mousey+1,mousex+3|) {
  
with (findimg(200 temp.p.id 2)) {
    
text p.nick;
    
temp.p.1.5;
    
temp.p.3.2;
    
style "bc";
    
font $pref::graal::defaultfontname;
      
    
red 0;
    
green 1;
    
blue 0;
    
layer 0;
  } 
} else 
hideimg(200); 

This is theoretical, though... but I think it should work.

fowlplay4 10-27-2009 05:26 AM

I don't believe findnearestplayer works on the client-side.

temp.p refers to a player object so you can just use..

NPC Code:

for (temp.p: players) {
if (mousex in |temp.p.x, temp.p.x + 3| && mousey in |temp.p.y, temp.p.y + 3|) {
// do whatever
}
}



The in operator has a couple different uses:

NPC Code:

temp.array = {"a", "b", "oranges"};
if ("oranges" in temp.array) {
echo("You have oranges!"); // would output "You have oranges"
}



or it can be used as a shortcut instead of doing..

NPC Code:

temp.i = 2;
if (temp.i >= 1 && temp.i <= 3) {

}

// You can use instead:
if (temp.i in |1,3|) {
echo("rawr"); // would output "rawr"
}


DustyPorViva 10-27-2009 05:33 AM

It should, at least, it's listed.

Imperialistic 10-27-2009 05:35 AM

Quote:

Originally Posted by Tigairius (Post 1534378)
Add a parameter to drawNicknames which is the player object of the nickname you want to show, then inside of the timeout, test the players in the level and check if the mousex and y are in the player's x and y, if it is, then drawNicknames(pl). Then inside of drawNicknames(pl), inside of the for loop, add a check for the player object, like if (temp.p == pl).

Inside of drawNicknames you could be removing extra images that aren't used by adding
hideimg(200, 300); at the top of the function or so.

I feel terrible for saying this, but I didn't understand that.
I'm a freshman @ scripting.

cbk1994 10-27-2009 12:59 PM

See if you can figure it out from here:

PHP Code:

if (mousex in |pl.1pl.2| && mousey in |pl.1pl.2|) { // might have to play with these numbers until you get it right
  // show the nick


You'll have to add this in inside the 'for each' loop, and place your text showing script inside the condition.

Imperialistic 10-27-2009 05:21 PM

I tried rebuilding something better:
PHP Code:

//#CLIENTSIDE
function onCreated()
 {
 for (
jplayers) {
    if ( 
mousex in j.0.5j.2.5| && mousey in j.yj.3|) {
      
showText250j.1.5j.3.2"Comic Sans MS""cb"j.nick.substringNULLmin30j.nick.pos"("))));
      
changeImgVis2500);
      if ( 
j.guild != NULL) {
        
showText251j.1.3j.4.5"Comic Sans MS""cb""[ " j.guild " ]");
        
changeImgVis2510);
        if ( 
containsthis.staffGuildsj.guild)) changeImgColors251NULL1NULL1);
      }
    }
  }

  for ( 
jnpcs) {
    if ( 
mousex in j.0.5j.2.5| && mousey in j.yj.3|) {
      
showText250j.1.5j.3.2"Comic Sans MS""cb"j.nick.substringNULLmin30j.nick.pos"("))));
      
changeImgVis2500);
      if ( 
j.guild != NULL) {
        
showText251j.1.3j.4.5"Comic Sans MS""cb""[ " j.guild " ]");
        
changeImgVis2510);
        if ( 
containsthis.staffGuildsj.guild)) changeImgColors251NULL1NULL1);
      }
    }
  }



fowlplay4 10-27-2009 06:16 PM

Your issue with that is, that it will run once (when you login or update the script) and won't work after, you need to have a loop like so:

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
setTimer(0.05);
}

function 
onTimeout() {
  
// do stuff
  // continue looping
  
setTimer(0.05);



DustyPorViva 10-27-2009 06:16 PM

So ya, this works perfectly fine...
PHP Code:

  temp.findnearestplayer(mousex,mousey);
  if (
mousex in |p.x,p.x+2.5| && mousey in |p.y+.5,p.y+3|) {
    
with (findimg(200)) {
      
text p.nick;
      
p.1.5;
      
p.3.2;
      
style "bc";
      
font $pref::graal::defaultfontname;
      
      
red 0;
      
green 1;
      
blue 0;
      
layer 0;
    } 
  } else 
hideimg(200); 



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

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