Jump to content

SOLVED


joaosilva099

Recommended Posts

Hi all...

I Have this SIMPLE script to download and replace vehicle mods:

function replaceModel()  
   
  txd = engineLoadTXD("429.txd", 429 ) 
  engineImportTXD(txd, 429) 
  dff = engineLoadDFF("429.dff", 429 ) 
  engineReplaceModel(dff, 429) 
  
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceModel) 

But the problem is that with more mods i add it is raising the ammount of MB that the player has to download.

That script downloads mods and after that the player can join the game

I want is a script that only downloads the mods when the player logs in so that he can play same time the mods are downloading...

Hope u can help me

Thanks!

Edited by Guest
Link to comment

You can try to use this script, but I didn't test it

local files = {  
    ["files/mydff.dff"] = { id=400, type="dff" }, 
    ["files/mytxd.txd"] = { id=400, type="txd" }, 
} 
  
for i, v in pairs ( files ) do 
    downloadFile ( i )  
end 
  
  
addEventHandler ( "onClientFileDownloadComplete", root, function ( _, success ) 
    if ( success ) then 
        local allDone = true 
        for i, v in pairs ( files ) do  
            if ( not fileExists ( i ) ) then 
                allDone = false  
                break  
            end  
        end 
        if ( allDone ) then 
            for i, v in pairs( files ) do 
                local v.type = tostring ( v.type ):lower ( ) 
                if ( v.type == "dff" ) then 
                    local dff = engineLoadDFF ( i, 0 ) 
                    if ( not dff or not engineReplaceModel ( dff, v.id ) ) then 
                        outputDebugString ( "Failed to replace ".. tostring ( i  ).. " (Loading file as .dff | Tryed to replace model "..tostring(v.id)..")" ) 
                    end 
                elseif ( v.type == 'txd' ) then 
                    local txd = engineLoadTXD ( i ) 
                    if ( not txd or not engineImportTXD ( txd, v.id ) ) then 
                        outputDebugString ( "Failed to replace ".. tostring ( i  ).. " (Loading file as .txd | Tryed to replace model "..tostring(v.id)..")" ) 
                    end  
                else 
                    outputDebugString ( "Failed to replace ".. tostring ( i  ).. " (Unknown type -> Allowed: txd, dff)" ) 
                end 
            end  
        end 
    end  
end ) 

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...