Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Old Scripting Engine (GS1)
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-16-2007, 01:29 PM
pig132 pig132 is offline
professional troll
Join Date: May 2006
Posts: 260
pig132 will become famous soon enough
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!;
  
}

Reply With Quote
  #2  
Old 07-16-2007, 05:16 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
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).

__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #3  
Old 07-16-2007, 05:56 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
I thought using "string" in GS1 isn't valid
Reply With Quote
  #4  
Old 07-16-2007, 06:15 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
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!";
    }
  }

__________________
Reply With Quote
  #5  
Old 07-17-2007, 02:50 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Oh haha, I overlooked the array setting - should be setstring indeed!
__________________
Follow my work on social media post-Graal:Updated august 2025.
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 07:13 PM.


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