Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Upload & Download Files with Rgss

its nice looking.. but i havent gotten to try it yet.. I get the error as well. also when I try to download the rmxp version.. it corrupts.. I havent tried vx yet.. but I am now

EDIT: nope same error corrupt zip file. I would like to use this script in my particle engine, allowing users to upload and download particles, graphics, movement paths, etc.. It will allow me to update a file on an ftp server so they just turn on the game and bam new junk XD
 
This is fantastic, really though while I was reading through this post I started to wonder, this script makes it easy to release updates and thats cool. Though is it possible to make it so that players can report a problem within the game?

I'm not by any means requesting something like that just wondering if something like it would be possible.

In case you don't know what I mean say someones playing your demo they find a TON of TERRIBLE TERRIBLE grammar... :biggrin: ... they can send you a message right in the game... say by pressing a F key or something and typing the problem within the window. Could something along those lines be done?

Lets face it I've played a few games were there where a few issues, but when I tried to report it I really didn't care enough to remember the details, while I rated the game.

EDIT :biggrin:

Sorry I was looking around a little more and noticed

InputBox Script Version: 1.3
By: Rafidelis

http://www.rmxp.org/forums/viewtopic.php?f=11&t=63074

Something like this type of input box but when you submit it sends the info to an e-mail inbox.
 
Really interesting and handy script indeed... The game design half in me wonders if games need that at all really, because I figure only a handful will be fitting for an updating feature, but the customization side wants to update my games with new graphics and scripts :]

I think the script is a little messy... also, naming modules 'berka' isn't any practical at all tbh. Other than that, well done, so keep up the good work.
 
I fixed the xp version, there were errors with the error display XD, but here it is

Code:
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

#                   Download & Upload Files with RGSS

#  par berka                      v 2.1                  rgss 1

#                         [url=http://www.rpgmakervx-fr.com  ]http://www.rpgmakervx-fr.com  [/url]                           # azirht001 bug fixes          

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

# thanks to: [url=http://www.66rpg.com]http://www.66rpg.com[/url] for documentation on wininet

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

# ! do not use ftp which contains privates data

# ! this scripts need ftp account information !

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

# Ftp :

#    â–¼ receive : 

#          Net::FTP.download("dir_on_ftp/file.zip","./Graphics")

#    â–¼ send : 

#          Net::FTP.upload("./directoryinfolder/file.exe","directoryonftp newfilename.exe")

#    â–¼ make directory : 

#          Net::FTP.mkdir("/dir_on_ftp")

# Http :

#    â–¼ receive : 

#          Net::HTTP.download("url","./Graphics")

#    â–¼ total octets downloaded : 

#          Net::HTTP.dloaded

#    â–¼ size of file : 

#          Net::HTTP.size("test.zip")

#    â–¼ % dl progress :

#          Net::HTTP.progress("test.zip")

#    â–¼ transfer time: 

#          Net::HTTP.temps("test.zip")

#    â–¼ list files : 

#          Net::HTTP.transfers

#    â–¼ file loaded? : 

#          Net::HTTP.loaded?("test.zip")

#    â–¼ octets transfered : 

#          Net::HTTP.transfered

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

module Berka

  module NetError

    ErrConIn="Unable to connect to Internet"

    ErrConFtp="Unable to connect to Ftp"

    ErrConHttp="Unable to connect to the Server"

    ErrNoFFtpIn="The file to be download doesn't exist"

    ErrNoFFtpEx="The file to be upload doesn't exist"

    ErrTranHttp="Http Download is failed"

    ErrDownFtp="Ftp Download is failed"

    ErrUpFtp="Ftp Upload is failed"

    ErrNoFile="No file to be download"

    ErrMkdir="Unable to create a new directory"

  end

end

