Jump to content

Get all server map's name.


Feche1320

Recommended Posts

i guess you have a grid list, right?

then you have to trigger an event when you open the panel/change tab:

server side:

  
function mapsList() 
local resourceTable = getResources() 
     for resourceKey, resourceValue in ipairs(resourceTable) do 
          local name = getResourceName(resourceValue) 
          local type = getResourceInfo ( resourceValue, "type" ) 
          local game = getResourceInfo ( resourceValue, "gamemodes" ) 
          if type == "map" and game == "race" then 
          triggerClientEvent ( "sendMaps", getRootElement(), name) 
          else 
          cancelEvent() 
        end 
    end 
end 
addEvent("getMaps", true) 
addEventHandler("getMaps", getRootElement(), mapsList) 

then you will send them to client side:

addEvent("sendMaps", true) 
addEventHandler("sendMaps", getRootElement(), 
function (name) 
local row = guiGridListAddRow(buyMapGrid) 
guiGridListSetItemText ( buyMapGrid, row, 1, name, false, false ) 
end) 

Link to comment

server side (modified Castillo's):

  
function mapsList() 
    for k, v in ipairs(getResources()) do 
        if getResourceInfo(v,"type") == "map" then 
            triggerClientEvent("sendMaps",getRootElement(),getResourceName(v)) 
        end 
    end 
end 
addEvent("getMaps", true) 
addEventHandler("getMaps",getRootElement(),mapsList) 

@Castillo: I wouldn't use 'type' as a variable, since it's a built-in lua function.

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