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 08-25-2004, 03:37 PM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
Position of strings

Im just messing around wondering how would i get the postion of a string without tokenizeing the string... i've tried lindexof , indexof and triming the string and getting the var of each ... but none work, indexof was the closest thing to it but it gave the positon of the first letter in the entire string so say if i had
this.parts = one,two,three
indexof would give me 1,4,7
if it helps this is what i put when i trimed the string
NPC Code:

if(actionserverside)
sendtonc Debug:#p(0);
//#CLIENTSIDE
if(created){
setstring this.parts,skin,coat,sleeves,shoes,belt;
}
if(playerchats){
tokenize #c;
if(strcontains(#s(this.parts),#t(0))){
triggeraction 0,0,serverside,Player/Taylor,#e(indexof(#t(0),#s(this.parts)),strlen(#t( 0)),#s(this.parts))
,;
}
}


that gets me the string but i want the position of the string in the list
and this is with indexof
NPC Code:

if(actionserverside)
sendtonc Debug:#p(0);
//#CLIENTSIDE
if(created){
setstring this.parts,skin,coat,sleeves,shoes,belt;
}
if(playerchats){
tokenize #c;
if(strcontains(#s(this.parts),#t(0))){
triggeraction 0,0,serverside,Player/Taylor,#v(indexof(#t(0),#s(this.parts)))
,;
}
}


Last edited by ZeroTrack; 08-25-2004 at 03:48 PM..
Reply With Quote
  #2  
Old 08-25-2004, 11:08 PM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
anyyone... aannyyyonneee? =(
Reply With Quote
  #3  
Old 08-25-2004, 11:13 PM
calum calum is offline
Registered User
Join Date: Nov 2003
Location: Scotland
Posts: 182
calum is on a distinguished road
1. Stop double posting, it is something that i see you do frequently.
2. Have you tried using 'addstring' and using '#I'?
__________________
Reply With Quote
  #4  
Old 08-25-2004, 11:13 PM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
Explain a little further what u r trying to do...
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #5  
Old 08-25-2004, 11:41 PM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
Quote:
Originally Posted by calum
1. Stop double posting, it is something that i see you do frequently.
No i havent
Quote:
Originally Posted by calum
2. Have you tried using 'addstring' and using '#I'?
and yes i have
Reply With Quote
  #6  
Old 08-26-2004, 12:13 AM
middo middo is offline
VHE Monkey
middo's Avatar
Join Date: Aug 2002
Location: California
Posts: 327
middo is on a distinguished road
Send a message via AIM to middo
#I is the way to go

I don't see why it wouldn't have worked.
Reply With Quote
  #7  
Old 08-26-2004, 12:28 AM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
Quote:
Originally Posted by middo
#I is the way to go

I don't see why it wouldn't have worked.
i've tried that but i need the interger not the string
Reply With Quote
  #8  
Old 08-26-2004, 12:29 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
lindexof(string,stringlist)
Reply With Quote
  #9  
Old 08-26-2004, 12:53 AM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
Quote:
Originally Posted by Lance
lindexof(string,stringlist)
tried that already see
Quote:
Originally Posted by ZeroTrack
i've tried lindexof , indexof and triming the string and getting the var of each ... but none work
Reply With Quote
  #10  
Old 08-26-2004, 03:08 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
wait how do you usae #I?
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #11  
Old 08-26-2004, 03:46 AM
xManiamaNx xManiamaNx is offline
Supreme Dictator
xManiamaNx's Avatar
Join Date: Nov 2002
Location: 127.0.0.1
Posts: 385
xManiamaNx is on a distinguished road
Send a message via MSN to xManiamaNx Send a message via Yahoo to xManiamaNx
#I(string,token);
setstring this.foo,bar,asdf,fhqwhgads
#I(this.foo,2) = asdf
__________________
Maniaman

Play Maloria Now: [2.3] [3]
Maloria Website

Reply With Quote
  #12  
Old 08-26-2004, 04:49 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
i got it thanks
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #13  
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
  #14  
Old 08-26-2004, 06:27 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by ZeroTrack
tried that already see
Then you're doing something wrong...?
Reply With Quote
  #15  
Old 08-26-2004, 05:11 PM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
Quote:
Originally Posted by Lance
Then you're doing something wrong...?
no im not i did excatly this it was the first thing i tried
NPC Code:

if(actionserverside)
sendtonc Debug:#p(0);
//#CLIENTSIDE
if(created){
setstring this.parts,skin,coat,sleeves,shoes,belt;
}
if(playerchats){
tokenize #c;
if(strcontains(#s(this.parts),#t(0))){
triggeraction 0,0,serverside,Player/Taylor,#v(lindexof(#t(0),this.parts));
}
}


Last edited by ZeroTrack; 08-26-2004 at 05:36 PM..
Reply With Quote
  #16  
Old 08-26-2004, 05:43 PM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by ZeroTrack
no im not i did excatly this it was the first thing i tried
NPC Code:

if(actionserverside)
sendtonc Debug:#p(0);
//#CLIENTSIDE
if(created){
setstring this.parts,skin,coat,sleeves,shoes,belt;
}
if(playerchats){
tokenize #c;
if(strcontains(#s(this.parts),#t(0))){
triggeraction 0,0,serverside,Player/Taylor,#v(lindexof(#t(0),this.parts));
}
}

It works perfectly, even though you should not be using strcontains...?
Reply With Quote
  #17  
Old 08-26-2004, 06:58 PM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
.. i reset the npcserver and it started working, and yes thats there for the taylor part
finshed script... no stealing please
NPC Code:

//#CLIENTSIDE
if(created)
setstring this.parts,skin,coat,sleeves,shoes,belt;

if(playerchats){
tokenize #c;
if(strcontains(#s(this.parts),#t(0))){
part=lindexof(#t(0),this.parts);
if(part=0)
setplayerprop #C0,#t(1);
if(part=1)
setplayerprop #C1,#t(1);
if(part=2)
setplayerprop #C2,#t(1);
if(part=3)
setplayerprop #C3,#t(1);
if(part=4)
setplayerprop #C4,#t(1);
}
}

Reply With Quote
  #18  
Old 08-26-2004, 07:43 PM
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:

//#CLIENTSIDE

if(created){
setstring this.parts,skin,coat,sleeves,shoes,belt;
}

if(playerchats){
tokenize #c;
pos = lindexof(#t(0),this.parts);
if(pos>=0){
if(startswith(#t(0),#c)){
setplayerprop #c,[#I(this.parts,pos) was changed to color #t(1)];
if(pos == 0) setplayerprop #C0,#t(1);
if(pos == 1) setplayerprop #C1,#t(1);
if(pos == 2) setplayerprop #C2,#t(1);
if(pos == 3) setplayerprop #C3,#t(1);
if(pos == 4) setplayerprop #C4,#t(1);
}
}
}



Too simple, please try to understand the code and feel free to use it.
__________________
"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
  #19  
Old 08-26-2004, 07:53 PM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
Quote:
Originally Posted by osrs
Too simple
You've got to be kidding O_O;
__________________
Reply With Quote
  #20  
Old 08-26-2004, 07:59 PM
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
Quote:
Originally Posted by Gerami
You've got to be kidding O_O;
Things are simple when you want to learn & work hard to progress instead of look for help every time.
__________________
"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
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 04:03 PM.


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