Jump to content

Get all maps from server


Overkillz

Recommended Posts

  
local maps = {} 
local resources = getResources() --https://wiki.multitheftauto.com/wiki/GetResources 
for i,v in ipairs(resources) do 
    local name = getResourceInfo(v, "name") 
    local type = getResourceInfo(v, "type") --https://wiki.multitheftauto.com/wiki/GetResourceInfo 
    if type == "map" then -- Check whether it's a map or not 
        table.insert(maps, name) 
    end 
end 
  

And in case you want to retrieve the total number of maps:

  
local total = #maps -- You're able to use # here to retrieve the table's total size (this option only works for numerical indexed tables) 
local total = table.maxn(maps) -- Same as the above but returning the largest positive numerical index 
  

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