module Net

  W='wininet'

  SPC=Win32API.new('kernel32','SetPriorityClass','pi','i').call(-1,128)

  IOA=Win32API.new(W,'InternetOpenA','plppl','l').call('',0,'','',0)

  IC=Win32API.new(W,'InternetConnectA','lplpplll','l')

  print(Berka::NetError::ConIn)if IOA==0

  module FTP

    FSCD=Win32API.new(W,'FtpSetCurrentDirectoryA','lp','l')

    FGF=Win32API.new(W,'FtpGetFileA','lppllll','l')

    FPF=Win32API.new(W,'FtpPutFile','lppll','l')

    FCD=Win32API.new(W,'FtpCreateDirectoryA','lp','l')

    module_function    

    def init

      #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#

      ftp="ftp.host.com"          #

      port=21                      #  A modifier ! 21 is default

      identifiant="username"            #

      motdepasse="password"        #

      #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#

      @fb=IC.call(IOA,ftp,port,identifiant,motdepasse,1,0,0)

      ftp,port,identifiant,motdepasse=[nil]*4 # efface les ids par sécurité

      (print(Berka::NetError::ErrConFtp))if @fb==0

    end

    def download(ext,int='./')

      init if @fb.nil?    

      c=ext.split('/').pop

      if FSCD.call(@fb,ext.gsub(c,''))!=0

        print(Berka::NetError::ErrDownFtp)if FGF.call(@fb,c,"#{int}/#{c}",0,32,2,0)==0

      else

        print(Berka::NetError::ErrNoFFtpIn)

      end

    end

    def mkdir(rep)

      init if @fb.nil?

      print(Berka::NetError::ErrMkdir)if FCD.call(@fb,rep)==0

    end

    def upload(int,ext)

      init if @fb.nil?

      if FSCD.call(@fb,ext)&&File.exist?(int)

        print(Berka::NetError::ErrUpFtp) if FPF.call(@fb,int,ext,2,0)==0

      else

        print(Berka::NetError::ErrNoFFtpEx)

      end

    end

  end

  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  module HTTP

    IOU=Win32API.new(W,'InternetOpenUrl','lppllp','l')

    IRF=Win32API.new(W,'InternetReadFile','lpip','l')

    ICH=Win32API.new(W,'InternetCloseHandle','l','l')

    HQI=Win32API.new(W,'HttpQueryInfo','llppp','i')

    module_function

    def sizeloaded(i='');@read[i];end

    def transfered;@dloaded;end

    def transfers;@dls;end

    def progress(i='');(@read[i].to_f/@size[i]*100);end

    def loaded?(i='');@read[i]>=@size[i]rescue nil;end

    def temps(i='');@tps[i]if loaded?(i);end

    def size(i='');@size[i];end

    def download(url,int='./')

      @dloaded||=0;@dls||={};@i||=-1;@size||={};@read||={};@tps={}

      a=url.split('/');serv,root,fich=a[2],a[3..a.size].join('/'),a[-1]

      print(Berka::NetError::ErrNoFile)if fich.nil?

      @dls[fich]=Thread.start(url,int){|url,int|txt='';t=Time.now

      Berka::NetError::ErrConHttp if(e=IC.call(IOA,serv,80,'','',3,1,0))==0  

      f=IOU.call(IOA,url,nil,0,0,0)

      HQI.call(f,5,k="\0"*1024,[k.size-1].pack('l'),nil)

      @read[fich],@size[fich]=0,k.delete!("\0").to_i

      loop do

        buf,n=' '*1024,0

        r=IRF.call(f,buf,1024,o=[n].pack('i!'))

        n=o.unpack('i!')[0]

        break if r&&n==0

        txt << buf[0,n]

        @read[fich]=txt.size

      end

      (File.open(int+fich,'wb')<<txt).close

      @dloaded+=@read[fich]

      ICH.call(f);sleep(0.01)

      @tps[fich]=Time.now-t}

    end

  end

end
 
Works fantasicly well Berka, great job. One question though how come the scene showing the download progress doesn't show up 100% of the time? I called it like you did in your XP demo, however it doesn't always show the bars which is quite odd. Any ideas?
 
@BlueScope : yeah, my script is quite messy, but I chose this very ugly programming to accelerate the implementation process
@Desecration : this maybe an issue about float numbers rounded.
Or, because of each trame has 1024 octets, maybe your file is too small !

thanks all !

berka
 
What type file do you want to download ?
If you receive *.rxdata files... you have to restart your game to reload the datas.
If you have zip files... you have to unzip them manually.

regards

berka
 
o, that would be amazing! with a option to make it restart itself to, like if true it uses print to tell the user that it has updated and must restart, when they press ok it restarts :)
 
Near: no, you have to download a complete rgssad file to change the encrypted game.
deathbethecost: F12 ?

thanks, guys,
berka
 
Hi berka, would you mind if my Trading script will require your script? (I'll tell people to download yours and put it above mine)

Also, I have a problem with the script. it downloads all the files perfectly, but then reports an error and the game is closed.
I think the scene doesn't detect the download has finished.
I used your RMXP demo, and just changed the .zip file download to:
Net::FTP.download('ftp://192.168.2.103/FTP/actor.trd',"./Graphics")
 
well, your syntax is wrong:

Net::FTP.download('/FTP/actor.trd',"./Graphics")
and in the script, you change the host by 192.168.2.103 (but, this is a subdomain ip !)

berka
 
Thanks, but it didn't help. Is sub-domain a bad thing? *im clueless here*
I'm using my computer as the server (using Golden-FTP). I can see & download the file when typing ftp://(my IP) on Firefox.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top