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 04-08-2013, 04:22 PM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
Returning players clientside

PHP Code:
for ( temp.players ) {
  echo( 
temp.);

This is only returning one player in the same level on the clientside, and I want it to return all of the players in the level; or in the players[] array case, 3x3 levels, which is also fine.
Reply With Quote
  #2  
Old 04-08-2013, 04:30 PM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
PHP Code:
for ( temp.pl allplayers ) { //This will get you all the current players on the server.
  
if (temp.pl.level.name != player.level.name) { //And this will filter out the players that aren't in your level.
    
continue;
  }

  echo( 
temp.pl );

__________________
Reply With Quote
  #3  
Old 04-08-2013, 04:31 PM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
Quote:
Originally Posted by Tim_Rocks View Post
PHP Code:
for ( temp.pl allplayers ) {
  echo( 
temp.pl );

Doesn't work, I've tried this method. It also isn't what I'm wanting to go for. I want to create a custom hit detection system.
Reply With Quote
  #4  
Old 04-08-2013, 04:33 PM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
Sorry, I was making some changes.

Quote:
Originally Posted by Tim_Rocks View Post
PHP Code:
for ( temp.pl allplayers ) { //This will get you all the current players on the server.
  
if (temp.pl.level.name != player.level.name) { //And this will filter out the players that aren't in your level.
    
continue;
  }

  echo( 
temp.pl );

__________________
Reply With Quote
  #5  
Old 04-08-2013, 04:34 PM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
No dice :s

If it makes a difference, I'm trying to do this on a gmap, so that may cause some problems. Just in case that changes anything that I'm not catching

EDIT: tried it in a singular level. No luck there either
Reply With Quote
  #6  
Old 04-08-2013, 04:38 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
You shouldn't need allplayers.

Try:

PHP Code:
for (temp.pl players) {
  echo(
temp.pl.account);

Alternatively just try this:

echo(players.size()); and see if it's actually just returning 1. I don't remember if players returns objects or id's.
Reply With Quote
  #7  
Old 04-08-2013, 04:39 PM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
Quote:
Originally Posted by devilsknite1 View Post
No dice :s

If it makes a difference, I'm trying to do this on a gmap, so that may cause some problems. Just in case that changes anything that I'm not catching

EDIT: tried it in a singular level. No luck there either
Oh, I'm sorry, I wasn't sure what you were looking for at first.. Try this.

PHP Code:
for (temp.plfindNearestPlayers(this.xthis.y)) {
  echo(
temp.pl);

That should help, you'll need distance checks though.
__________________
Reply With Quote
  #8  
Old 04-08-2013, 04:41 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
Quote:
Originally Posted by Tim_Rocks View Post
Oh, I'm sorry, I wasn't sure what you were looking for at first.. Try this.

PHP Code:
for (temp.plfindNearestPlayers(this.xthis.y)) {
  echo(
temp.pl);

That should help, you'll need distance checks though.
Actually ya, I think this may be what he wants. He shouldn't need distance checks if he's looking for all players in the level as this is what I think findNearestPlayers() returns(all loaded players).
Reply With Quote
  #9  
Old 04-08-2013, 04:45 PM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
He said he was making a hit detection system, and in order to do that, he'll need distance checks so it only registers attacks from players within 1-2 tiles.
__________________
Reply With Quote
  #10  
Old 04-08-2013, 04:47 PM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
Quote:
Originally Posted by DustyPorViva View Post
You shouldn't need allplayers.

Try:

PHP Code:
for (temp.pl players) {
  echo(
temp.pl.account);

Alternatively just try this:

echo(players.size()); and see if it's actually just returning 1. I don't remember if players returns objects or id's.
players returns an object, and the size is always outputting 1, no matter how many players are in the level.

Quote:
Originally Posted by Tim_Rocks View Post
PHP Code:
for (temp.plfindNearestPlayers(player.xplayer.y)) {
  echo(
temp.pl);

Not having any luck with this, it's still only returning one player in the level. I'm doing it through a weapon NPC, so I switched it to what I'm using. Now, I can change where it detects the nearest player(s), but it still only returns one player
I mean that method can work just fine and is probably what I'll end up doing, but I'm trying to figure out why all of the players in the level aren't being returned o_o
Reply With Quote
  #11  
Old 04-08-2013, 04:55 PM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
PHP Code:
for (temp.plfindNearestPlayers(player.xplayer.y)) { //It was this.x, this.y
  
echo(temp.pl);

There ya go, don't forget to check F2 to see the echo's; it's not going to appear on RC.
__________________
Reply With Quote
  #12  
Old 04-08-2013, 04:56 PM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
I really don't think you're reading what I'm writing...
I'm well aware where echo() will output. I'm just wondering why I can't return all of the players in a level.
Reply With Quote
  #13  
Old 04-08-2013, 05:00 PM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
I just logged in player to test it; it's working. Sorry didn't realize you fixed my typo. That's what I'm working with, it's hard for me to help if you don't provide code for us to look at.

PHP Code:
findplayer("Tim_Rocks").addweapon(this.name);

//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat == ":hiqtpi") {
    
    for (
temp.pl findNearestPlayers(player.xplayer.y)) { 
      echo(
temp.pl); 
    }  
    
    
player.chat "worked?";
  }

Edit: I'm not even exactly sure why your original code isn't work; It should return everyone on the gmap.
__________________
Reply With Quote
  #14  
Old 04-08-2013, 05:20 PM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
Errrrr I was being dumb
I was drawing a circle around all of the players and it was only showing on one, so instead of looking at how I wasn't indexing the image, I deduced that the returning players wasn't working. OOPS
Thanks for the help though guys, sorry about that
Reply With Quote
  #15  
Old 04-09-2013, 05:26 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
FWIW, I've actually experienced a bug like the one you initially reported in the past:

Quote:
Originally Posted by cbk1994 View Post
Has anyone had issues with the players array being empty clientside? It's happening to me both on GMAPs and in single levels randomly on Mac. Reconnecting fixes it.
It was actually empty, though.
__________________
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:33 PM.


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