Jump to content

Image when downloading


Axel

Recommended Posts

You can set the image resource as map and everything else as script/gamemode/misc, as maps downloads before the scripts.

Then use a timer or so to check every sec maybe if it's done, unless it's a event for that.

And kill the timer when it finds out that it's done.

Edit: Removed lua.

Was never ment to be a copy/paste script, just an idea for how it could be done.

Edited by Guest
Link to comment

Example

  
local nWidth, nHeight = guiGetScreenSize( ) 
local sImage = 'image.png' 
  
local tDownloadFiles = 
{ 
    'car.txd'; 
    'car.dff'; 
    -- ... 
} 
  
local fDraw = function( ) 
    dxDrawImage( 0.5 * nWidth, 0.5 * nHeight, 0.5 * nWidth, 0.5 * nHeight, sImage ) 
end 
  
addEventHandler( 'onClientFileDownloadComplete', root, 
    function( sFile, bSucces ) 
        if sFile == sImage and bSucces then 
            addEventHandler( 'onClientRender', root, fDraw ) 
            for _, s in ipairs( tDownloadFiles ) do 
                downloadFile( s ) 
            end 
        elseif sFile == tDownloadFiles[1] then   
            local uTxd = engineLoadTXD ( sFile ) 
            engineImportTXD ( uTxd, 587 ) 
        elseif sFile == tDownloadFiles[2] then   
            local uDff = engineLoadDFF ( sFile, 587 ) 
            engineReplaceModel ( uDff, 587 ) 
        end 
    end 
) 
  
addEventHandler( 'onClientResourceStart', resourceRoot, 
    function( ) 
        downloadFile( sImage ) 
    end 
) 

meta.xml

  
<meta> 
    <script src='c.lua' type='client' /> 
     
    <file src='image.png' download='false' /> 
    <file src='car.txd' download='false' /> 
    <file src='car.dff' download='false' /> 
</meta> 

downloadFile

This function downloads a file from the HTTP server. This can only be used on files on the HTTP server associated with the MTA server and will only download files from within the folder of the resource that is calling it. The file should also be included in meta.xml with the download attribute set to "false", see meta.xml for more details. If the file has been previously downloaded and the CRC matches, the file will not be downloaded again but onClientFileDownloadComplete will still run.

Who want test it

http://www.getzilla.net/files/3280297/testing.rar.html

http://depositfiles.com/files/v2yqqj3ag

Updated

Link to comment
It seems to work, it has nothing related to version in the wiki.
FROM VERSION 1.3.1 ONWARDS

- downloadFile

the latest stable version is 1.3.0.

I tested your script Kenix but downloadFile didn't work, and the files were downloaded as normally before the script started.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...