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 09-17-2011, 05:03 AM
oralgnome oralgnome is offline
doesnt afraid of anything
oralgnome's Avatar
Join Date: Sep 2011
Posts: 34
oralgnome is an unknown quantity at this point
checking an array's contents

I wonder if there's a way to just check an array's contents without actually doing so, for instance if I had an array full of account strings how would I check if one of them was the client's player.account? account.array[someselectingparams] (what would those params be?)
Reply With Quote
  #2  
Old 09-17-2011, 05:24 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
This is an example of an array:
PHP Code:
temp.array = {"hello","world"};
player.chat temp.array[0]; // 0 is our index 
Output:
PHP Code:
hello 
Using an index of 1 would result in:
PHP Code:
world 
If you just want to see if a player's account name is in the array you can use:
PHP Code:
if ( player.account in temp.array ) {
  
// do stuff

Reply With Quote
  #3  
Old 09-17-2011, 05:53 AM
oralgnome oralgnome is offline
doesnt afraid of anything
oralgnome's Avatar
Join Date: Sep 2011
Posts: 34
oralgnome is an unknown quantity at this point
I'm not a n00b, I know what an array and index is (I wrote in the post) I was just merely asking if there was a way to check the array content (because in java normally you'd loop through each value). Thanks for the reply though helped me solve my problem - can't imagine why there is an 'in' operator though lol gs2
Reply With Quote
  #4  
Old 09-17-2011, 06:26 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quote:
Originally Posted by oralgnome View Post
I'm not a n00b, I know what an array and index is (I wrote in the post) I was just merely asking if there was a way to check the array content (because in java normally you'd loop through each value). Thanks for the reply though helped me solve my problem - can't imagine why there is an 'in' operator though lol gs2
Sorry, wasn't trying to imply you were a noob. Just informing fellow passer-by's that may happen to stumble upon this thread.

Yeah, "in" can make things so much easier.
Reply With Quote
  #5  
Old 09-24-2011, 04:27 PM
gaben gaben is offline
uhh no
gaben's Avatar
Join Date: Aug 2011
Posts: 47
gaben is an unknown quantity at this point
i was wondering as well if you can check if a value is not in array with a similar method
__________________
Quote:
Originally Posted by iBeatz View Post
Who came up with this Cheat Engine? The more I read about, the more ingenious the whole thing sounds.
Quote:
Originally Posted by Unixmad
This forums is going worst each day.
Quote:
Originally Posted by ff7chocoboknight View Post
You sure are taking your time leaving, furry.
Quote:
Originally Posted by [email protected] View Post
are u old enough 2 even play Graal little girl???
Reply With Quote
  #6  
Old 09-24-2011, 04:31 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by gaben View Post
i was wondering as well if you can check if a value is not in array with a similar method
PHP Code:
if (!(temp.element in temp.array)) 
__________________
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:25 AM.


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