Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- begin
- class GTS_Scene
- def pbStartScene
- @sprites={}
- @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z=99999
- @sprites["overlay"]=Sprite.new(@viewport)
- @sprites["overlay"].bitmap=Bitmap.new(Graphics.width,Graphics.height)
- @sprites["overlay"].z=9999999
- pbSetSystemFont(@sprites["overlay"].bitmap)
- @overlay = @sprites["overlay"].bitmap
- @baseColor=Color.new(0,0,0)
- @shadowColor=Color.new(208-40,208-40,200-40)
- end
- def pbEndScene
- @viewport.dispose
- end
- def pbUpdate
- $mouse.update
- Graphics.update
- Input.update
- end
- def pbChooseCommand(commands,cancel=false)
- @commands=commands
- @cancel=cancel
- @command_window = Window_CommandPokemon.new(@commands,160)
- @command_window.index = 0
- height=(@commands.length*64)-(28*(@commands.length-1))
- if height<384-124
- @command_window.height=height
- else
- @command_window.height=384-124
- end
- @command_window.width=400
- @command_window.x = Graphics.width
- @command_window.y = (Graphics.height/2)-(@command_window.height/2)
- 10.times do
- @command_window.x-=@command_window.width/10
- pbWait(1)
- end
- loop do
- if Input.trigger?(Input::UP) && @command_window.index>0
- @command_window.index-=1
- pbWait(6)
- end
- if Input.trigger?(Input::DOWN) && @command_window.index<(@command_window.commands.length-1)
- @command_window.index+=1
- pbWait(6)
- end
- if Input.trigger?(Input::C)
- 10.times do
- @command_window.x+=@command_window.width/10
- pbWait(1)
- end
- return @command_window.index
- end
- if Input.trigger?(Input::B) && @cancel==true
- 10.times do
- @command_window.x+=@command_window.width/10
- pbWait(1)
- end
- @command_window.dispose
- return -1
- end
- pbUpdate
- end
- end
- def pbGTS(temp)
- gtsfile="./Data/GTS.rxdata"
- target="http://yourhost.com/FTP location/GTS.rxdata"
- File.delete(gtsfile) if FileTest.exist?(gtsfile)
- pbDownloadToFile(target,gtsfile)
- @file=gtsfile
- Kernel.pbMessage(_INTL("Welcome to the GTS!"))
- if FileTest.exist?(@file)
- global=$PokemonGlobal
- File.open(@file){|f|
- $PokemonGlobal.GTS = Marshal.load(f)
- }
- @gtsdata=$PokemonGlobal.GTS
- $PokemonGlobal=global
- trade=false
- index=0
- i=0
- (@gtsdata.length).times do
- trade=true if @gtsdata[i][0][1]==$Trainer.id && @gtsdata[i][3]==true
- index=i if @gtsdata[i][0][1]==$Trainer.id && @gtsdata[i][3]==true
- i+=1
- end
- if trade==true
- Kernel.pbMessage(_INTL("You have a trade pending."))
- if $Trainer.party.length<6
- $Trainer.party.push(@gtsdata[index][1])
- Kernel.pbMessage(_INTL("You recieved {1}'s {2}.",@gtsdata[index][0][0],@gtsdata[index][1].name))
- @gtsdata.delete_at(index)
- $PokemonGlobal.GTS=@gtsdata
- File.open(@file,"wb"){|f|
- Marshal.dump($PokemonGlobal.GTS,f)
- }
- Net::FTP.upload(@file,"GTS.rxdata")
- $PokemonGlobal.GTS=[]
- else
- Kernel.pbMessage(_INTL("Please free up a Pokemon Slot in your party to proceed."))
- end
- end
- end
- Kernel.pbMessage(_INTL("What would you like to do?"))
- @choice=pbChooseCommand(["Put a Pokemon up for Trade","Trade a Pokemon already listed"],true)
- case @choice
- when 0
- Kernel.pbMessage(_INTL("Please select a Pokemon to put up for trade."))
- commands=[]
- i=0
- ($Trainer.party.length).times do
- commands.push($Trainer.party[i].name)
- i+=1
- end
- i=pbChooseCommand(commands)
- @trainer=[$Trainer.name,$Trainer.id,$Trainer.outfit]
- @pokemon=$Trainer.party[i]
- $Trainer.party.delete_at(i)
- Kernel.pbMessage(_INTL("Please type the number of the Species you'd like in return."))
- species=(pbEnterText("Pokemon Number:",1,3,"")).to_i
- Kernel.pbMessage(_INTL("Please type its level."))
- level=(pbEnterText("Pokemon Level:",1,3,"")).to_i
- if Kernel.pbConfirmMessage(_INTL("Would you like a shiny version of that Pokemon?"))
- shiny=true
- else
- shiny=false
- end
- @gtsentry=[@trainer,@pokemon,[species,level],false]
- if FileTest.exist?(@file)
- global=$PokemonGlobal
- File.open(@file){|f|
- $PokemonGlobal.GTS = Marshal.load(f)
- }
- @gtsdata=$PokemonGlobal.GTS
- $PokemonGlobal=global
- @gtsdata.push(@gtsentry)
- $PokemonGlobal.GTS=@gtsdata
- File.open(@file,"wb"){|f|
- Marshal.dump($PokemonGlobal.GTS,f)
- }
- Net::FTP.upload(@file,"GTS.rxdata")
- Kernel.pbMessage(_INTL("Your Trade request has been sent!"))
- $PokemonGlobal.GTS=[]
- else
- @gtsdata=[]
- @gtsdata.push(@gtsentry)
- $PokemonGlobal.GTS=@gtsdata
- File.open(@file,"wb"){|f|
- Marshal.dump($PokemonGlobal.GTS,f)
- }
- Net::FTP.upload(@file,"GTS.rxdata")
- Kernel.pbMessage(_INTL("Your Trade request has been sent!"))
- $PokemonGlobal.GTS=[]
- end
- when 1
- ret=nil
- if FileTest.exist?(@file)
- global=$PokemonGlobal
- File.open(@file){|f|
- $PokemonGlobal.GTS = Marshal.load(f)
- }
- @gtsdata=$PokemonGlobal.GTS
- $PokemonGlobal=global
- end
- if FileTest.exist?(@file) && @gtsdata.length>0
- Kernel.pbMessage(_INTL("Which Pokemon would you like to trade with?"))
- global=$PokemonGlobal
- File.open(@file){|f|
- $PokemonGlobal.GTS = Marshal.load(f)
- }
- @gtsdata=$PokemonGlobal.GTS
- $PokemonGlobal=global
- commands=[]
- i=0
- (@gtsdata.length).times do
- commands.push(@gtsdata[i][1].name)
- i+=1
- end
- i=pbChooseCommand(commands)
- @i2=i
- @tradepoke=@gtsdata[i][1]
- @requestpoke=@gtsdata[i][2]
- if @gtsdata[i][3]==true
- Kernel.pbMessage(_INTL("That trade has already been completed"))
- else
- loop do
- Kernel.pbMessage(_INTL("Please offer up a Pokemon for trade."))
- commands=[]
- i=0
- ($Trainer.party.length).times do
- commands.push($Trainer.party[i].name)
- i+=1
- end
- @i=pbChooseCommand(commands,true)
- @yourpoke=$Trainer.party[@i] if @i>-1
- if @yourpoke && @yourpoke.species==@requestpoke[0] && @yourpoke.level>=@requestpoke[1]
- Kernel.pbMessage(_INTL("The Trade will now begin."))
- $Trainer.party[@i]=@tradepoke
- @gtsdata[@i2][1]=@yourpoke
- @gtsdata[@i2][3]=true
- $PokemonGlobal.GTS=@gtsdata
- File.open(@file,"wb"){|f|
- Marshal.dump($PokemonGlobal.GTS,f)
- }
- Net::FTP.upload(@file,"GTS.rxdata")
- Kernel.pbMessage(_INTL("The Trade was successful"))
- $PokemonGlobal.GTS=[]
- break
- else
- Kernel.pbMessage(_INTL("Your Pokemon does not match the requirements.")) if @i>-1
- end
- break if @i==-1
- end
- end
- else
- Kernel.pbMessage(_INTL("There currently isn't any GTS data online."))
- end
- when -1
- Kernel.pbMessage(_INTL("We hope to see you again."))
- end
- end
- end
- class GTS
- def initialize(scene)
- @scene=scene
- end
- def pbStartScreen(temp=nil)
- @scene.pbStartScene
- @scene.pbGTS(temp)
- @scene.pbEndScene
- end
- end
- rescue Exception
- if $!.is_a?(SystemExit) || "#{$!.class}"=="Reset"
- raise $!
- else
- end
- end
- # Net module done by Berka
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # Download & Upload Files with RGSS
- # par berka v 2.1 rgss 1
- # [url="http://www.rpgmakervx-fr.com "]http://www.rpgmakervx-fr.com [/url]
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # 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("./Graphics/file.zip","§dir_on_ftp/file.zip")
- # �–� make directory :
- # Net::Ftp.mkdir("/dir_on_ftp")
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- 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::NetErrorErr::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.yourhost.com" #
- port=21 # A modifier !
- 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::NetErrorErr::ErrDownFtp)if FGF.call(@fb,c,"#{int}/#{c}",0,32,2,0)==0
- else
- print(Berka::NetErrorErr::ErrNoFFtpIn)
- end
- end
- def mkdir(rep)
- init if @fb.nil?
- print(Berka::NetErrorErr::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::NetErrorErr::ErrUpFtp)if FPF.call(@fb,int,ext,2,0)==0
- else
- print(Berka::NetErrorErr::ErrNoFFtpEx)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement