Jump to content

¿que falla?


Carlossg

Recommended Posts

La gui no aparece y el debugscript 3 no muestra nada

Server side:

function getServerMaps() 
local mapsTable = {} 
    for resourceKey, resourceValue in ipairs(getResources()) do 
        local name = getResourceInfo ( resourceValue, "name" ) 
        local type = getResourceInfo ( resourceValue, "type" ) 
        local author = getResourceInfo ( resourceValue, "author" ) 
        local game = getResourceInfo ( resourceValue, "gamemodes" ) 
        if (type == "map" and game == "race") then 
            table.insert(mapsTable, {name=name, author=author or "Unknown"}) 
        end 
    end 
    return mapsTable 
end 
  
addEvent( "getServerMaps", true ) 
addEventHandler( "getServerMaps", getRootElement(), getServerMaps ) 
  

Client side:

function buyMap () 
  
    local mapas = triggerServerEvent(getServerMaps, getLocalPlayer())) 
         
      spawnScreenMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, "Welcome to map customer", true ) 
      
      spawnScreenOKButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "OK", true, spawnScreenMenu ) 
     
      guiWindowSetMovable ( spawnScreenMenu, true ) 
      guiWindowSetSizable ( spawnScreenMenu, false ) 
       
      spawnScreenGridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, spawnScreenMenu ) 
      guiGridListSetSelectionMode ( spawnScreenGridList, 2 ) 
      
      guiGridListAddColumn ( spawnScreenGridList, "Maps", 0.3 ) 
          guiSetVisible(spawnScreenMenu, false) 
      
  
     for index, map in ipairs(mapas) do 
      guiGridListSetItemText ( spawnScreenGridList, row, 1, mapsTable, false, false ) 
      end 
                 
  
end 
  
  
  
function bindTheKeys () 
        for k, v in ipairs(getElementsByType("player")) do 
                bindKey(v, "F1", "down", triggerGUI) 
        end 
end 
  
  
function bindKeyToConnectingPlayer(player) 
        if player then 
                bindKey(player, "F1", "down", triggerGUI) 
        end 
end 
  
  
function triggerGUI(key,keyState) 
        if key == "F1" and keyState == "down" then 
                guiSetVisible(spawnScreenMenu, true) 
        end 
end 
  
addEvent( "onKeyPressed", true ) 
addEventHandler( "onKeyPressed", getRootElement(), bindTheKeys ) 
  
addEvent( "bindKeyToConnectingPlayer", true ) 
addEventHandler( "bindKeyToConnectingPlayer", getRootElement(), bindKeyToConnectingPlayer ) 

Link to comment

-- client side:

spawnScreenMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, "Welcome to map customer", true ) 
guiWindowSetMovable ( spawnScreenMenu, true ) 
guiWindowSetSizable ( spawnScreenMenu, false ) 
spawnScreenOKButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "OK", true, spawnScreenMenu ) 
spawnScreenGridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, spawnScreenMenu ) 
guiGridListAddColumn ( spawnScreenGridList, "Maps", 0.3 ) 
guiSetVisible(spawnScreenMenu, false) 
  
addEvent("returnServerMaps",true) 
addEventHandler("returnServerMaps",root, 
function (mapsTable) 
    guiGridListClear(spawnScreenGridList) 
    for index, map in ipairs(mapsTable) do 
        local row = guiGridListAddRow(spawnScreenGridList) 
        guiGridListSetItemText(spawnScreenGridList,row,1,tostring(map.name),false,false) 
    end 
end) 
  
function triggerGUI() 
    guiSetVisible(spawnScreenMenu, not guiGetVisible(spawnScreenMenu)) 
    showCursor(guiGetVisible(spawnScreenMenu)) 
    if guiGetVisible(spawnScreenMenu) then 
        triggerServerEvent("getServerMaps", localPlayer) 
    end 
end 
bindKey("F1", "down", triggerGUI) 

-- server side:

function getServerMaps() 
    local mapsTable = {} 
    for resourceKey, resourceValue in ipairs(getResources()) do 
        local name = getResourceInfo ( resourceValue, "name" ) 
        local type = getResourceInfo ( resourceValue, "type" ) 
        local author = getResourceInfo ( resourceValue, "author" ) 
        local game = getResourceInfo ( resourceValue, "gamemodes" ) 
        if (type == "map" and game == "race") then 
            table.insert(mapsTable, {name=name, author=author or "Unknown"}) 
        end 
    end 
    triggerClientEvent(source,"returnServerMaps",source,mapsTable) 
end 
addEvent( "getServerMaps", true ) 
addEventHandler( "getServerMaps", getRootElement(), getServerMaps ) 

Link to comment

