Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-24-2013, 11:05 PM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Post Array doesn't seem to be returning the players in a selection

Greetings!
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:
PHP Code:
function getPlayers() {
  
temp.array = {};
  for (
temp.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]|) {
        
temp.array.add(findplayer(temp.i).account);
      }
    }
  }
  return 
temp.array;

Test function:
PHP Code:
function Test(playerss) {
  for (
temp.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!
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #2  
Old 10-24-2013, 11:25 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 353
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
hello!

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
__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #3  
Old 10-25-2013, 12:38 AM
Starfire2001 Starfire2001 is offline
Unholy Nation
Starfire2001's Avatar
Join Date: Dec 2010
Location: The streets.
Posts: 156
Starfire2001 will become famous soon enough
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.
__________________
-Ph8
Reply With Quote
  #4  
Old 10-25-2013, 01:51 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
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.
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!



Last edited by Astram; 10-25-2013 at 02:08 AM.. Reason: Editted that the issue is still there
Reply With Quote
  #5  
Old 10-25-2013, 02:23 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Just started working somewhat randomly. Very odd. Must've been something weird with my spacing because I re-wrote some of the code.
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:40 PM.


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