Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-27-2009, 05:05 AM
Imperialistic Imperialistic is offline
graal player lord
Imperialistic's Avatar
Join Date: Apr 2007
Location: Florida
Posts: 1,094
Imperialistic is a jewel in the roughImperialistic is a jewel in the rough
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;
    }
  }

__________________
" It's been swell, but the swelling's gone down. "
Reply With Quote
  #2  
Old 10-27-2009, 05:13 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
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.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #3  
Old 10-27-2009, 05:35 AM
Imperialistic Imperialistic is offline
graal player lord
Imperialistic's Avatar
Join Date: Apr 2007
Location: Florida
Posts: 1,094
Imperialistic is a jewel in the roughImperialistic is a jewel in the rough
Quote:
Originally Posted by Tigairius View Post
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.
__________________
" It's been swell, but the swelling's gone down. "
Reply With Quote
  #4  
Old 10-27-2009, 05:26 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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.
Reply With Quote
  #5  
Old 10-27-2009, 05:26 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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"
}

__________________
Quote:
Reply With Quote
  #6  
Old 10-27-2009, 05:33 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
It should, at least, it's listed.
Reply With Quote
  #7  
Old 10-27-2009, 12:59 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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.
__________________
Reply With Quote
  #8  
Old 10-27-2009, 05:21 PM
Imperialistic Imperialistic is offline
graal player lord
Imperialistic's Avatar
Join Date: Apr 2007
Location: Florida
Posts: 1,094
Imperialistic is a jewel in the roughImperialistic is a jewel in the rough
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);
      }
    }
  }

__________________
" It's been swell, but the swelling's gone down. "
Reply With Quote
  #9  
Old 10-27-2009, 06:16 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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);

__________________
Quote:
Reply With Quote
  #10  
Old 10-27-2009, 06:16 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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); 
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:11 PM.


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