Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Old Scripting Engine (GS1) (https://forums.graalonline.com/forums/forumdisplay.php?f=154)
-   -   Arrays.. (https://forums.graalonline.com/forums/showthread.php?t=75570)

pig132 07-16-2007 01:29 PM

Arrays..
 
I have NO idea how to use arrays and thought maybe this would work, also, how can i find out if the players 2nd word is eqaul to one of the words in the array?
I tried this, but failed. Help would be appreciated.

PHP Code:

if (created) {
  
this.events = {"test","race","idle"};
}
if (
playerchats&&startswith(:select,#c)) {
  
tokenize #c;
  
if (#t(1) != this.events)) {
    
setplayerprop #c,Error: Event not found!;
  
}
  if (
#t(1) = this.events)) {
    
setplayerprop #c,Event chosen!;
  
}



xXziroXx 07-16-2007 05:16 PM

PHP Code:

if (created) {
  
this.events = {"test","race","idle"};
}

if (
playerchats && startswith(:select,#c)) {
  
tokenize #c;
  
if (lindexof(#t(1),#s(this.events)) == -1) {
    
setplayerprop #c,Error: Event not found!;
  
} else {
    
setplayerprop #c,Event chosen!;
  
}


Possibly replace lindexof(#t(1),#s(this.events)) with lindexof(#t(1),this.events).

:)

Twinny 07-16-2007 05:56 PM

I thought using "string" in GS1 isn't valid :confused:

Inverness 07-16-2007 06:15 PM

You're mixing GS2 with GS1 up at the top there. You would use
PHP Code:

//GS1
if (created) {
  
setstring this.events,test,race,idle;
}

if (
playerchats && startswith(:select,#c)) {
  
tokenize #c;
  
if (lindexof(#t(1),this.events) == -1) {
    
setplayerprop #c,Error: Event not found!;
  
} else {
    
setplayerprop #c,Event chosen!;
  
}


PHP Code:

//GS2
function onCreated() {
  
this.events = {"test""race""idle"};
}
function 
onPlayerChats() {
  if (
player.chat.starts(":select")) {
    
temp.tokens player.chat.tokenize();
    if (
this.events.index(temp.tokens[1]) == -1) {
      
player.chat "Error: Event not found!";
    }
    else {
      
player.chat "Event chosen!";
    }
  }



xXziroXx 07-17-2007 02:50 AM

Oh haha, I overlooked the array setting - should be setstring indeed! ^^


All times are GMT +2. The time now is 01:45 PM.

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