Quote:
Originally Posted by killerogue
Hate to revive this, but just read it and found it to be useful. But I've tried a few ways to call the function but it didn't quite work.
What's the issue? Or how should I do it? As I am obviously doing it wrong..:P
|
Call the function serverside with a word as the parameter
for example you can make a class and have a little script in the Control-NPC:
dictionary (class):
PHP Code:
function Define(word) {
temp.link = "http://www.onelook.com/?w=" @ word @ "&ls=a";
echo("Requesting Definition of" SPC word @ ":");
temp.req = requesturl(temp.link);
this.catchevent(temp.req,"onReceiveData","onDefine");
}
function onDefine(obj) {
temp.toks = obj.fulldata.tokenize("\n");
for(b: temp.toks) {
if (b == "<LI>") continue;
if (b.starts("<LI>") > 0) {
temp.ntoks = b.tokenize(";");
temp.npos = temp.ntoks[2].pos("(");
temp.defin = temp.ntoks[2].substring(0,temp.npos);
if (temp.defin.length() > 1) echo(" - " @ temp.defin);
temp.msg++;
}
}
if (temp.msg == 0) echo("No Definitions Found!");
}
Control-NPC
PHP Code:
function onCreated()
join("dictionary");
public function onRCChat() {
if (params[0] == "defineword") {
temp.word = params[1];
Define(temp.word);
}
}
can be a part of the Control-NPC script at the bottom and then..
NPC Code:
/npcdefineword <word here>
in RC chat
I think that should work..