Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-22-2007, 03:25 PM
Raeiphon Raeiphon is offline
I never asked for this.
Join Date: Jun 2005
Posts: 855
Raeiphon is on a distinguished road
GScript File Handling?

I'm currently trying to script a CRC check that works on images - basically gets the byte size of the original image and compares it to the player's image, if it's over or under, the file gets deleted and is replaced with the original, if it isn't then it goes on as normal.

I can do this fairly easily - one problem: I don't know of a command/variable that deals with files in gscript. Could someone point me towards a wiki article or the proper syntax/commands to do so? It'd be greatly appreciated.
__________________

I hope for nothing. I fear nothing. I am free.
Reply With Quote
  #2  
Old 06-22-2007, 04:53 PM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
Quote:
Originally Posted by Raeiphon View Post
I'm currently trying to script a CRC check that works on images - basically gets the byte size of the original image and compares it to the player's image, if it's over or under, the file gets deleted and is replaced with the original, if it isn't then it goes on as normal.

I can do this fairly easily - one problem: I don't know of a command/variable that deals with files in gscript. Could someone point me towards a wiki article or the proper syntax/commands to do so? It'd be greatly appreciated.
PHP Code:
// Loads the lines of a file to an array
temp.lines.clear();
temp.lines.loadLines("path/to/file");

// Saves the lines to an array
temp.line.saveLines("path/to/file"0); 
Please note that you have to give your NPC server r/w rights if you want to do both, or just read rights if you just want to read the files.
__________________
What signature? I see no signature?
Reply With Quote
  #3  
Old 06-23-2007, 05:34 AM
Raeiphon Raeiphon is offline
I never asked for this.
Join Date: Jun 2005
Posts: 855
Raeiphon is on a distinguished road
And I could do loadlines on an image file and it'd work fine? I'm doubting that alot - all I'm really after is some way of getting the byte size of the file as a variable I can manipulate a little.

Or would loadlines return the size of the file opened in bytes anyway?
__________________

I hope for nothing. I fear nothing. I am free.
Reply With Quote
  #4  
Old 06-23-2007, 06:28 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
You can do loadstring() on the image and then return length().

I never managed to get loadstring() to work, though (but I never put more then a few minutes into trying).

I personnally can hardly wait for the next client version so I can loadlines() an image clientside!
__________________
Do it with a DON!
Reply With Quote
  #5  
Old 06-24-2007, 12:29 PM
Raeiphon Raeiphon is offline
I never asked for this.
Join Date: Jun 2005
Posts: 855
Raeiphon is on a distinguished road
I tried loadlines() on an image serverside, it returned 0 when sent back in a sendrpgmessage.

I also tried loadstring(), yielding the same result.

I'm not quite sure what to do now. Could I get the byte size of the file through sockets somehow?

EDIT: Not sure the npcserver has r/w access.
__________________

I hope for nothing. I fear nothing. I am free.

Last edited by Raeiphon; 06-24-2007 at 12:39 PM..
Reply With Quote
  #6  
Old 06-24-2007, 12:54 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
You could use var.loadstring(filename) and then checksum(string) or md5(string). For getting the file size you could also simply use filesize(filename)
Reply With Quote
  #7  
Old 06-24-2007, 01:23 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Yeah, sounds like the best idea. Just checksum() or md5() the file on both the client and the server and compare. This will reduce the packet size sent in your triggeraction.

Also:
After reading your initial post again, I don't think you can do what you are trying to do just yet. You will be able to get the data on the serverside (add rights to the npcserver; that is probably your problem) but you won't be able to on the client. You gotta wait like everyone else for the new client version. :[
__________________
Do it with a DON!
Reply With Quote
  #8  
Old 06-24-2007, 01:36 PM
Raeiphon Raeiphon is offline
I never asked for this.
Join Date: Jun 2005
Posts: 855
Raeiphon is on a distinguished road
Okay, the checksum is nailed.

Now, is there any way to delete/force a client to delete/download a specific file?
__________________

I hope for nothing. I fear nothing. I am free.
Reply With Quote
  #9  
Old 06-24-2007, 01:58 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Try:
reloadfile(filename) clientside.

(http://wiki.graal.net/index.php/Crea...t/Client#Files)
__________________
Do it with a DON!
Reply With Quote
  #10  
Old 06-24-2007, 03:30 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Weird, there is no reloadfile() command, not sure who has added that.
Normally if a file is updated on serverside then it is automatically sent to the players who have already seen the file.
Reply With Quote
  #11  
Old 06-24-2007, 03:44 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Stefan View Post
Weird, there is no reloadfile() command, not sure who has added that.
Normally if a file is updated on serverside then it is automatically sent to the players who have already seen the file.
Well I do like that change you made to the file system. I always hated having to restart Graal to see changes to a file I uploaded on the server when the file wasn't a new one
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:34 AM.


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