View Full Version : Array doesn't seem to be returning the players in a selection

10-24-2013, 11:05 PM
I haven't played Graal or coded for Graal in a long time now. However, I am getting back into it. Since this is my first post in a very long time I would like to state that I've became much more of an experienced Scripter after learning a lot of Java and learned how to write much better since I aged and got a better education. So please forgive me if in my past I ever sounded like I was immature, as I have changed now. Thank you.

Anyways, I have ran into an issue with some of my code that I'm working on. The code is posted below:

getPlayers function:

function getPlayers() {
temp.array = {};
for (temp.i : players) {
if (temp.i.level.name == player.level.name) {
if (temp.i.x in |mousestart[0], mousestart[2]| && temp.i.y in |mousestart[1], mousestart[3]|) {
return temp.array;

Test function:

function Test(playerss) {
for (temp.i : playerss) {
findplayer(temp.i).chat = "WOOT";

The issue is, is that whenever the first even fires, it doesn't seem to add anything to the array because when I try and do: "player.chat = temp.array" nothing happens. I'm sure that these events are being properly called through my script and this is the line that is combined these functions: "Test(getPlayers());". It appears the chat doesn't say 0 either as I think it would if I remember correctly if you use an empty array. Thank you and please help me!

10-24-2013, 11:25 PM

the first thing i should ask is whether 'mousestart' is being defined previously, if not then i guess you mean to use 'mousex' and 'mousey'. you may also want to use the center of the players which is player.x + 1.5 and player.y + 2

also although using findplayer('account'); would still work, you dont need to use the function because findplayer(); is just returning the object you obtained the account string from in the first place

when you try 'player.chat = temp.array' player.chat is supposed to be a string, so its not really correct to be setting it to an array of player objects, you could try 'player.chat = (@ temp.array)' and hope the engine truncates the objects into strings, or do 'player.chat = temp.array[0].account'

and i think it would still work in the case of 'array' but its not really a good idea to be using variable names of built-in object types, for example using 'var' breaks stuff

10-25-2013, 12:38 AM
Everything he said ^ plus...

If the first script is checking your mouse x and y it's going to have to be clientside, if it isn't already. Then you'll have to use a trigger to set the other players chat.

And it's not really necessary to check if the players level name is the same as the npcs level name, as the players array already only contains players in the npcs level.

10-25-2013, 01:51 AM
Yes, it is previously defining the mousestart correctly, I have the set up right as it works when I draw a polygon through the locations. Also, I know that arrays are not equal to strings, however Graal translates them to: "Graal749201, Graal482914, Starfire2001" if it is set as a player.chat if I remember correctly. I will remove the levelname thing though. Thank you for that.

EDIT: However, it appears that nothing has changed.

10-25-2013, 02:23 AM
Just started working somewhat randomly. Very odd. Must've been something weird with my spacing because I re-wrote some of the code.