Funciona bien, pero no he obtenido el resultado deseado, yo esperaba obtener primero una ventana para pulsar OK y después que saliera el explorador de mapas, sin embargo, recibo el explorador directamente con el OK debajo al que no se le puede pinchar.

Otra cosa, ¿Como podría hacer para que al lado (El espacio que queda en blanco) salga la info detallada del mapa?

Link to comment

¿Así estaría bien? ¿O le he metido una patada al MTA?

spawnScreenMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, "Welcome to map customer", true ) 
guiWindowSetMovable ( spawnScreenMenu, true ) 
guiWindowSetSizable ( spawnScreenMenu, false ) 
spawnScreenOKButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "OK", true, spawnScreenMenu ) 
  
function mapas() 
spawnScreenGridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, spawnScreenMenu ) 
guiGridListAddColumn ( spawnScreenGridList, "Maps", 0.3 ) 
guiSetVisible(spawnScreenMenu, false) 
end 
  
addEventHandler ( "onClientGUIClick", spawnScreenOKButton, mapas ) 
  
addEvent("returnServerMaps",true) 
addEventHandler("returnServerMaps",root, 
function (mapsTable) 
    guiGridListClear(spawnScreenGridList) 
    for index, map in ipairs(mapsTable) do 
        local row = guiGridListAddRow(spawnScreenGridList) 
        guiGridListSetItemText(spawnScreenGridList,row,1,tostring(map.name),false,false) 
    end 
end) 
  
function triggerGUI() 
    guiSetVisible(spawnScreenMenu, not guiGetVisible(spawnScreenMenu)) 
    showCursor(guiGetVisible(spawnScreenMenu)) 
    if guiGetVisible(spawnScreenMenu) then 
        triggerServerEvent("getServerMaps", localPlayer) 
    end 
end 
bindKey("F1", "down", triggerGUI) 
function mostrar() 
guiCreateLabel( 0.15, 0.66, 0.7, 0.34, spawnScreenGridList, true) 
end 
addEventHandler ( "onClientGUIClick", spawnScreenGridList, mostrar ) 

P.D:No puedo probarlo

P.D2:¿A ti también te gusta Doctor Who?

Link to comment

Ok, intento que al pulsar F1 aparezca un mensaje , que cuando pulses OK, te lleve al explorador de mapas, que cuando pinches un mapa salga la información al lado (autor, nombre...)

P.D:Ok no te molesto más

P.D2:Yo no he visto todas las temporadas(Cuando lo hechan estoy atareado), sin embargo soy un gran fan.

P.D3:¿Sabes que van a sacar un videouego de Doctor Who?

Link to comment

Ahora la barra sale aquí:

aquig.jpg

Cuando quiero que salga aquí:

aqui2v.jpg

Para escribir en el espacio en blanco los datos detallados del mapa.

Code:

Server side:

    function getServerMaps() 
        local mapsTable = {} 
        for resourceKey, resourceValue in ipairs(getResources()) do 
            local name = getResourceInfo ( resourceValue, "name" ) 
            local type = getResourceInfo ( resourceValue, "type" ) 
            local author = getResourceInfo ( resourceValue, "author" ) 
            local game = getResourceInfo ( resourceValue, "gamemodes" ) 
            if (type == "map" and game == "race") then 
                table.insert(mapsTable, {name=name, author=author or "Unknown"}) 
            end 
        end 
        triggerClientEvent(source,"returnServerMaps",source,mapsTable) 
    end 
    addEvent( "getServerMaps", true ) 
    addEventHandler( "getServerMaps", getRootElement(), getServerMaps ) 

Client side:

spawnScreenMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, "Map Customer", true ) 
guiWindowSetMovable ( spawnScreenMenu, true ) 
guiWindowSetSizable ( spawnScreenMenu, false ) 
spawnScreenGridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, spawnScreenMenu ) 
guiGridListAddColumn ( spawnScreenGridList, "Maps", 0.3 ) 
guiSetVisible(spawnScreenMenu, false) 
  
  
addEvent("returnServerMaps",true) 
addEventHandler("returnServerMaps",root, 
function (mapsTable) 
    guiGridListClear(spawnScreenGridList) 
    for index, map in ipairs(mapsTable) do 
        local row = guiGridListAddRow(spawnScreenGridList) 
        guiGridListSetItemText(spawnScreenGridList,row,1,tostring(map.name),false,false) 
    end 
end) 
  
function triggerGUI() 
    guiSetVisible(spawnScreenMenu, not guiGetVisible(spawnScreenMenu)) 
    showCursor(guiGetVisible(spawnScreenMenu)) 
    if guiGetVisible(spawnScreenMenu) then 
        triggerServerEvent("getServerMaps", localPlayer) 
    end 
end 
bindKey("F1", "down", triggerGUI) 
  

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...