Carlossg Posted February 5, 2012 Posted February 5, 2012 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 )
Castillo Posted February 5, 2012 Posted February 5, 2012 -- 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 )
Carlossg Posted February 6, 2012 Author Posted February 6, 2012 sigue sin funcionar y sin errores en debugscript3
Castillo Posted February 6, 2012 Posted February 6, 2012 Copia el client side de nuevo, arregle un error.
Carlossg Posted February 7, 2012 Author Posted February 7, 2012 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?
Castillo Posted February 7, 2012 Posted February 7, 2012 Estudia el script para agregar los datos del mapa.
Carlossg Posted February 7, 2012 Author Posted February 7, 2012 Si, lo que me falta es obtener a que mapa le he pinchado.
Carlossg Posted February 7, 2012 Author Posted February 7, 2012 Ok, otra cosa¿como puedo vaciar ( el texto) la gui para volver a poner texto?
Castillo Posted February 7, 2012 Posted February 7, 2012 Decis borrar los datos de la grid list? si es asi, usa: guiGridListClear
Carlossg Posted February 7, 2012 Author Posted February 7, 2012 ¿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?
Castillo Posted February 7, 2012 Posted February 7, 2012 Eso no tiene sentido. No se que intentas hacer, pero ahora no puedo ayudarte. P.D: Me parece que ya te ayude bastante. P.D2: Ya mire la serie entera del 2005 unas 4 veces (las 6 temporadas).
Carlossg Posted February 7, 2012 Author Posted February 7, 2012 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?
Carlossg Posted February 9, 2012 Author Posted February 9, 2012 Ahora la barra sale aquí: Cuando quiero que salga aquí: 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)
Recommended Posts