| Blockland Forums > Modification Help |
| Reading Words in a Sentence |
| (1/2) > >> |
| General:
I'm having problems figuring out how to do the following: $Answer[0] = "I'm AFK right now." $Answer[1] = "I'm AFK at the moment." $Answer[2] = "I'm AFK." $Answer[3] = "AFK, ask me later." package AFKBot { function serverCmdMessageSent(%client, %text) { for (%i = 0; %i < getWordCount(%text); %i++) { %t = getWord(%text,%i); if (%t $= "#") { schedule(1000,0,messageAll,'',"<color:FFFF00>General<color:FFFFFF>: " @ $Answer[getRandom(3)]); } } parent::serverCmdMessageSent(%client, %text); } }; activatePackage(AFKBot); The code just checks for the word I enter where the red number symbol is, if the word is Hello and somebody says: "Hello, how's it going General?" It will return a message. I want it to check for two or more words in that sentence to return the message, for example: "Hello, how's it going General?" Both Hello and General... I hope I made myself as clear as possible, help would be much appreciated. Thanks. |
| Plornt:
It should be getRandom(0,3); |
| General:
--- Quote from: Plornt on July 16, 2010, 12:45:23 PM ---It should be getRandom(0,3); --- End quote --- It doesn't have to be... It works the same either way |
| Plornt:
do if(stripos(%text,%word) !$= -1 || stripos(%text,%Otherword) !$= -1) { servercmdMessageSent(findclientbyname(General),$Answer[getRandom(3)]); } |
| General:
--- Quote from: Plornt on July 16, 2010, 01:32:25 PM ---do if(stripos(%text,%word) !$= -1 || stripos(%text,%Otherword) !$= -1) { servercmdMessageSent(findclientbyname(General),$Answer[getRandom(3)]); } --- End quote --- What I meant was that I want both words to be present in the sentence to display the message, not separated. |
| Navigation |
| Message Index |
| Next page |