Jump to content

AYUDA CON GUI PANEL DE AUTOS


Recommended Posts

Posted

Hola, hace poco volví y decidí seguir aprendiendo como crear mis propios recursos, así que hice una gui sencilla para un panel de autos, una gridlist y 2 botones comprar y cerrar, como logro que al seleccionar el row y luego darle "comprar" aparezca el coche, gracias.

CLIENT:

function PANEL() 
         COMPRAR = guiCreateButton(0.41, 0.55, 0.12, 0.11, "COMPRAR", true) 
        guiSetProperty(COMPRAR, "NormalTextColour", "FFAAAAAA") 
  
  
        CERRAR = guiCreateButton(328, 251, 96, 69, "CERRAR", false) 
        addEventHandler("onClientGUIClick",CERRAR, CERRAR1) 
        guiSetProperty(CERRAR, "NormalTextColour", "FFAAAAAA") 
  
  
        LISTA = guiCreateGridList(0.17, 0.29, 0.23, 0.37, true) 
        guiGridListAddColumn(LISTA, "CARS", 0.9) 
        guiGridListAddRow(LISTA) 
        guiGridListSetItemText(LISTA, 0, 1, "BUGATTI", false, false)  
        showCursor(true)         
    end 
    addCommandHandler("carro", PANEL) 
     
    function CERRAR1 () 
    destroyElement(COMPRAR) 
    destroyElement(LISTA) 
    destroyElement(CERRAR) 
    showCursor(false) 
    end 
  
function SPAWNCAR() 
guiGridListSetSelectedItem ( LISTA, 1, 0) 
  

Posted

Agrega esto en la función SPAWNCAR

local r, c = guiGridListGetSelectedItem(gridlist) 
if (r ~= -1 and c ~= -1) then 
      -- Lo que quieres hacer. 
end 

Posted

Perfecto gracias con eso mismo pude agregar la imagen del auto, ahora quiero que se compre el coche pero no sirve lo que hice, incluso ya no me crea el auto, que esta mal?

function SPAWN_BUGATTI(thePlayer) 
local money = getPlayerMoney(thePlayer) 
if money > 300 then 
    takePlayerMoney(thePlayer, 300) 
    carro = createVehicle(tonumber(411), 528.84295654297, -1287.8753662109, 16.701047897339 ) 
    warpPedIntoVehicle(source, carro) 
    outputChatBox("Compraste un Bugatti por $50000",thePlayer, 0, 255, 0) 
    outputChatBox("¡¡GRACIAS POR TU COMPRA!!",thePlayer, 0, 255, 0)   else 
    outputChatBox("Necesitas $50000 para adquirir el vehiculo.",thePlayer, 255, 0, 0) 
    destroyElement(carro, SPAWN_BUGATTI)     
end 
end 

Posted
Reemplaza la linea seis con esto:
  
    warpPedIntoVehicle(thePlayer, carro) 
  

Pero en lugar de thePlayer sería source por como el dijo que no le crea el auto, el error estaria en el getPlayerMoney.

Posted

Bueno solucione el problema getPlayerMoney debía estar con source, ahora existe un botón que dice "matricula" y abre una ventana con un memo y el botón aceptar como logro que lo que se escriba ahí sea el nombre de la matricula del vehiculo? se que debo usar getVehiclePlateText, pero no se como lograr que el jugador cree su propia matricula.

Posted

INTENTE LO SIGUIENTE PERO NO DA RESULTADO AL HACER CLICK SOBRE EL MEMO ME CREA EL AUTO Y ME WARPEA A EL Y APARECE EL ERROR: Bad argument @ 'setVehiclePlateText' [Expected string at argument 2, got nil]

CLIENT:

function PLACAOFICIAL() 
local r, c = guiGridListGetSelectedItem(LISTCAR) 
if (r ~= 1 and c ~= 0) and MATRICULABOTON and PLACATEXT and ACEPTARPLACA then 
            triggerServerEvent("PLACA", getLocalPlayer()) 
    end 
end 

SERVER:

function SPAWN_BUGATTI(thePlayer) 
setVehiclePlateText( carro, text ) 
local money = getPlayerMoney(source) 
if money > 299 then 
    takePlayerMoney(source, 300) 
    carro = createVehicle(tonumber(411), 528.84295654297, -1287.8753662109, 16.701047897339 ) 
    warpPedIntoVehicle(source, carro) 
    outputChatBox("Compraste un Bugatti por $50000",thePlayer, 0, 255, 0) 
    outputChatBox("¡¡GRACIAS POR TU COMPRA!!",thePlayer, 0, 255, 0)   else 
    outputChatBox("Necesitas $50000 para adquirir el vehiculo.",thePlayer, 255, 0, 0) 
     
end 
end 
addEvent("SPAWN1", true) 
addEventHandler("SPAWN1", getRootElement(), SPAWN_BUGATTI ) 
addEvent("PLACA",true) 
addEventHandler("PLACA", getRootElement(),SPAWN_BUGATTI) 

Y necesito que la placa se cree antes de spawnear el auto es decir: selecciono row, boton matricula, introduzco nombre, acepto, compro, spawneo y la placa tendría el nombre que coloque anteriormente.

  • Recently Browsing   0 members

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