Guest Posted January 27, 2013 Share Posted January 27, 2013 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) Link to comment
Castillo Posted January 27, 2013 Share Posted January 27, 2013 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. Link to comment
Castillo Posted January 27, 2013 Share Posted January 27, 2013 Are you sure about that? because that looks like they are resources. Link to comment
Guest Posted January 27, 2013 Share Posted January 27, 2013 Here you are: http://img835.imageshack.us/img835/3021/38507693.png . Link to comment
Guest Posted January 27, 2013 Share Posted January 27, 2013 So I made a mistake. Honestly, I did not know that. ;d So, what i must do now ? Link to comment
Castillo Posted January 27, 2013 Share Posted January 27, 2013 I'm not really sure what are you trying to do. Link to comment
Guest Posted January 27, 2013 Share Posted January 27, 2013 I want to start a random map from .zip file. Link to comment
Castillo Posted January 27, 2013 Share Posted January 27, 2013 Use: getResourceFromName startResource Link to comment
Guest Posted January 27, 2013 Share Posted January 27, 2013 Ehh, i know that, but what i have to enter between the ( ) ? ;d getResourceFromName( ??? ) Link to comment
Castillo Posted January 27, 2013 Share Posted January 27, 2013 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 ) Link to comment
Guest Posted January 27, 2013 Share Posted January 27, 2013 I have a zip files in the same directory as the resource. Error: Bad argument @ 'startResource'. Link to comment
Castillo Posted January 27, 2013 Share Posted January 27, 2013 I don't understand, if these two are resource files, it should work. Link to comment
Guest Posted January 27, 2013 Share Posted January 27, 2013 First ss: http://img715.imageshack.us/img715/8458/31605268.png Second ss: http://img689.imageshack.us/img689/1264/ss2uwt.png Third ss: http://img802.imageshack.us/img802/2010/ss3pn.png Link to comment
Castillo Posted January 27, 2013 Share Posted January 27, 2013 Hold on, these .zip files are inside another resource? if so, then you can't load them. Link to comment
Guest Posted January 28, 2013 Share Posted January 28, 2013 These .zip files are inside in the same resource as function openNextMap(). Link to comment
Castillo Posted January 28, 2013 Share Posted January 28, 2013 You can't load them, you can maybe decompress the files and load them, but you can't load a .zip file. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now