Graal Forums

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

12171217 02-02-2010 02:30 AM

requesturlasgamefile?
 
Does anybody know how to use it?

I've got the parameters, but I have no clue how to use it.

Otherwise, is there a way to save a file to the images folder on the client using savestring?

And if not, can somebody give the NPCServer read/write access to a certain folder on Testbed so I can experiment?

fowlplay4 02-02-2010 04:22 AM

In theory this should work, but it doesn't.

PHP Code:

function urltest() {
  
temp.url "http://forums.graalonline.com/forums/images/misc/vbulletin3_logo_white.gif";
  
temp.req requesturlasgamefile(temp.url"levels/images/vbulletin3_logo_white.gif"0);
  
this.catchevent(temp.req"onReceiveData""onFileTransferred");
}

function 
onFileTransferred(obj) {
  echo(
extractfilename(obj.fileSPC "received. (" obj.fulldata.length() @ " bytes)");


But you can also try the redirect option in the Folder Configuration.

I.e:
NPC Code:

redirect onlineimages/*.png http://www.example.com/images/


coreys 02-02-2010 04:51 AM

ooo, I did not know you could do that in folder config

12171217 02-02-2010 05:34 AM

Quote:

Originally Posted by fowlplay4 (Post 1553679)
In theory this should work, but it doesn't.

PHP Code:

function urltest() {
  
temp.url "http://forums.graalonline.com/forums/images/misc/vbulletin3_logo_white.gif";
  
temp.req requesturlasgamefile(temp.url"levels/images/vbulletin3_logo_white.gif"0);
  
this.catchevent(temp.req"onReceiveData""onFileTransferred");
}

function 
onFileTransferred(obj) {
  echo(
extractfilename(obj.fileSPC "received. (" obj.fulldata.length() @ " bytes)");


But you can also try the redirect option in the Folder Configuration.

I.e:
NPC Code:

redirect onlineimages/*.png http://www.example.com/images/


And what does the former do? Does it add it to the server, or is it sent to the client, is it called on the client? Does the NPCServer need read/write access to the directory?

Admins 02-02-2010 04:47 PM

These things only work in v6.
For the redirect-feature you still need to upload the files to the server (for file-modification-time-check) but the client will download them from a website.
With requesturlasgamefile() you can download a file from a webserver and treat it like it has been downloaded from the server. I've just seen that there is a bug though, normally it requires 4 parameters, will fix it in the next version.

The main reason for these functions is to take stress away from the server, e.g. it could be possible to download Graal.exe from the website instead from the game server so that not hundreds of people download a new Graal version at once and slow down the server.

Darklux 02-02-2010 08:12 PM

Quote:

Originally Posted by Stefan (Post 1553783)
These things only work in v6.
For the redirect-feature you still need to upload the files to the server (for file-modification-time-check) but the client will download them from a website.
With requesturlasgamefile() you can download a file from a webserver and treat it like it has been downloaded from the server. I've just seen that there is a bug though, normally it requires 4 parameters, will fix it in the next version.

Uploading the file anyways is a bit unhandy, could a md5 hash be attached to the command?

12171217 02-02-2010 11:21 PM

Quote:

Originally Posted by Stefan (Post 1553783)
These things only work in v6.
For the redirect-feature you still need to upload the files to the server (for file-modification-time-check) but the client will download them from a website.
With requesturlasgamefile() you can download a file from a webserver and treat it like it has been downloaded from the server. I've just seen that there is a bug though, normally it requires 4 parameters, will fix it in the next version.

The main reason for these functions is to take stress away from the server, e.g. it could be possible to download Graal.exe from the website instead from the game server so that not hundreds of people download a new Graal version at once and slow down the server.

Thanks. How about savestring? Can I use that to save an image on the client?

coreys 02-02-2010 11:47 PM

Quote:

Originally Posted by 12171217 (Post 1553839)
Thanks. How about savestring? Can I use that to save an image on the client?

I wouldn't think so, since it will be saving it as ASCII data instead of binary data (I'm pretty sure).

Loriel 02-02-2010 11:52 PM

Quote:

Originally Posted by coreys (Post 1553842)
I wouldn't think so, since it will be saving it as ASCII data instead of binary data (I'm pretty sure).

What is the difference? \n?

12171217 02-03-2010 12:50 AM

There is no difference. I can generate my image via script perfectly fine, and use savestring to save it. Only problem is, it's in the scriptfiles folder.

coreys 02-03-2010 03:55 AM

Quote:

Originally Posted by Loriel (Post 1553845)
What is the difference? \n?

I guess depends on how it chooses to encode the text, but it seems it works.

Admins 02-03-2010 03:48 PM

savestring() is saving as binary, not ASCII.
Normally files saved to the scriptfiles folder should work fine as in-game image.

calani 02-14-2010 10:42 AM

Quote:

Originally Posted by Stefan
Normally files saved to the scriptfiles folder should work fine as in-game image.

They do :) and have for awhile.

Pretty handy, actually. Custom graphics generated via script. Think: seasonal images.
Would be nice to have photoshop-like features added, however, or something like ImageMagick for Perl.

12171217 02-14-2010 04:27 PM

Really? O_o..

I had images in scriptfiles and they refused to display on the client..

fowlplay4 02-14-2010 04:51 PM

Quote:

Originally Posted by 12171217 (Post 1556110)
Really? O_o..

I had images in scriptfiles and they refused to display on the client..

Same here, I declare shenanigans.

cbk1994 02-14-2010 06:11 PM

From what I understand there's a problem with the old client that prevents images from loading. In the new client it should work, though, because they are added to FILENAMECACHE when saved.


All times are GMT +2. The time now is 06:09 AM.

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