It could often help to do a flowchart and then pseudo-code when you do a NPC and then turn it, a step at a time, in to code:
1) What should the NPC do when ...
Clicked on? -> Nothing -> Put a close/end at the beginning
Spoken near? -> Register item ID or name and check if it matches a previously created pattern.
-> We need to make the arrays
-> We need to make the patterns (there's two ways to handle this, I'll get to that later on)
2) Pseudo-code
NPC header {
(We could if we wanted to, present the user with a list of items so he/she dont have to remember it)
close; (We do not want the user to click the NPC)
OnInit: (What do we need to do before using the NPC?)
1) Arrays for items
2) Regular expressions
end; (OnInit done)
Labels and code for the RegExp (Here we also want to check for the equipped item since the code starts reading from each label)
}
The arrays are correct for you, I don't see why you put in those two for-loops since they only iterate through the arrays without changing anything.
And if you want to have a loop inside another, you shouldn't use the same iteration variable for both (in this case .@i)
Regular Expressions, "defpatterns", works like this:
You give a pattern for a string to find, the parts that are inside round brackets will be set as a variable you can use! (We like this)
So you can make 1 expression for each item OR pass the name or ID said and check if those are inside the arrays. (More convenient with larger arrays)
Example of using names for the patterns: (I'm not showing how to manually make each pattern since everyone likes it dynamic, and also using a bit of lazy coding)
for(i=0; i < size(.@lowerid); i++){ //For each item (Both lists should be the same size)
defpattern 1, "([^:]+):s"+.@lowerid[ i ], getd("L"+.@lowerid[ i ]); //Make a pattern for the id pointing at the label L<id>
defpattern 1, "([^:]+):s"+.@lowername$[ i ], getd("L"+.@lowerid[ i ]); //Make a pattern for the name pointing at the label L<id>
}
activatepset 1; //Activate the patterns we did
end;
//This is where the code starts reading for the user when they say a certain string, you want to check their items equipped etc. after the appropriate label.
L25200:
code for item 25200
end;
L25201:
code for item 25201
end;
... and so on
Example of using general pattern for all:
defpattern 1, "([^:]+).*)", "CheckItem";
activatepset 1;
end;
CheckItem:
set .@name$, $@p2$; (If the player said the item name)
set .@id, atoi($@p2$); (If the player said the item ID)
Now you loop through the arrays looking for any of those two, if you find a result, then you can do what you need to, otherwise just end;
I'm not 100% sure that the patterns I used above are correct since I can't test them but they should give enough information for you to find the correct one from trial and error.
There are also a lot of examples in https://rathena.svn....le/npc_pcre.txt
I hope this all makes sense, otherwise just ask