Jump to content

Map Shop - Race


'LinKin

Recommended Posts

Posted

Hello,

I want to make a GUI so that it displays a list of all maps compatible with Race gamemode. (Only Race).

Which stuff should I use to get those maps?

Also, to order them alphabetically in the GUI.

Thanks.

Posted

Try this:

  
local raceMaps = {} 
  
addEventHandler('onResourceStart', resourceRoot, function() 
 for index, resource in pairs(getResources()) do 
  if (getResourceInfo(resource, "type") == "map" and string.find(getResourceInfo(resource, "gamemodes") or "", "race") then 
   table.insert(raceMaps, resource) 
  end 
 end 
end) 
  

Posted

Hmm,

I remember some function that was smth like this: getMapsCompatibleWithGamemode(getRunningGamemode()).

Also, how to sort them alphabetically?

Posted

That's an exported function in the mapmanager resource, you can also use that.

Here's how to sort the raceMaps table:

table.sort(raceMaps, function(a, b) return getResourceName(b) > getResourceName(a) end) 

Not tested but should work.

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