Jump to content

[Ayuda] Tienda De Comidas


DanielZ3RO

Recommended Posts

client

  
  
------- Objetos -------- 
  
createObject ( 1571, 211.8, 1921.8, 18, 0, 0, 0 ) 
createPed ( 205, 211.8, 1921.2, 17, 180.0 ) 
tienda = createMarker ( 211.8, 1919.7, 16.7, "cylinder", 1.5, 0, 0, 255, 255 ) 
  
------- Panel De Comidas -------- 
  
addEventHandler ( "onClientMarkerHit", tienda, function(jugador) 
if jugador == getLocalPlayer() then 
  
        ventana = guiCreateWindow(103, 138, 602, 388, "Panel De Comidas", false) 
        guiWindowSetSizable(ventana, false) 
  
        img1 = guiCreateStaticImage(25, 40, 153, 116, "images/c1.png", false, ventana) 
        img2 = guiCreateStaticImage(218, 40, 164, 116, "images/c2.png", false, ventana) 
        img3 = guiCreateStaticImage(419, 40, 156, 116, "images/c3.png", false, ventana) 
        img4 = guiCreateStaticImage(25, 189, 153, 107, "images/c4.png", false, ventana) 
        img5 = guiCreateStaticImage(218, 191, 165, 105, "images/c5.png", false, ventana) 
        img6 = guiCreateStaticImage(422, 189, 153, 107, "images/c6.png", false, ventana) 
        boton1 = guiCreateButton(25, 162, 153, 21, "Ensalda Pequeña $2", false, ventana) 
        boton2 = guiCreateButton(220, 162, 153, 21, "Ensalada Grande $10", false, ventana) 
        boton3 = guiCreateButton(422, 160, 153, 21, "Pizza Personal $20", false, ventana) 
        boton4 = guiCreateButton(25, 306, 153, 21, "Pizza Jumbo $40", false, ventana) 
        boton5 = guiCreateButton(220, 306, 153, 21, "Combo Mediano $70", false, ventana) 
        boton6 = guiCreateButton(422, 306, 153, 21, "Combo Jumbo $100", false, ventana) 
        cerrar = guiCreateButton(220, 343, 153, 35, "Cerrar", false, ventana) 
  
addEventHandler ( "onClientGUIClick", boton1, comida1, false ) 
addEventHandler ( "onClientGUIClick", boton2, comida2, false ) 
addEventHandler ( "onClientGUIClick", boton3, comida3, false ) 
addEventHandler ( "onClientGUIClick", boton4, comida4, false ) 
addEventHandler ( "onClientGUIClick", boton5, comida5, false ) 
addEventHandler ( "onClientGUIClick", boton6, comida6, false ) 
addEventHandler ( "onClientGUIClick", cerrar, Exit, false ) 
        showCursor (true)  
  
    end 
end)  
  
------- Funciones -------- 
  
function Exit() 
destroyElement(ventana) 
showCursor(false) 
end 
  
function comida1() 
    triggerServerEvent ( "onComidas1", localPlayer ) 
end 
  
function comida2() 
    triggerServerEvent ( "onComidas2", localPlayer ) 
end 
  
function comida3() 
    triggerServerEvent ( "onComidas3", localPlayer ) 
end 
  
function comida4() 
    triggerServerEvent ( "onComidas4", localPlayer ) 
end 
  
function comida5() 
    triggerServerEvent ( "onComidas5", localPlayer ) 
end 
  
function comida6() 
    triggerServerEvent ( "onComidas6", localPlayer ) 
end 
  

server

  
function c1() 
setElementHealth ( source, +5 ) 
takePlayerMoney ( source, 2 ) 
end 
addEvent( "onComidas1", true ) 
addEventHandler( "onComidas1", getRootElement(), c1 ) 
  
function c2() 
setElementHealth ( source, +15 ) 
takePlayerMoney ( source, 10 ) 
end 
addEvent( "onComidas1", true ) 
addEventHandler( "onComidas1", getRootElement(), c2 ) 
  
function c3() 
setElementHealth ( source, +30 ) 
takePlayerMoney ( source, 20 ) 
end 
addEvent( "onComidas1", true ) 
addEventHandler( "onComidas1", getRootElement(), c3 ) 
  
function c4() 
setElementHealth ( source, +50 ) 
takePlayerMoney ( source, 40 ) 
end 
addEvent( "onComidas1", true ) 
addEventHandler( "onComidas1", getRootElement(), c4 ) 
  
function c5() 
setElementHealth ( source, +75 ) 
takePlayerMoney ( source, 70 ) 
end 
addEvent( "onComidas1", true ) 
addEventHandler( "onComidas1", getRootElement(), c5 ) 
  
function c6() 
setElementHealth ( source, +90 ) 
takePlayerMoney ( source, 100 ) 
end 
addEvent( "onComidas1", true ) 
addEventHandler( "onComidas1", getRootElement(), c6 ) 
  

Link to comment

tienta

client

------- Objetos -------- 
  
createObject ( 1571, 211.8, 1921.8, 18, 0, 0, 0 ) 
createPed ( 205, 211.8, 1921.2, 17, 180.0 ) 
  
