Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Looping through every player serverside (https://forums.graalonline.com/forums/showthread.php?t=68463)

JkWhoSaysNi 08-30-2006 11:54 PM

Looping through every player serverside
 
Hello, i'm trying to loop through each player on the serverside in a database npc.

I tried this:

PHP Code:

for (pplayers) {
  
this.playernames.add(p.account);
 } 

however, for some reason it doesn't store all the players accounts.

Heres how i'm using it:

PHP Code:

db findnpc("DBNPC");
playernames db.getPlayerNames(); 

All this is serverside, then I send the playernames array, along with some other info to the clientside using triggeractions.

However...

If i'm in a level with more than 1 person I get the names of the people in the same level as me and my account name.
If i'm in a level on my own I just get my own account name.

Can anyone explain this? It's all being done serverside so why it doesnt always show every account on the server is puzzling.

Any ideas? Thanks.

Luigi203 08-31-2006 12:36 AM

allplayers = the playercount of the server
playerscount = the playercount of the level

JkWhoSaysNi 08-31-2006 12:41 AM

I take it then that players is just the players on the level...

but that makes no sense because players[int] can find any player on the server.

xXziroXx 08-31-2006 12:50 AM

Quote:

Originally Posted by JkWhoSaysNi
I take it then that players is just the players on the level...

but that makes no sense because players[int] can find any player on the server.

True, but do this and it will work:

PHP Code:

for (pallplayers) {
  
this.playernames.add(p);


No need for p.account either, just use p.

JkWhoSaysNi 08-31-2006 04:00 AM

thanks, that did it :)


All times are GMT +2. The time now is 10:11 AM.

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