Jump to content

how show maps name in GridList , please help


ABu-ALi_

Recommended Posts

i Search for it and i found this code :

function mapsList() 
local resourceTable = getResources() 
     for resourceKey, resourceValue in ipairs(resourceTable) do 
          local name = getResourceName(resourceValue) 
          local type = getResourceInfo ( resourceValue, "type" ) 
          if type == "map" then 
          triggerClientEvent ( "sendMaps", getRootElement(), name) 
          else 
          cancelEvent() 
        end 
    end 
end 

but what do the server client event? :(

please help me :(

Link to comment

this my client code :

function sendmaps(name) 
mapGridList = guiCreateGridList(7,12,183,350,false,tab6) 
mapsColumn = guiGridListAddColumn(mapGridList,"Maps",0.85) 
guiGridListSetSelectionMode(mapGridList,2) 
for id, name in ipairs(maps) do 
row = guiGridListAddRow ( mapGridList ) 
guiGridListSetItemText ( mapGridList, row, mapsColumn, name, false, false ) 
end 
addEventHandler( "sendMaps", mapGridList, sendmaps ) 

but , this code not working :(

please help me ... :(

Link to comment
  • Moderators

Hi,

Try this:

Server-Side:

function mapsList() 
    local resourceTable = getResources() 
    triggerClientEvent ( "clearGridList", getRootElement() ) 
    for resourceKey, resourceValue in ipairs(resourceTable) do 
          local name = getResourceName(resourceValue) 
          local type1 = getResourceInfo ( resourceValue, "type" ) 
          if type1 == "map" then 
            triggerClientEvent ( "sendMaps", getRootElement(), name) 
          else 
            cancelEvent() 
        end 
    end 
end 
addCommandHandler( "sendMaps", mapsList, false, false ) 

Client-Side:

--- Put here all your GUI and use guiSetVisible to show or hide the GUI 
mapGridList = guiCreateGridList(7,12,183,350,false,tab6) 
mapsColumn = guiGridListAddColumn(mapGridList,"Maps",0.85) 
guiGridListSetSelectionMode(mapGridList,2) 
  
addEvent("sendMaps", true ) 
function sendmaps(name) 
    row = guiGridListAddRow ( mapGridList ) 
    guiGridListSetItemText ( mapGridList, row, mapsColumn, name, false, false ) 
end 
addEventHandler( "sendMaps", getLocalPlayer(), sendmaps ) 
  
addEvent( "clearGridList", true ) 
function clearGridList() 
    guiGridListClear( mapGridList ) 
end 
addEventHandler( "clearGridList", getLocalPlayer(), clearGridList ) 

Link to comment

Try this:

-- It's serverside

function mapsList() 
    local resourceTable = getResources() 
    triggerClientEvent ( "clearGridList", getRootElement() ) 
    for resourceKey, resourceValue in ipairs(resourceTable) do 
          local name = getResourceName(resourceValue) 
          local type1 = getResourceInfo ( resourceValue, "type" ) 
          local gamemode1 = getResourceInfo ( resourceValue, "gamemodes" ) 
          if type1 == "map" and gamemode1 == "race" then 
            triggerClientEvent ( "sendMaps", getRootElement(), name) 
          else 
            cancelEvent() 
        end 
    end 
end 
addCommandHandler( "sendMaps", mapsList, false, false ) 

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