View Single Post
  #14  
Old 08-26-2004, 05:27 AM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
NPC Code:

if(created){
setstring this.string,Welcome,to,graal,forums;
setstring this.search,forums;
}

if(playerenters){
pos = lindexof(#s(this.search),this.string);
if(pos>=0) message Word found at position: #v(pos);
else message Word not found;
}



I will explain it anyway:

NPC Code:

if(created){
setstring this.string,Welcome,to,graal,forums; // string list of course
setstring this.search,forums; // the word you're searching
}



That string (this.string) is divided into 4 pieces, you count the pieces since the number 0. (same method of triggeraction and other commands), so:
Welcome - piece 0
to - piece 1
graal - piece 2
forums - piece 3

NPC Code:

if(playerenters){
pos = lindexof(#s(this.search),this.string);
if(pos>=0) message Word found at position: #v(lindexof(#s(this.search),this.string));
else message Word not found;
}



I presume you know how lindexof work, so, create a variable (you don't really need it, but i like to) to hold the value of the lindexof(), just check if it is >= 0 and voalá, here is your example script.
Hope this help, took me - 5 minutes of sleep, good night. n_n'
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote