Overkillz Posted September 1, 2014 Share Posted September 1, 2014 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 ^^ Link to comment
novo Posted September 1, 2014 Share Posted September 1, 2014 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
Et-win Posted September 1, 2014 Share Posted September 1, 2014 exports.mapmanager:getMapsCompatibleWithGamemode(getResourceFromName("race")) --Or: exports.mapmanager:getMaps() Because, why would you get all resources? Link to comment
Overkillz Posted September 1, 2014 Author Share Posted September 1, 2014 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 ? Link to comment
Et-win Posted September 1, 2014 Share Posted September 1, 2014 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) 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