![]() |
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:
|
players is for players in the level, you need to use allplayers.
PHP Code:
|
...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:
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. |
Quote:
Quote:
I even did this: PHP Code:
|
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 |
Quote:
|
Quote:
That or I'm just ignorant. |
Quote:
|
Quote:
|
Quote:
Doing something like: PHP Code:
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. |
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.
|
Quote:
Edit: I just tested, and when doing: PHP Code:
|
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:
|
Quote:
PHP Code:
|
Quote:
Also, that DOESN'T work. |
Try something like this:
PHP Code:
|
Turns out the error was in fact with the line
PHP Code:
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. |
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. |
| All times are GMT +2. The time now is 10:14 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.