Anubhav Posted March 23, 2014 Posted March 23, 2014 Is it a way to start random map? Something with my own script? See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
HerculePoirot Posted March 23, 2014 Posted March 23, 2014 I think u should use tables and then extract a random entry from it using math.random and use the map assigned to that entry.
Anubhav Posted March 23, 2014 Author Posted March 23, 2014 I know but how should i do that? See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
cheez3d Posted March 23, 2014 Posted March 23, 2014 local maps = {} for k,resource in ipairs (getResources()) do if getResourceInfo(resource,"type") == "map" then table.insert(maps,k,resource) end end startResource(maps[math.random(1,#maps)])
Anubhav Posted March 23, 2014 Author Posted March 23, 2014 =__=. Will get the maps from each resource? I need it only for one resource name : tdmMaps See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Anubhav Posted March 23, 2014 Author Posted March 23, 2014 Lock the topic please . Did it myself! See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Moderators IIYAMA Posted March 23, 2014 Moderators Posted March 23, 2014 Before you let somebody lock it, you also can use mapmanager. function setNextRound () local mapmanager = getResourceFromName ( "mapmanager" ) if mapmanager then local maps = call (mapmanager,"getMapsCompatibleWithGamemode",thisResource) if maps then call (mapmanager,"changeGamemodeMap",maps[math.random(#maps)]) end end end Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Recommended Posts