Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   RequestURL woes (https://forums.graalonline.com/forums/showthread.php?t=67191)

Raeiphon 07-07-2006 08:51 AM

RequestURL woes
 
NPC Code:

function onTimeout() {
xr = player.chat.tokenize();
switch(xr[0]) {

case ":ar":
player.chat = "doing..";
this.req = requestURL(xr[1]);
catchEvent(this.req,"onRecieveData","onData");
break;

}
setTimer(.05);
}

function onData(obj) {
player.chat = obj;
}



Obj returns nothing. Absolutely nothing. The chat stays doing.. for the default chat timeout and just disappears. Now the interesting part:

If I were to do player.chat = this.req right below it, and the url was, say http://www.di.fm/aacplus/lounge.pls, i'd get:

HTTP_www.di.fm_80_/aacplus/lounge.pls

Which of course, yields nothing any closer to parsing it into a stream.

And also, if I extract the ip/port of the stream from the pls file manually, and try to play it within graal, it doesnt work. Why?

Admins 07-07-2006 09:57 AM

Should be "onReceiveData" or "receivedata"

Raeiphon 07-07-2006 02:35 PM

So I should change onData to onRecieveData?

ApothiX 07-08-2006 01:24 PM

Recieve is spelled Receive. I before E except after c.

catchEvent(this.req,"onRecieveData","onData");
needs to be changed to:
catchEvent(this.req,"onReceiveData","onData");

Raeiphon 07-08-2006 05:25 PM

Oh, forgot that :o

Still doesnt work

Admins 07-09-2006 12:47 AM

onData is never called? You do it on clientside right ?

Raeiphon 07-09-2006 04:56 AM

Of course. onData simply is never called.

KuJi 07-12-2006 07:40 AM

Do you even call onTimeout();?

Rick 07-12-2006 07:43 AM

why are you using timeout to watch the player's chat?

ApothiX 07-12-2006 09:58 AM

Quote:

Originally Posted by KuJi
Do you even call onTimeout();?

... I believe there's a rule about responses like this.

Quote:

Originally Posted by Rick
why are you using timeout to watch the player's chat?

Heh, good point.

Raeiphon 07-12-2006 10:11 AM

onTimeout is called in onCreated. This is in a 300 line script, like i'm going to cut it all anyway :[

So besides correcting each other and backseat moderating, are any of you going to actually make any input or is the thread going to go inactive again?

xXziroXx 07-12-2006 11:32 AM

Quote:

Originally Posted by Raeiphon
onTimeout is called in onCreated. This is in a 300 line script, like i'm going to cut it all anyway :[

So besides correcting each other and backseat moderating, are any of you going to actually make any input or is the thread going to go inactive again?

So why not simply use onPlayerChats() to lower *the lag*?

Raeiphon 07-12-2006 12:59 PM

Hey um, that's nice, if you'd read the previous posts you'd know why it was like that.

Have you got ANYTHING to contribute as to why requestURL isnt working or are you going to continually poke at my coding style?

ForgottenLegacy 07-13-2006 02:14 AM

Uh, you can't do catchEvent on events like that. It just doesn't work for some reason. You should use the standard onReceiveData() function, and pass that to onData().

PHP Code:

function onReceiveData(params...) {
  
onData(params...);



ApothiX 07-14-2006 04:04 PM

Quote:

Originally Posted by ForgottenLegacy
Uh, you can't do catchEvent on events like that. It just doesn't work for some reason. You should use the standard onReceiveData() function, and pass that to onData().

PHP Code:

function onReceiveData(params...) {
  
onData(params...);



you can do catchEvent like that. I think you may have to do it like this, though: catchevent(this.req.name, ...)

Try that and see if it works.


Quote:

Originally Posted by Raeiphon
Hey um, that's nice, if you'd read the previous posts you'd know why it was like that.

Actually, you made no mention to why it is in a timeout, and not just in an onPlayerChats() handler. I can not think of any reason why you would need such a thing in a timeout.


All times are GMT +2. The time now is 09:13 PM.

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