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 03-09-2008, 05:54 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
problem with the players array o.0

For some odd reason (I don't know if this is restricted to just Maloria, or what) the built in players array which holds objects for the players on the server (as opposed to allplayers, which has their accounts) is not working serverside. I've tried just making a test NPC to do something like this:
PHP Code:
for (plplayers) {
  echo(
pl.account);

But nothing happens...I've tried restarting the NPC Server several times, and now I'm at a loss...
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #2  
Old 03-09-2008, 06:03 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
players is for players in the level, you need to use allplayers.

PHP Code:
for ( temp.allplayers )
{
  echo( 
temp.i.account );

__________________
Reply With Quote
  #3  
Old 03-09-2008, 06:06 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
...uh...
I've always used players serverside as far as I can remember...never had trouble with it before.
And for some reason when I use allplayers it goes through twice.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #4  
Old 03-09-2008, 06:20 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
Quote:
Originally Posted by coreys View Post
...uh...
I've always used players serverside as far as I can remember...never had trouble with it before.
And for some reason when I use allplayers it goes through twice.
Well you've always done it wrong ... players means the players in a level, may have worked for a DB NPC in a level with players ...

allplayers should only be going through once. I would try echoing at the beginning of the function to make sure it isn't being called twice.
__________________
Reply With Quote
  #5  
Old 03-09-2008, 06:26 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by cbkbud View Post
Well you've always done it wrong ... players means the players in a level, may have worked for a DB NPC in a level with players ...
No. It's worked for every NPC I've done using it. I'm not stupid, I would've figured it out by now if it never worked.
Quote:
Originally Posted by cbkbud View Post
allplayers should only be going through once. I would try echoing at the beginning of the function to make sure it isn't being called twice.
No ****.
I even did this:
PHP Code:
temp.list = new[0];
for (
plallplayers) {
  if (!(
pl in temp.list)) {
    
temp.list.add(pl);
    echo(
pl);
  }

And it echoed twice.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #6  
Old 03-09-2008, 06:27 AM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Why it's going 'twice' is because it contains IRCs, RC's and players..

to filter those out use obj.isexternal and/or check if their level is 0 or something
__________________
Reply With Quote
  #7  
Old 03-09-2008, 06:29 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Chompy View Post
Why it's going 'twice' is because it contains IRCs, RC's and players..

to filter those out use obj.isexternal and/or check if their level is 0 or something
Yeah, I've checked for NULL level as well, and it still does it o.o
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #8  
Old 03-09-2008, 06:30 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
Quote:
Originally Posted by coreys View Post
No. It's worked for every NPC I've done using it.
Then your NPC-Server really is screwed up ;o

That or I'm just ignorant.
__________________
Reply With Quote
  #9  
Old 03-09-2008, 06:38 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by cbkbud View Post
That or I'm just ignorant.
I prefer the term "misinformed," although they technically mean the same thing.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #10  
Old 03-09-2008, 07:17 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
Quote:
Originally Posted by coreys View Post
I prefer the term "misinformed," although they technically mean the same thing.
Just tried it, players does not work for me on my server ...
__________________
Reply With Quote
  #11  
Old 03-09-2008, 09:32 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by coreys View Post
Yeah, I've checked for NULL level as well, and it still does it o.o
Odd...

Doing something like:
PHP Code:
for (temp.pallplayers) {
  if (
temp.p.level != null) {
    echo(
temp.p.account);
  }

Will only show the accounts of the player not on RC.

And, yes, Chris is correct. 'players' is an array of player objects in the level, while 'allplayers' is the array of player objects on the server.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #12  
Old 03-09-2008, 10:19 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
players will not work in all cases serverside in a WNPC because it does not always have the scope of a player which is required to have the level variable not be NULL. If the level variable is NULL, logically the players variable would be empty.
__________________
Do it with a DON!
Reply With Quote
  #13  
Old 03-09-2008, 05:58 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by zokemon View Post
players will not work in all cases serverside in a WNPC because it does not always have the scope of a player which is required to have the level variable not be NULL. If the level variable is NULL, logically the players variable would be empty.
Yeah, I was sending player.level, which is an object and cannot be passed serverside, instead of player.level.name.

Edit:
I just tested, and when doing:
PHP Code:
if (players != NULL)
  echo(
"test"); 
in the triggeraction I've been trying to use this in, it echoes "test." Meaning players is not null. However, I still can't use it. o.O
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #14  
Old 03-09-2008, 06:37 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Sorry to double-post, but I've got the weirdest ****ing problem with this now...
When both an RC and a client for an account is on, no matter what you do, when you loop through allplayers it will go to that account twice.
PHP Code:
temp.list = NULL;
for (
plallplayers) {
  if (
pl in temp.list)
    continue;
  
temp.list.add(pl);
  
temp.player findPlayer(pl);
  if (
temp.player.level.name != NULL && temp.player.level.name != "level") {
    if (
temp.player.level.name == params[3])
      echo(
pl);
  }

Will still echo my name twice if I am on both client and RC.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #15  
Old 03-09-2008, 06:51 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by coreys View Post
Sorry to double-post, but I've got the weirdest ****ing problem with this now...
When both an RC and a client for an account is on, no matter what you do, when you loop through allplayers it will go to that account twice.
PHP Code:
temp.list = NULL;
for (
plallplayers) {
  if (
pl in temp.list)
    continue;
  
temp.list.add(pl);
  
temp.player findPlayer(pl);
  if (
temp.player.level.name != NULL && temp.player.level.name != "level") {
    if (
temp.player.level.name == params[3])
      echo(
pl);
  }

Will still echo my name twice if I am on both client and RC.
You dont have to do the findPlayer() stuff. Something like this will work:

PHP Code:
for (temp.plallplayers) {
  
pl.addWeapon("xyz");
  
pl.hearts 5;
  
pl.client.foo bar;

Reply With Quote
  #16  
Old 03-09-2008, 06:57 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Crow View Post
You dont have to do the findPlayer() stuff. Something like this will work:

PHP Code:
for (temp.plallplayers) {
  
pl.addWeapon("xyz");
  
pl.hearts 5;
  
pl.client.foo bar;

Doesn't change anything though. I figured since it...you know, returned a string, that it wasn't an object.
Also, that DOESN'T work.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #17  
Old 03-09-2008, 07:05 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Try something like this:

PHP Code:
echo("I am generating a list now!");
for (
temp.allplayers) {
  if (!
p.isexternal && p.level != "") {
    echo(
" - " p);
  }

Also: allplayers is not an array of strings but is in fact an array of TServerPlayer's and such.
__________________
Do it with a DON!
Reply With Quote
  #18  
Old 03-09-2008, 07:12 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Turns out the error was in fact with the line
PHP Code:
temp.player findPlayer(pl); 
In doing this, you are setting temp.player to the client pl.
If I had zokemon in all players twice, one for my client and one for my RC, using findplayer() for both of those would give my client.
__________________
Do it with a DON!
Reply With Quote
  #19  
Old 03-09-2008, 07:26 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
When you display object as a string it is using the name of the object. Like doing any string operations on player.level such as player.level.starts() would be doing player.level.name.starts()

Though it doesn't appear to do that with custom objects. I would like it if there was a tostring() function for objects that Graal would call. Which would return this.name by default and could be overridden by scripts.
__________________
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 12:51 AM.


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