SimmerMemer Posted February 24, 2014 Share Posted February 24, 2014 Hola comunidad ! Hice una tienda de armas, ahora con un marker, el problema es que no la puedo cerrar ni tampoco me funcionan los botones. Client. GUIEditor = { memo = {} } addEventHandler ( "onClientResourceStart",resourceRoot,function() ventanaArmas = guiCreateWindow(232, 74, 565, 250, "Tienda de Armas \"McCall\"", false) guiWindowSetSizable(ventanaArmas, false) botonGlock = guiCreateButton(28, 45, 146, 47, "Glock 9mm - $150", false, ventanaArmas) botonDeagle = guiCreateButton(28, 161, 146, 47, "Desert Eagle .44 - $300", false, ventanaArmas) GUIEditor.memo[1] = guiCreateMemo(331, 43, 224, 128, "Bienvenido a la Tienda de Armas \"McCall\".\n\nPor ahora solo contamos con 2 armas Glock 9mm y Desert Eagle .44\n\nLas dos armas vienen con 2 cargadores incluidos.\n", false, ventanaArmas) guiMemoSetReadOnly(GUIEditor.memo[1], true) cerrar = guiCreateButton(420, 189, 135, 51, "Cerrar", false, ventanaArmas) addEventHandler ( "onClientGUIClick",guiRoot, comprar) end ) function comprar (button,state) if (button == "left") then if(source == botonGlock) then triggerServerEvent("onClientBuyArmas", localPlayer, "glock") elseif(source == botonDeagle) then triggerServerEvent("onClientBuyArmas", localPlayer, "desert") elseif(source == cerrar) then triggerServerEvent("onClientBuyArmas", localPlayer, "cerrar") end end end addEvent("GuiCerrar",true) addEventHandler("GuiCerrar",root, function() guiSetVisible(ventana,not guiGetVisible(ventana)) showCursor(not isCursorShowing()) end) Server. function comprarServer(Armas) local dinero = getPlayerMoney(source) local Gloc= 150 local Desert= 300 if(Armas == "Glock 9mm - $150") then if(dinero >= Gloc)then takePlayerMoney(source,Gloc) giveWeapon(source, 22, 34) end elseif (Armas == "Desert Eagle .44 - $300") then if (dinero >= Desert) then takePlayerMoney(source,Desert) giveWeapon(source, 24, 14) end elseif(Armas == "cerrar") then triggerClientEvent(source,'GuiCerrar',source) end end addEvent( "onClientBuyArmas", true ) addEventHandler( "onClientBuyArmas",getRootElement(), comprarServer ) local tienda =createMarker ( -2540.3955078125, 2288.0318824219, 4.984375, "cylinder", 1.5, 0, 0, 255, 255 ) addEventHandler("onMarkerHit",tienda, function(E) if(E) and getElementType(E) == "player" then triggerClientEvent(E,"GuiCerrar",E) end end) Saludos. Link to comment
manawydan Posted February 24, 2014 Share Posted February 24, 2014 client GUIEditor = { memo = {} } addEventHandler ( "onClientResourceStart",resourceRoot,function() ventanaArmas = guiCreateWindow(232, 74, 565, 250, "Tienda de Armas \"McCall\"", false) guiWindowSetSizable(ventanaArmas, false) guiSetVisible(ventanaArmas,false) botonGlock = guiCreateButton(28, 45, 146, 47, "Glock 9mm - $150", false, ventanaArmas) botonDeagle = guiCreateButton(28, 161, 146, 47, "Desert Eagle .44 - $300", false, ventanaArmas) GUIEditor.memo[1] = guiCreateMemo(331, 43, 224, 128, "Bienvenido a la Tienda de Armas \"McCall\".\n\nPor ahora solo contamos con 2 armas Glock 9mm y Desert Eagle .44\n\nLas dos armas vienen con 2 cargadores incluidos.\n", false, ventanaArmas) guiMemoSetReadOnly(GUIEditor.memo[1], true) cerrar = guiCreateButton(420, 189, 135, 51, "Cerrar", false, ventanaArmas) addEventHandler ( "onClientGUIClick",guiRoot, comprar) end ) function comprar (button,state) if (button == "left") then if(source == botonGlock) then triggerServerEvent("onClientBuyArmas", localPlayer, "glock") elseif(source == botonDeagle) then triggerServerEvent("onClientBuyArmas", localPlayer, "desert") elseif(source == cerrar) then triggerServerEvent("onClientBuyArmas", localPlayer, "cerrar") end end end addEvent("GuiCerrar",true) addEventHandler("GuiCerrar",root, function() guiSetVisible(ventanaArmas,not guiGetVisible(ventanaArmas)) showCursor(not isCursorShowing()) end) server function comprarServer(Armas) local dinero = getPlayerMoney(source) local Gloc= 150 local Desert= 300 if(Armas == "glock") then if(dinero >= Gloc)then takePlayerMoney(source,Gloc) giveWeapon(source, 22, 34) end elseif (Armas == "desert") then if (dinero >= Desert) then takePlayerMoney(source,Desert) giveWeapon(source, 24, 14) end elseif(Armas == "cerrar") then triggerClientEvent(source,'GuiCerrar',source) end end addEvent( "onClientBuyArmas", true ) addEventHandler( "onClientBuyArmas",getRootElement(), comprarServer ) local tienda =createMarker ( -2540.3955078125, 2288.0318824219, 4.984375, "cylinder", 1.5, 0, 0, 255, 255 ) addEventHandler("onMarkerHit",tienda, function(E) if(E) and getElementType(E) == "player" then triggerClientEvent(E,"GuiCerrar",E) end end) Has enviado un texto al servidor y tratado de tomar un texto diferente enviado. por lo que no funcionó Link to comment
SimmerMemer Posted February 26, 2014 Author Share Posted February 26, 2014 Gracias Me base en tu script de comidas jaja, espero que no te moleste. Link to comment
Recommended Posts