Jump to content

Get all maps from server


Overkillz

Recommended Posts

Posted

Hey everyone, I hope you can help me with these little things which I need.

Actually, I have a DM Server (Race[DM])

Im using a dx to draw how many maps there are in the server, but I don't know the functions and events to use.

If you can tell me please.

Thanks and Regards ^^

Posted
  
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 
  

Posted
exports.mapmanager:getMapsCompatibleWithGamemode(getResourceFromName("race")) 
--Or: 
exports.mapmanager:getMaps() 

Because, why would you get all resources?

Posted

For example, would be like this

  
local maplist = exports.mapmanager:getMaps() 
function isanexample() 
code.... 
code... 
dxDrawText ("Total Maps:"..maplist.." !",x,y,tocolor ( 0, 0, 0, 255 ), 1.02,255,255,255,true) 
  

Should be like this right ?

Posted

Try this:

local mapcount = exports.mapmanager:getMaps() 
--[[usage for count (To draw it):]]tostring(#mapcount) 

If this doesn't work client-side, you have to do this server-side. (Exactly the same)

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