Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-23-2010, 11:03 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Showing clientside stuff

Have also been trying to show certain things when you hover over players.

i have a script that does something like
PHP Code:
for(i=0i<playerscounti++) { 
then trying to use showtext and pull up
PHP Code:
players[i].clientr.guild 
but it wont, only shows my own character. Any suggestions on how to make this work so everyone can see everyones clientr.guild come up?
I've tried
PHP Code:
findplayerbyid(players[i]).clientr.guild 
but it doesnt work.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #2  
Old 05-23-2010, 11:07 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
You can't view other players flags clientside, you're best option is to save the var as an attr (player.attr[#]) which can be read from other players clients
__________________
Reply With Quote
  #3  
Old 05-24-2010, 02:10 AM
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
(sorry for the slow reply)

The problem with what you want to do is that there's no way to access another player's client or clientr variables from clientside. The reason for this is because it would require far too much bandwidth to transfer all of this data every time a player logs on or enters a new level.

However, you can place certain values in something called the "attr" array. Values in the "attr" array can be accessed by another player as long as they are in the same level.

In order to place clientr.guild in one of the player's attrs, you would need to update it each time the player's "clientr.guild" flag changes.

PHP Code:
player.attr[10] = player.clientr.guild
It's also a good idea to set this on login in case the player's guild changed while offline (e.g. a staff edited the attributes).

Then, when you want to access another player's guild, you can use a script like

PHP Code:
//#CLIENTSIDE
function onCreated() {
  for (
temp.pl players) { // this lets you loop through each player in your current level
    
if (pl.attr[10] != null) { // if the player has a guild
      
echo(pl.communityname " is in the guild " pl.attr[10]); // output it to F2
    
}
  }


Also, instead of using players[i].value, you can use a "for each" loop.

Quote:
Originally Posted by cbk1994 View Post
Another, different type of for loop is like a foreach loop in other languages. It's done like this:

PHP Code:
for (variable : array) {
  echo(
variable);

Arrays are defined like this

PHP Code:
temp.array = {"one""two""three""hello""world"}; 
which means you can also do

PHP Code:
for (variable : {"one""two""three""hello""world"}) {
  echo(
variable);

however, you need to specify a variable

PHP Code:
for (temp.number : array) {
  echo(
number);

would output

Quote:
one
two
three
hello
world
Be sure not to get the two types of for loops mixed up. The for each loop does the same thing as

PHP Code:
temp.array = {"one""two""three""hello""world"};

for (
temp.0< array.size(); ++) {
  
temp.variable = array[i];

The way this works is like this:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
this.trigger("timeOut"null); // start the timeout loop
}

function 
onTimeOut() {
  
temp.didShow false;
  
  for (
temp.pl players) {
    if (
pl == player) {
      continue; 
// if it's yourself, skip it
    
}
    
    if (
mousex in |pl.xpl.2| && mousey in |pl.ypl.2|) { // the coordinates probably need to be improved
      
with (findimg(200)) {
        if (
pl.attr[10] != null) { // are they in a guild?
          
text "Guild: " pl.attr[10]; // if in a guild
        
} else {
          
text "Guild: (not in a guild)"// if not in a guild
        
}
        
        
mousex 2;
        
mousey;
      }
      
      
didShow true;
      break; 
// end the loop
    
}
  }
  
  if (! 
didShow) {
    
hideimg(200); // hide the image since it wasn't shown this frame
  
}
  
  
this.setTimer(0.05);

Each 0.05 seconds, the script looks through every player in the level. If the player it is looking at is the current player, it skips it since you don't want to display it for yourself (if you do, you wouldn't want that part of course). It checks if the player's mouse is on that player. If it is, it shows the text. If not, it doesn't.

Notice that this:

PHP Code:
for (temp.pl players) { 
is equivalent to this:

PHP Code:
for (temp.0players.size(); ++) {
  
pl players[i]; 
It's just easier to do.

Sorry for the long post, I hope it answers your questions. And as always, sorry if I come off as condescending.
__________________
Reply With Quote
  #4  
Old 05-24-2010, 05:07 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Not condescending at all, and thanks to both of you. Needed to actually learn what attr[#] was and how to make it work.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 02:06 PM.


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