------- Panel De Comidas -------- 
  
addEventHandler ( "onClientResourceStart",resourceRoot,function() 
  
        ventana = guiCreateWindow(103, 138, 602, 388, "Panel De Comidas", false) 
        guiWindowSetSizable(ventana, false) 
  
        img1 = guiCreateStaticImage(25, 40, 153, 116, "images/c1.png", false, ventana) 
        img2 = guiCreateStaticImage(218, 40, 164, 116, "images/c2.png", false, ventana) 
        img3 = guiCreateStaticImage(419, 40, 156, 116, "images/c3.png", false, ventana) 
        img4 = guiCreateStaticImage(25, 189, 153, 107, "images/c4.png", false, ventana) 
        img5 = guiCreateStaticImage(218, 191, 165, 105, "images/c5.png", false, ventana) 
        img6 = guiCreateStaticImage(422, 189, 153, 107, "images/c6.png", false, ventana) 
        boton1 = guiCreateButton(25, 162, 153, 21, "Ensalda Pequeña $2", false, ventana) 
        boton2 = guiCreateButton(220, 162, 153, 21, "Ensalada Grande $10", false, ventana) 
        boton3 = guiCreateButton(422, 160, 153, 21, "Pizza Personal $20", false, ventana) 
        boton4 = guiCreateButton(25, 306, 153, 21, "Pizza Jumbo $40", false, ventana) 
        boton5 = guiCreateButton(220, 306, 153, 21, "Combo Mediano $70", false, ventana) 
        boton6 = guiCreateButton(422, 306, 153, 21, "Combo Jumbo $100", false, ventana) 
        cerrar = guiCreateButton(220, 343, 153, 35, "Cerrar", false, ventana) 
  
addEventHandler ( "onClientGUIClick",guiRoot, comidas) 
  
end) 
  
  
function comidas(button,state) 
if (button == "left") then 
        if(source == boton1) then 
    triggerServerEvent("onClientBuyComida", localPlayer, "Ensalda Pequeña")     
        elseif(source == boton2) then 
    triggerServerEvent("onClientBuyComida", localPlayer, "Ensalada Grande") 
    elseif(source == boton3) then 
    triggerServerEvent("onClientBuyComida", localPlayer, "Pizza Personal") 
    elseif(source == boton4) then 
    triggerServerEvent("onClientBuyComida", localPlayer, "Pizza Jumbo") 
    elseif(source == boton5) then 
    triggerServerEvent("onClientBuyComida", localPlayer, "Combo Mediano") 
    elseif(source == boton6) then 
    triggerServerEvent("onClientBuyComida", localPlayer, "Combo Jumbo") 
    elseif(source == cerrar) then 
    triggerServerEvent("onClientBuyComida", localPlayer, "cerrar") 
end 
end 
end 
  
addEvent("GuiCerrarOrno",true) 
addEventHandler("GuiCerrarOrno",root, 
function() 
guiSetVisible(ventana,not guiGetVisible(ventana)) 
showCursor(not isCursorShowing()) 
end) 
  

Server

  
function comprarServer(Comida) 
local dinero = getPlayerMoney(source) 
  
    local Co1= 2 
    local Co2= 10 
    local Co3=20 
    local Co4=40 
    local Co5=70 
    local Co6=100 
  
if(Comida == "Ensalda Pequeña") then 
            if(dinero >= Co1)then 
        takePlayerMoney(source,Co1) 
setElementHealth(source,getElementHealth(source)+5) 
end 
elseif(Comida == "Ensalada Grande") then 
if(dinero >= Co2)then 
        takePlayerMoney(source,Co2) 
setElementHealth(source,getElementHealth(source)+15) 
end 
elseif(Comida == "Pizza Personal") then 
if(dinero >= Co3)then 
        takePlayerMoney(source,Co3) 
setElementHealth(source,getElementHealth(source)+30) 
end 
elseif(Comida == "Pizza Jumbo") then 
if(dinero >= Co4)then 
        takePlayerMoney(source,Co4) 
setElementHealth(source,getElementHealth(source)+50) 
end 
elseif(Comida == "Combo Mediano") then 
if(dinero >= Co5)then 
        takePlayerMoney(source,Co5) 
setElementHealth(source,getElementHealth(source)+75) 
end 
elseif(Comida == "Combo Jumbo") then 
if(dinero >= Co6)then 
        takePlayerMoney(source,Co6) 
setElementHealth(source,getElementHealth(source)+90) 
end 
elseif(Comida == "cerrar") then 
triggerClientEvent(source,'GuiCerrarOrno',source) 
end 
end 
addEvent( "onClientBuyComida", true ) 
addEventHandler( "onClientBuyComida",getRootElement(), comprarServer ) 
  
local tienda =createMarker ( 211.8, 1919.7, 16.7, "cylinder", 1.5, 0, 0, 255, 255 ) 
  
addEventHandler("onMarkerHit",tienda, 
function(E) 
if(E) and getElementType(E) == "player" then 
triggerClientEvent(E,"GuiCerrarOrno",E) 
end 
end) 

Link to comment
  • Recently Browsing   0 members

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