Jump to content

Open a map from .zip file ?


Guest Guest26901

Recommended Posts

Posted

Hey all !

How to open map from .zip file ? I did something like this:

  
local files = { "maps/edos.zip", "maps/shootermcqueen.zip" } 
  
function openNextMap() 
    local randomFile = files[math.random(#files)] 
    --local hFile = fileOpen(randomFile, true) 
    if randomFile then 
        outputDebugString("File opened! //random_maps.lua") 
        startResource(randomFile) 
    else 
        outputDebugString("Unable to open files - maps! //random_maps.lua") 
    end 
end 
addEventHandler("onResourceStart", getRootElement(), openNextMap) 
  

Posted

You don't need to define the folder, nor the .zip, also, these are resource names or file names? because you need to specify the file name to open.

Posted

So I made ​​a mistake. Honestly, I did not know that. ;d So, what i must do now ?

Posted

Ehh, i know that, but what i have to enter between the ( ) ? ;d

getResourceFromName( ??? )

Posted
local resources = { "edos", "shootermcqueen" } 
  
function openNextMap ( ) 
    local randomResource = resources [ math.random ( #resources ) ] 
    if ( randomResource ) then 
        outputDebugString ( "File opened! //random_maps.lua" ) 
        startResource ( getResourceFromName ( randomResource ) ) 
    else 
        outputDebugString ( "Unable to open files - maps! //random_maps.lua" ) 
    end 
end 
addEventHandler ( "onResourceStart", resourceRoot, openNextMap ) 

Posted

I have a zip files in the same directory as the resource. Error: Bad argument @ 'startResource'.

Posted

These .zip files are inside in the same resource as function openNextMap().

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