#Horus Posted January 7, 2019 Share Posted January 7, 2019 Eu queria separar as funções de um script de bar ( Separar uma função pra cada bebida, Catuaba, Vodca e Cerveja ) pois é muito desorganizado e tambem porque coloquei um painel novo nesse script... ja tentei varias e varias vezes e todas deram errado; c.lua ( A Parte das funções que quero separar Antes ) Esse aqui funciona normalmente, mas o proximo que eu separei não funciona.. function clickEffectDrink(button,state) if button == "left" and state == "up" then if isMouseInPosition(drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY, drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 200) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY, drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 150) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY, drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 100) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseH) then if isEventHandlerAdded("onClientRender", root, drawDrinks) and isEventHandlerAdded("onClientClick", root, clickEffectDrink) then removeEventHandler("onClientRender", root, drawDrinks) removeEventHandler("onClientClick", root, clickEffectDrink) showCursor(false) end end end end c.lua ( Aqui eu refiz separando as funções das bebidas Catuaba, Vodca e Cerveja, adicionei algumas coisas a mais porque como eu disse, mudei o painel. ) function Catuaba(_,state) if isEventHandlerAdded("onClientRender", root, drawDrinks) then if state == "down" then if isCursorOnElement(screenW * 0.3522, screenH * 0.4714, screenW * 0.4632, screenH * 0.5143) then if (not isTimer(timerExpireDrinks)) then setBlur(false) triggerServerEvent("server:onPlayerBuyDrinkBVS", localPlayer, 200) removeEventHandler("onClientRender", root, drawDrinks) showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) else playSound("sfx/hit.mp3", false) outputChatBox("#1066E7Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end end end end end addEventHandler("onClientClick", root, Catuaba) function Vodca(_,state) if isEventHandlerAdded("onClientRender", root, drawDrinks) then if state == "down" then if isCursorOnElement(screenW * 0.3522, screenH * 0.4714, screenW * 0.4632, screenH * 0.5143) then if (not isTimer(timerExpireDrinks)) then setBlur(false) triggerServerEvent("server:onPlayerBuyDrinkBVS", localPlayer, 150) removeEventHandler("onClientRender", root, drawDrinks) showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) else playSound("sfx/hit.mp3", false) outputChatBox("#1066E7Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end end end end end addEventHandler("onClientClick", root, Vodca) function Cerveja(_,state) if isEventHandlerAdded("onClientRender", root, drawDrinks) then if state == "down" then if isCursorOnElement(screenW * 0.3522, screenH * 0.4714, screenW * 0.4632, screenH * 0.5143) then if (not isTimer(timerExpireDrinks)) then setBlur(false) triggerServerEvent("server:onPlayerBuyDrinkBVS", localPlayer, 100) removeEventHandler("onClientRender", root, drawDrinks) showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) else playSound("sfx/hit.mp3", false) outputChatBox("#1066E7Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end end end end end addEventHandler("onClientClick", root, Cerveja) Oque há de errado no script ? se puderem me informar o erro como sempre agradeço irmãos! Link to comment
Other Languages Moderators Lord Henry Posted January 7, 2019 Other Languages Moderators Share Posted January 7, 2019 12 minutes ago, #Horus said: Oque há de errado no script ? Começando pela indentação. Link to comment
#Horus Posted January 7, 2019 Author Share Posted January 7, 2019 (edited) 8 minutes ago, Lord Henry said: Começando pela indentação. Lord você acha melhor mandar o client e o server dos dois pra facilitar ? Porque aí vocês já veem as exportações e os triggers do server e do client Edited January 7, 2019 by #Horus Link to comment
Other Languages Moderators Lord Henry Posted January 7, 2019 Other Languages Moderators Share Posted January 7, 2019 Facilitaria bem mais se vc corrigisse a indentação dos códigos. Mas mandar o resto tbm ajuda. Link to comment
Jonas^ Posted January 7, 2019 Share Posted January 7, 2019 A mania da galera de fazer um código de qualquer jeito, acho que não é só eu que tenho toque kkkk, me da agonia ver um código todo mal indentado ahsuasuhauhssauh Link to comment
#Horus Posted January 7, 2019 Author Share Posted January 7, 2019 (edited) 14 minutes ago, Lord Henry said: Facilitaria bem mais se vc corrigisse a indentação dos códigos. Mas mandar o resto tbm ajuda. Bar original c.lua local sWidth, sHeight = guiGetScreenSize() local drawDrinksBVS = {} drawDrinksBVS.bgX = sWidth / 2 - 200 drawDrinksBVS.bgY = sHeight / 2 - 200 drawDrinksBVS.bgW = 400 drawDrinksBVS.bgH = 250 drawDrinksBVS.bgTopBarX = sWidth / 2 - 200 drawDrinksBVS.bgTopBarY = sHeight / 2 - 200 drawDrinksBVS.bgTopBarW = 400 drawDrinksBVS.bgTopBarH = 50 drawDrinksBVS.bgCloseX = sWidth / 2 - 200 drawDrinksBVS.bgCloseY = sHeight / 2 - 200 drawDrinksBVS.bgCloseW = 50 drawDrinksBVS.bgCloseH = 50 drawDrinksBVS.bgCatuabaX = sWidth / 2 - 170 drawDrinksBVS.bgCatuabaY = sHeight / 2 - 120 drawDrinksBVS.bgCatuabaW = 96 drawDrinksBVS.bgCatuabaH = 96 drawDrinksBVS.bgVodkaX = sWidth / 2 - 50 drawDrinksBVS.bgVodkaY = sHeight / 2 - 120 drawDrinksBVS.bgVodkaW = 96 drawDrinksBVS.bgVodkaH = 96 drawDrinksBVS.bgCervejaX = sWidth / 2 + 70 drawDrinksBVS.bgCervejaY = sHeight / 2 - 120 drawDrinksBVS.bgCervejaW = 96 drawDrinksBVS.bgCervejaH = 96 BarBVS = {} BarBVS.peds = {} BarBVS.pedsPos = { {240, 498.4, -77.9, 998.7, 11, 1}, {240, 498.4, -77.9, 998.7, 11, 2}, {240, 498.4, -77.9, 998.7, 11, 3}, {240, 498.4, -77.9, 998.7, 11, 4}, {240, 498.4, -77.9, 998.7, 11, 5}, {240, 498.4, -77.9, 998.7, 11, 6}, } BarBVS.markers = {} BarBVS.markersPos = { {498.4, -75.7, 997.7, 11, 1}, {498.4, -75.7, 997.7, 11, 2}, {498.4, -75.7, 997.7, 11, 3}, {498.4, -75.7, 997.7, 11, 4}, {498.4, -75.7, 997.7, 11, 5}, {498.4, -75.7, 997.7, 11, 6}, } function startClientDrinks() for k, v in pairs(BarBVS.pedsPos) do local id = #BarBVS.peds + 1 BarBVS.peds[id] = createPed(v[1], v[2], v[3], v[4]) setElementInterior(BarBVS.peds[id], v[5]) setElementDimension(BarBVS.peds[id], v[6]) addEventHandler("onClientPedDamage", BarBVS.peds[id], function() cancelEvent() end) setElementData(BarBVS.peds[id], "Ped:Msg", "Que tal uma bebida?") addEventHandler("onClientRender", getRootElement(), function() setSellerLookAt(BarBVS.peds[id]) end) end for k, v in pairs(BarBVS.markersPos) do local id = #BarBVS.markers + 1 BarBVS.markers[id] = createMarker(v[1], v[2], v[3], "cylinder", 1, 30, 180, 65, 200) setElementInterior(BarBVS.markers[id], v[4]) setElementDimension(BarBVS.markers[id], v[5]) addEventHandler('onClientMarkerHit', BarBVS.markers[id], function(player) if player == localPlayer then if not isEventHandlerAdded("onClientRender", root, drawDrinks) and not isEventHandlerAdded("onClientClick", root, clickEffectDrink) then addEventHandler("onClientRender", root, drawDrinks) addEventHandler("onClientClick", root, clickEffectDrink) showCursor(true) end end end) addEventHandler('onClientMarkerLeave', BarBVS.markers[id], function(player) if player == localPlayer then if isEventHandlerAdded("onClientRender", root, drawDrinks) and isEventHandlerAdded("onClientClick", root, clickEffectDrink) then removeEventHandler("onClientRender", root, drawDrinks) removeEventHandler("onClientClick", root, clickEffectDrink) showCursor(false) end end end) end end addEventHandler("onClientResourceStart", resourceRoot, startClientDrinks) function drawDrinks() dxDrawRectangle(drawDrinksBVS.bgX, drawDrinksBVS.bgY, drawDrinksBVS.bgW, drawDrinksBVS.bgH, tocolor(0, 0, 0, 180)) dxDrawRectangle(drawDrinksBVS.bgX-2, drawDrinksBVS.bgY-2, drawDrinksBVS.bgW+4, drawDrinksBVS.bgH+4, tocolor(0, 0, 0, 150)) dxDrawRectangle(drawDrinksBVS.bgTopBarX, drawDrinksBVS.bgTopBarY, drawDrinksBVS.bgTopBarW, drawDrinksBVS.bgTopBarH, tocolor(30, 180, 65, 200)) closeDrinksAplha = isMouseInPosition(drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseH) and 255 or 180 dxDrawRectangle(drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseH, tocolor(255, 0, 0, closeDrinksAplha)) dxDrawText("X", drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseX+drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseY+drawDrinksBVS.bgCloseH, tocolor(255,255,255,255), 2, "pricedown", "center", "center") dxDrawText("BEBIDAS", drawDrinksBVS.bgX, drawDrinksBVS.bgY - 200, drawDrinksBVS.bgX+drawDrinksBVS.bgW, drawDrinksBVS.bgY+drawDrinksBVS.bgH, tocolor(255,255,255,255), 1.5, "pricedown", "center", "center") if isMouseInPosition(drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY, drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaH) then dxDrawImage(drawDrinksBVS.bgCatuabaX-1, drawDrinksBVS.bgCatuabaY-1, drawDrinksBVS.bgCatuabaW+2, drawDrinksBVS.bgCatuabaH+2, "files/icon.png") end dxDrawImage(drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY, drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaH, "files/icon.png") dxDrawText("CATUABA", drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY + 120, drawDrinksBVS.bgCatuabaX+drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaY+drawDrinksBVS.bgCatuabaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") dxDrawText("200$", drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY + 170, drawDrinksBVS.bgCatuabaX+drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaY+drawDrinksBVS.bgCatuabaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") if isMouseInPosition(drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY, drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaH) then dxDrawImage(drawDrinksBVS.bgVodkaX-1, drawDrinksBVS.bgVodkaY-1, drawDrinksBVS.bgVodkaW+2, drawDrinksBVS.bgVodkaH+2, "files/icon.png") end dxDrawImage(drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY, drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaH, "files/icon.png") dxDrawText("VODKA", drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY + 120, drawDrinksBVS.bgVodkaX+drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaY+drawDrinksBVS.bgVodkaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") dxDrawText("150$", drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY + 170, drawDrinksBVS.bgVodkaX+drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaY+drawDrinksBVS.bgVodkaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") if isMouseInPosition(drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY, drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaH) then dxDrawImage(drawDrinksBVS.bgCervejaX-1, drawDrinksBVS.bgCervejaY-1, drawDrinksBVS.bgCervejaW+2, drawDrinksBVS.bgCervejaH+2, "files/icon.png") end dxDrawImage(drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY, drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaH, "files/icon.png") dxDrawText("CERVEJA", drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY + 120, drawDrinksBVS.bgCervejaX+drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaY+drawDrinksBVS.bgCervejaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") dxDrawText("100$", drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY + 170, drawDrinksBVS.bgCervejaX+drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaY+drawDrinksBVS.bgCervejaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") end function clickEffectDrink(button,state) if button == "left" and state == "up" then if isMouseInPosition(drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY, drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 200) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY, drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 150) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY, drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 100) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseH) then if isEventHandlerAdded("onClientRender", root, drawDrinks) and isEventHandlerAdded("onClientClick", root, clickEffectDrink) then removeEventHandler("onClientRender", root, drawDrinks) removeEventHandler("onClientClick", root, clickEffectDrink) showCursor(false) end end end end function currentEffectDrinks() ---------------------------------------------------------- timerControlDrinks = setTimer(function() setPedControlState(localPlayer, "walk", true) end, 100, 0) setWindVelocity(100, 100, 0) setCameraShakeLevel(255) ---------------------------------------------------------- timerExpireDrinks = setTimer(function() ---------------------------------------------------------- resetWindVelocity() setCameraShakeLevel(1) if isTimer(timerControlDrinks) then killTimer(timerControlDrinks) end setPedControlState(localPlayer, "walk", false) outputChatBox("O efeito da bebida acabou.", 0, 255, 0) triggerServerEvent("resetWalkingStyle",resourceRoot) ---------------------------------------------------------- end, math.random(40000, 60000), 1) end addEvent("client:currentEffectDrinks", true) addEventHandler("client:currentEffectDrinks", resourceRoot, currentEffectDrinks) function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end function setSellerLookAt(ped) if(isElement(ped)) then setPedLookAt(ped, 0.0, 0.0, 0.0, 3000, localPlayer) end end s.lua local markersBarPositions = { {2348.547, -1372.678, 24.398, 501.900, -67.600, 999.700, 11, 1}, -- 1 {1000.592, -919.914, 42.328, 501.900, -67.600, 999.700, 11, 2}, -- 2 {2369.240, 1984.234, 10.820, 501.900, -67.600, 999.700, 11, 3}, -- 3 {-2432.25, -183.043, 35.312, 501.900, -67.600, 999.700, 11, 4}, -- 4 } local markersBarEnter = {} local markersBarExit = {} for i=1, #markersBarPositions do local xEnter, yEnter, zEnter, xExit, yExit, zExit, intEnter, dimEnter = unpack(markersBarPositions[i]) markersBarEnter[i] = createMarker(xEnter, yEnter, zEnter+1, "arrow", 1.5, 0, 255, 0, 255) local blip = createBlip(xEnter, yEnter, zEnter, 49) setBlipVisibleDistance(blip, 300) markersBarExit[i] = createMarker(xExit, yExit, zExit+0.1, "arrow", 1.5, 255, 0, 0, 255) setElementInterior(markersBarExit[i], intEnter, xExit, yExit, zExit-1) setElementDimension(markersBarExit[i], dimEnter) function enterBarBV:~(hitElement, matchingDimension) if (getElementType(hitElement) == "player") and (matchingDimension) then local vehicle = getPedOccupiedVehicle(hitElement) local playerAccount = getPlayerAccount(hitElement) if (not vehicle) then if (playerAccount) then if (not isGuestAccount(playerAccount)) then setElementInterior(hitElement, intEnter, xExit, yExit-2, zExit) setElementDimension(hitElement, dimEnter) setElementPosition(hitElement, xExit, yExit-2, zExit) setElementRotation(hitElement, 0, 0, 180) end end end end end addEventHandler("onMarkerHit", markersBarEnter[i], enterBarBV:~) function exitBarBV:~(hitElement, matchingDimension) if (getElementType(hitElement) == "player") and (matchingDimension) then setElementInterior(hitElement, 0, xEnter, yEnter-5, zEnter) setElementDimension(hitElement, 0) setElementPosition(hitElement, xEnter, yEnter-5, zEnter) end end addEventHandler("onMarkerHit", markersBarExit[i], exitBarBV:~) end function onPlayerBuyDrinkBVS(price) local money = getPlayerMoney(client) if (money >= price) then takePlayerMoney(client, price) local atualHealth = getElementHealth(client) setElementHealth(client, atualHealth + 20) ----------------------------------------------------- setPedWalkingStyle(client, 126) triggerClientEvent(client, "client:currentEffectDrinks", resourceRoot) ----------------------------------------------------- outputChatBox("Drink comprado com sucesso.", client, 0, 255, 0) else playSoundFrontEnd(client, 6) outputChatBox("Você não possui dinheiro suficiente.", client, 255, 0, 0) end end addEvent("server:onPlayerBuyDrinkBVS", true) addEventHandler("server:onPlayerBuyDrinkBVS", resourceRoot, onPlayerBuyDrinkBVS) function resetWalkingStyle() setPedWalkingStyle(client, 0) end addEvent("resetWalkingStyle", true) addEventHandler("resetWalkingStyle", resourceRoot, resetWalkingStyle) --------------------------------------------------- Meu bar: c.lua --[[ ################################################ # # # Resource Desenvolvido por: # # #Horus # # # # # ################################################ ]] local ped = createPed(240, 497.283, -77.876, 998.765, 0) local ped2 = createPed(240, 497.283, -77.876, 998.765, 0) local ped3 = createPed(240, 497.283, -77.876, 998.765, 0) local ped4 = createPed(240, 497.283, -77.876, 998.765, 0) setElementInterior(ped, 11) setElementDimension(ped, 1) setElementFrozen(ped, true) setElementInterior(ped2, 11) setElementDimension(ped2, 2) setElementFrozen(ped2, true) setElementInterior(ped3, 11) setElementDimension(ped3, 3) setElementFrozen(ped3, true) setElementInterior(ped4, 11) setElementDimension(ped4, 4) setElementFrozen(ped4, true) local dxfont0_fonte = dxCreateFont("font/fonte.ttf", 10) local screenW, screenH = guiGetScreenSize() local resW, resH = 1360,768 local x, y = (screenW/resW), (screenH/resH) function setBlur(state) setElementData(localPlayer, "showBlur", state) end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end function dxDrawLinedRectangle( x, y, width, height, color, _width, postGUI ) _width = _width or 1 dxDrawLine ( x, y, x+width, y, color, _width, postGUI ) -- Top dxDrawLine ( x, y, x, y+height, color, _width, postGUI ) -- Left dxDrawLine ( x, y+height, x+width, y+height, color, _width, postGUI ) -- Bottom return dxDrawLine ( x+width, y, x+width, y+height, color, _width, postGUI ) -- Right end function cancelPedDamage(attacker) cancelEvent() end addEventHandler("onClientPedDamage", ped, cancelPedDamage) addEventHandler("onClientPedDamage", ped2, cancelPedDamage) addEventHandler("onClientPedDamage", ped3, cancelPedDamage) addEventHandler("onClientPedDamage", ped4, cancelPedDamage) function drawDrinks() tocolor1 = tocolor(0, 0, 0, 150) if isCursorOnElement(screenW * 0.3257, screenH * 0.4115, screenW * 0.3272, screenH * 0.0469) then -- CATUABA tocolor1 = tocolor(16, 102, 231, 100) end tocolor2 = tocolor(0, 0, 0, 150) if isCursorOnElement(screenW * 0.3257, screenH * 0.4583, screenW * 0.3272, screenH * 0.0469) then -- VODCA tocolor2 = tocolor(16, 102, 231, 100) end tocolor3 = tocolor(0, 0, 0, 150) if isCursorOnElement(screenW * 0.3257, screenH * 0.5052, screenW * 0.3272, screenH * 0.0469) then -- CERVEJA tocolor3 = tocolor(16, 102, 231, 100) end tocolorF = tocolor(217, 0, 5, 0) if isCursorOnElement(screenW * 0.6426, screenH * 0.3490, screenW * 0.0221, screenH * 0.0417) then -- CLOSE tocolorF = tocolor(217, 0, 5, 150) end -- ################# BACKGROUND ################# dxDrawRectangle(screenW * 0.3140, screenH * 0.3490, screenW * 0.3507, screenH * 0.3997, tocolor(0, 0, 0, 150), false) dxDrawRectangle(screenW * 0.3140, screenH * 0.3490, screenW * 0.3507, screenH * 0.0417, tocolor(0, 0, 0, 150), false) -- ################# BUTTONS ################# dxDrawRectangle(screenW * 0.3257, screenH * 0.4115, screenW * 0.3272, screenH * 0.0469, tocolor1, false) -- CATUABA dxDrawRectangle(screenW * 0.3257, screenH * 0.4583, screenW * 0.3272, screenH * 0.0469, tocolor2, false) -- VODCA dxDrawRectangle(screenW * 0.3257, screenH * 0.5052, screenW * 0.3272, screenH * 0.0469, tocolor3, false) -- CERVEJA dxDrawRectangle(screenW * 0.6426, screenH * 0.3490, screenW * 0.0221, screenH * 0.0417, tocolorF, false) -- CLOSE -- ################# IMAGENS ################# dxDrawImage(screenW * 0.3287, screenH * 0.4180, screenW * 0.0191, screenH * 0.0352, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) dxDrawImage(screenW * 0.3287, screenH * 0.5573, screenW * 0.0191, screenH * 0.0339, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) dxDrawImage(screenW * 0.3257, screenH * 0.6458, screenW * 0.0265, screenH * 0.0430, "", 0, 0, 0, tocolor(254, 254, 254, 205), false) dxDrawImage(screenW * 0.3287, screenH * 0.4661, screenW * 0.0191, screenH * 0.0352, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) dxDrawImage(screenW * 0.3287, screenH * 0.5143, screenW * 0.0191, screenH * 0.0352, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) dxDrawImage(screenW * 0.3287, screenH * 0.6042, screenW * 0.0191, screenH * 0.0339, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) -- ################# TEXTOS ################# dxDrawText("Bar Passa Tempo - MENU", screenW * 0.4280, screenH * 0.3600, screenW * 0.4324, screenH * 0.3984, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("X", screenW * 0.6500, screenH * 0.3555, screenW * 0.7610, screenH * 0.3984, tocolor(255, 255, 255, 202), 1.30, "default-bold", "left", "top", false, false, false, true, false) dxDrawText("Catuaba", screenW * 0.3522, screenH * 0.4232, screenW * 0.4632, screenH * 0.4661, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("Vodca", screenW * 0.3522, screenH * 0.4714, screenW * 0.4632, screenH * 0.5143, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("Cerveja", screenW * 0.3522, screenH * 0.5183, screenW * 0.4632, screenH * 0.5573, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("#1066E7R$ #FFFFFF200", screenW * 0.6044, screenH * 0.4245, screenW * 0.7154, screenH * 0.4674, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("#1066E7R$ #FFFFFF150", screenW * 0.6044, screenH * 0.4674, screenW * 0.7154, screenH * 0.5104, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("#1066E7R$ #FFFFFF100", screenW * 0.6044, screenH * 0.5182, screenW * 0.7154, screenH * 0.5612, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("Selecione uma bebida abaixo:", screenW * 0.4350, screenH * 0.3898, screenW * 0.4324, screenH * 0.7487, tocolor(255, 255, 255, 202), 0.8, dxfont0_fonte, "left", "top", false, false, false, true, false) end function render() local screenx, screeny, worldx, worldy, worldz = getCursorPosition() local px, py, pz = getCameraMatrix() local hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, worldx, worldy, worldz ) local tx, ty, tz = getElementPosition(localPlayer) local rx, ry, rz = getElementPosition(ped) local distancia = getDistanceBetweenPoints3D(tx, ty, tz, rx, ry, rz) if not isEventHandlerAdded("onClientRender", root, drawDrink) then if (distancia < 5) then if hit then if elementHit == ped then addEventHandler("onClientRender", root, drawDrinks) showCursor(true) showChat(false) setElementData(localPlayer, "showBlur", true) end if elementHit == ped2 then addEventHandler("onClientRender", root, drawDrinks) showCursor(true) showChat(false) setElementData(localPlayer, "showBlur", true) end if elementHit == ped3 then addEventHandler("onClientRender", root, drawDrinks) showCursor(true) showChat(false) setElementData(localPlayer, "showBlur", true) end if elementHit == ped4 then addEventHandler("onClientRender", root, drawDrinks) showCursor(true) showChat(false) setElementData(localPlayer, "showBlur", true) end end end end end addEventHandler("onClientClick", root, render) local rootElement = getRootElement() local screenWidth, screenHeight = guiGetScreenSize() local maxrange = 9 function NPC2nametag() local pedX, pedY, pedZ = getElementPosition(ped) local sx, sy = getScreenFromWorldPosition (pedX,pedY,pedZ +1) local cameraX, cameraY, cameraZ = getCameraMatrix() if sx then if getDistanceBetweenPoints3D(cameraX,cameraY,cameraZ,pedX,pedY,pedZ) <= maxrange then if not getElementData(localPlayer, "showBlur") then dxDrawRectangle(sx - x*110,sy + y*57, screenW * 0.2514, screenH * 0.0630, tocolor(0, 0, 0, 165), false) dxDrawText("Garçom - Bebidas e Diversão;",sx - 25 ,sy + 60,screenWidth, screenHeight,tocolor ( 255, 255, 255, 230 ), 0.9,dxfont0_fonte) dxDrawText('Pressione #1066e7"M" #FFFFFFe clique no garçom para abrir o menu!',sx - 100,sy + 80,screenWidth, screenHeight,tocolor ( 255, 255, 255, 230 ), 0.8,dxfont0_fonte, "left", "top", false, false, false, true, false) end end end end addEventHandler("onClientRender",rootElement, NPC2nametag) function closePanel(_,state) if isEventHandlerAdded("onClientRender", root, drawDrinks) then if state == "down" then if isCursorOnElement(screenW * 0.6426, screenH * 0.3490, screenW * 0.0221, screenH * 0.0417) then showCursor(false) showChat(true) playSound("sfx/hit.mp3", false) removeEventHandler("onClientRender", root, drawDrinks) setElementData(localPlayer, "showBlur", false) end end end end addEventHandler("onClientClick", root, closePanel) function Vodca(_,state) if isEventHandlerAdded("onClientRender", root, drawDrinks) then if state == "down" then if isCursorOnElement(screenW * 0.3522, screenH * 0.4714, screenW * 0.4632, screenH * 0.5143) then if (not isTimer(timerExpireDrinks)) then setBlur(false) triggerServerEvent("server:onPlayerBuyDrinkBVS", localPlayer, 150) removeEventHandler("onClientRender", root, drawDrinks) showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) else playSound("sfx/hit.mp3", false) outputChatBox("#1066E7Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end end end end end addEventHandler("onClientClick", root, Vodca) function Cerveja(button,state) if button == "left" and state == "up" then if isCursorOnElement(screenW * 0.3522, screenH * 0.5183, screenW * 0.4632, screenH * 0.5573) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 100) if (not isTimer(timerExpireDrinks)) then else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) if isEventHandlerAdded("onClientRender", root, drawDrinks) and isEventHandlerAdded("onClientClick", root, Cerveja) then removeEventHandler("onClientRender", root, drawDrinks) removeEventHandler("onClientClick", root, Cerveja) showCursor(false) end end end end end function currentEffectDrinks() ---------------------------------------------------------- timerControlDrinks = setTimer(function() setPedControlState(localPlayer, "walk", true) end, 100, 0) setWindVelocity(100, 100, 0) setCameraShakeLevel(255) ---------------------------------------------------------- timerExpireDrinks = setTimer(function() ---------------------------------------------------------- resetWindVelocity() setCameraShakeLevel(1) if isTimer(timerControlDrinks) then killTimer(timerControlDrinks) end setPedControlState(localPlayer, "walk", false) outputChatBox("O efeito da bebida acabou.", 0, 255, 0) triggerServerEvent("resetWalkingStyle",resourceRoot) ---------------------------------------------------------- end, math.random(40000, 60000), 1) end addEvent("client:currentEffectDrinks", true) addEventHandler("client:currentEffectDrinks", resourceRoot, currentEffectDrinks) function isCursorOnElement( posX, posY, width, height ) if isCursorShowing( ) then local mouseX, mouseY = getCursorPosition( ) local clientW, clientH = guiGetScreenSize( ) local mouseX, mouseY = mouseX * clientW, mouseY * clientH if ( mouseX > posX and mouseX < ( posX + width ) and mouseY > posY and mouseY < ( posY + height ) ) then return true end end return false end s.lua local markersBarPositions = { {2348.547, -1372.678, 24.398, 501.900, -67.600, 999.700, 11, 1}, -- 1 {1000.592, -919.914, 42.328, 501.900, -67.600, 999.700, 11, 2}, -- 2 {2369.240, 1984.234, 10.820, 501.900, -67.600, 999.700, 11, 3}, -- 3 {-2432.25, -183.043, 35.312, 501.900, -67.600, 999.700, 11, 4}, -- 4 } local markersBarEnter = {} local markersBarExit = {} for i=1, #markersBarPositions do local xEnter, yEnter, zEnter, xExit, yExit, zExit, intEnter, dimEnter = unpack(markersBarPositions[i]) markersBarEnter[i] = createMarker(xEnter, yEnter, zEnter+1, "arrow", 1.5, 0, 16, 102, 231) local blip = createBlip(xEnter, yEnter, zEnter, 49) setBlipVisibleDistance(blip, 300) markersBarExit[i] = createMarker(xExit, yExit, zExit+0.1, "arrow", 1.5, 255, 0, 0, 255) setElementInterior(markersBarExit[i], intEnter, xExit, yExit, zExit-1) setElementDimension(markersBarExit[i], dimEnter) function enterBarBV:~(hitElement, matchingDimension) if (getElementType(hitElement) == "player") and (matchingDimension) then local vehicle = getPedOccupiedVehicle(hitElement) local playerAccount = getPlayerAccount(hitElement) if (not vehicle) then if (playerAccount) then if (not isGuestAccount(playerAccount)) then setElementInterior(hitElement, intEnter, xExit, yExit-2, zExit) setElementDimension(hitElement, dimEnter) setElementPosition(hitElement, xExit, yExit-2, zExit) setElementRotation(hitElement, 0, 0, 180) end end end end end addEventHandler("onMarkerHit", markersBarEnter[i], enterBarBV:~) function exitBarBV:~(hitElement, matchingDimension) if (getElementType(hitElement) == "player") and (matchingDimension) then setElementInterior(hitElement, 0, xEnter, yEnter-5, zEnter) setElementDimension(hitElement, 0) setElementPosition(hitElement, xEnter, yEnter-5, zEnter) end end addEventHandler("onMarkerHit", markersBarExit[i], exitBarBV:~) end function onPlayerBuyDrinkBVS(price) local money = getPlayerMoney(client) if (money >= price) then takePlayerMoney(client, price) local atualHealth = getElementHealth(client) setElementHealth(client, atualHealth + 20) playSound("sfx/hit.mp3", false) ----------------------------------------------------- setPedWalkingStyle(client, 126) triggerClientEvent(client, "client:currentEffectDrinks", resourceRoot) ----------------------------------------------------- outputChatBox("Drink comprado com sucesso.", client, 16, 102, 231) else playSound("sfx/hit.mp3", false) outputChatBox("Você não possui dinheiro suficiente.", client, 255, 0, 0) end end addEvent("server:onPlayerBuyDrinkBVS", true) addEventHandler("server:onPlayerBuyDrinkBVS", resourceRoot, onPlayerBuyDrinkBVS) function resetWalkingStyle() setPedWalkingStyle(client, 0) end addEvent("resetWalkingStyle", true) addEventHandler("resetWalkingStyle", resourceRoot, resetWalkingStyle) no client do meu bar fiz o seguinte, criei 4 peds, e coloquei um dxDrawText em cima de cada um, Mandando pressionar "M" pra abrir o cursor e clicar no ped, então basicamente tive de mudar algumas coisas, como setar o isCursorOnElement, e tenho costume com blur. Edited January 7, 2019 by #Horus Link to comment
Other Languages Moderators Lord Henry Posted January 7, 2019 Other Languages Moderators Share Posted January 7, 2019 (edited) 42 minutes ago, OverKILL said: A mania da galera de fazer um código de qualquer jeito, acho que não é só eu que tenho toque kkkk, me da agonia ver um código todo mal indentado ahsuasuhauhssauh Pois é. Não é querer ser chato, eu simplesmente não consigo ler código não-indentado. Eu preciso ficar toda hora copiando o código, colando no notepad++ e arrumando eu mesmo a indentação pra só depois conseguir ler e descobrir erros. Se o cara não é capaz nem de deixar um código legível, como espera aprender a programar direito? 34 minutes ago, #Horus said: s.lua local markersBarPositions = { {2348.547, -1372.678, 24.398, 501.900, -67.600, 999.700, 11, 1}, -- 1 {1000.592, -919.914, 42.328, 501.900, -67.600, 999.700, 11, 2}, -- 2 {2369.240, 1984.234, 10.820, 501.900, -67.600, 999.700, 11, 3}, -- 3 {-2432.25, -183.043, 35.312, 501.900, -67.600, 999.700, 11, 4}, -- 4 } local markersBarEnter = {} local markersBarExit = {} for i=1, #markersBarPositions do local xEnter, yEnter, zEnter, xExit, yExit, zExit, intEnter, dimEnter = unpack(markersBarPositions[i]) markersBarEnter[i] = createMarker(xEnter, yEnter, zEnter+1, "arrow", 1.5, 0, 16, 102, 231) local blip = createBlip(xEnter, yEnter, zEnter, 49) setBlipVisibleDistance(blip, 300) markersBarExit[i] = createMarker(xExit, yExit, zExit+0.1, "arrow", 1.5, 255, 0, 0, 255) setElementInterior(markersBarExit[i], intEnter, xExit, yExit, zExit-1) setElementDimension(markersBarExit[i], dimEnter) function enterBarBV:~(hitElement, matchingDimension) -- ERRO if (getElementType(hitElement) == "player") and (matchingDimension) then local vehicle = getPedOccupiedVehicle(hitElement) local playerAccount = getPlayerAccount(hitElement) if (not vehicle) then if (playerAccount) then if (not isGuestAccount(playerAccount)) then setElementInterior(hitElement, intEnter, xExit, yExit-2, zExit) setElementDimension(hitElement, dimEnter) setElementPosition(hitElement, xExit, yExit-2, zExit) setElementRotation(hitElement, 0, 0, 180) end end end end end addEventHandler("onMarkerHit", markersBarEnter[i], enterBarBV:~) -- ERRO function exitBarBV:~(hitElement, matchingDimension) -- ERRO if (getElementType(hitElement) == "player") and (matchingDimension) then setElementInterior(hitElement, 0, xEnter, yEnter-5, zEnter) setElementDimension(hitElement, 0) setElementPosition(hitElement, xEnter, yEnter-5, zEnter) end end addEventHandler("onMarkerHit", markersBarExit[i], exitBarBV:~) -- ERRO end function onPlayerBuyDrinkBVS(price) local money = getPlayerMoney(client) if (money >= price) then takePlayerMoney(client, price) local atualHealth = getElementHealth(client) setElementHealth(client, atualHealth + 20) playSound("sfx/hit.mp3", false) ----------------------------------------------------- setPedWalkingStyle(client, 126) triggerClientEvent(client, "client:currentEffectDrinks", resourceRoot) ----------------------------------------------------- outputChatBox("Drink comprado com sucesso.", client, 16, 102, 231) else playSound("sfx/hit.mp3", false) outputChatBox("Você não possui dinheiro suficiente.", client, 255, 0, 0) end end addEvent("server:onPlayerBuyDrinkBVS", true) addEventHandler("server:onPlayerBuyDrinkBVS", resourceRoot, onPlayerBuyDrinkBVS) function resetWalkingStyle() setPedWalkingStyle(client, 0) end addEvent("resetWalkingStyle", true) addEventHandler("resetWalkingStyle", resourceRoot, resetWalkingStyle) A propósito. Na linha 25 do s.lua o nome da sua função contém símbolos ilegais. Se vc usasse /debugscript 3 como a gente sempre diz pra fazer antes de qualquer coisa, vc já teria descoberto isso. ERROR: '<name>' expected near '~' Edited January 7, 2019 by Lord Henry Link to comment
#Horus Posted January 7, 2019 Author Share Posted January 7, 2019 46 minutes ago, Lord Henry said: Pois é. Não é querer ser chato, eu simplesmente não consigo ler código não-indentado. Eu preciso ficar toda hora copiando o código, colando no notepad++ e arrumando eu mesmo a indentação pra só depois conseguir ler e descobrir erros. Se o cara não é capaz nem de deixar um código legível, como espera aprender a programar direito? A propósito. Na linha 25 do s.lua o nome da sua função contém símbolos ilegais. Se vc usasse /debugscript 3 como a gente sempre diz pra fazer antes de qualquer coisa, vc já teria descoberto isso. ERROR: '<name>' expected near '~' Me dá um exemplo simples de código indentado ? Você fala deixá-los em ordem ? Link to comment
[M]ister Posted January 8, 2019 Share Posted January 8, 2019 (edited) 1 hour ago, #Horus said: Me dá um exemplo simples de código indentado ? Você fala deixá-los em ordem ? A indentação é os recuos no código que servem para deixar o código mais fácil de entender, com ela fica muito mais perceptível identificar as estruturas, saber a qual função/condição/instrução um bloco de código pertence, saber facilmente seu inicio e fim…. -- Exemplo código sem indentação: if (a) then if (d) then f() end elseif (e) then while(k) do g() end elseif (b) then for (0;10) do if (l) then u() end end end -- Código com indentação: if (a) then if (d) then f() end elseif (e) then while(k) do g() end elseif (b) then for (0,10) do if (l) then u() end end end Edited January 8, 2019 by MaligNos Link to comment
#Horus Posted January 8, 2019 Author Share Posted January 8, 2019 (edited) 4 minutes ago, MaligNos said: A identação é os recuos no código que servem para deixar o código mais fácil de entender, com ela fica muito mais perceptível identificar as estruturas, saber a qual função/condição/instrução um bloco de código pertence, saber facilmente seu inicio e fim…. -- Exemplo código sem identação:if (a) thenif (d) thenf()endelseif (e) thenwhile(k) dog()endelseif (b) thenfor (0;10) doif (l) thenu()endendend -- Código com identação:if (a) then if (d) then f() endelseif (e) then while(k) do g() endelseif (b) then for (0,10) do if (l) then u() end endend Ah sim, então no caso eu só indentei o segundo c.lua que mandei ali né ? É basicamente os espaços corretos pro notepadd++ já subir a linha e o código ficar corretamente mais legível né ? Edited January 8, 2019 by #Horus Link to comment
#Horus Posted January 8, 2019 Author Share Posted January 8, 2019 7 hours ago, Lord Henry said: Pois é. Não é querer ser chato, eu simplesmente não consigo ler código não-indentado. Eu preciso ficar toda hora copiando o código, colando no notepad++ e arrumando eu mesmo a indentação pra só depois conseguir ler e descobrir erros. Se o cara não é capaz nem de deixar um código legível, como espera aprender a programar direito? A propósito. Na linha 25 do s.lua o nome da sua função contém símbolos ilegais. Se vc usasse /debugscript 3 como a gente sempre diz pra fazer antes de qualquer coisa, vc já teria descoberto isso. ERROR: '<name>' expected near '~' Indentei o codigo do bar original. c.lua local sWidth, sHeight = guiGetScreenSize() local drawDrinksBVS = {} drawDrinksBVS.bgX = sWidth / 2 - 200 drawDrinksBVS.bgY = sHeight / 2 - 200 drawDrinksBVS.bgW = 400 drawDrinksBVS.bgH = 250 drawDrinksBVS.bgTopBarX = sWidth / 2 - 200 drawDrinksBVS.bgTopBarY = sHeight / 2 - 200 drawDrinksBVS.bgTopBarW = 400 drawDrinksBVS.bgTopBarH = 50 drawDrinksBVS.bgCloseX = sWidth / 2 - 200 drawDrinksBVS.bgCloseY = sHeight / 2 - 200 drawDrinksBVS.bgCloseW = 50 drawDrinksBVS.bgCloseH = 50 drawDrinksBVS.bgCatuabaX = sWidth / 2 - 170 drawDrinksBVS.bgCatuabaY = sHeight / 2 - 120 drawDrinksBVS.bgCatuabaW = 96 drawDrinksBVS.bgCatuabaH = 96 drawDrinksBVS.bgVodkaX = sWidth / 2 - 50 drawDrinksBVS.bgVodkaY = sHeight / 2 - 120 drawDrinksBVS.bgVodkaW = 96 drawDrinksBVS.bgVodkaH = 96 drawDrinksBVS.bgCervejaX = sWidth / 2 + 70 drawDrinksBVS.bgCervejaY = sHeight / 2 - 120 drawDrinksBVS.bgCervejaW = 96 drawDrinksBVS.bgCervejaH = 96 BarBVS = {} BarBVS.peds = {} BarBVS.pedsPos = { {240, 498.4, -77.9, 998.7, 11, 1}, {240, 498.4, -77.9, 998.7, 11, 2}, {240, 498.4, -77.9, 998.7, 11, 3}, {240, 498.4, -77.9, 998.7, 11, 4}, {240, 498.4, -77.9, 998.7, 11, 5}, {240, 498.4, -77.9, 998.7, 11, 6}, } BarBVS.markers = {} BarBVS.markersPos = { {498.4, -75.7, 997.7, 11, 1}, {498.4, -75.7, 997.7, 11, 2}, {498.4, -75.7, 997.7, 11, 3}, {498.4, -75.7, 997.7, 11, 4}, {498.4, -75.7, 997.7, 11, 5}, {498.4, -75.7, 997.7, 11, 6}, } function startClientDrinks() for k, v in pairs(BarBVS.pedsPos) do local id = #BarBVS.peds + 1 BarBVS.peds[id] = createPed(v[1], v[2], v[3], v[4]) setElementInterior(BarBVS.peds[id], v[5]) setElementDimension(BarBVS.peds[id], v[6]) addEventHandler("onClientPedDamage", BarBVS.peds[id], function() cancelEvent() end) setElementData(BarBVS.peds[id], "Ped:Msg", "Que tal uma bebida?") addEventHandler("onClientRender", getRootElement(), function() setSellerLookAt(BarBVS.peds[id]) end) end for k, v in pairs(BarBVS.markersPos) do local id = #BarBVS.markers + 1 BarBVS.markers[id] = createMarker(v[1], v[2], v[3], "cylinder", 1, 30, 180, 65, 200) setElementInterior(BarBVS.markers[id], v[4]) setElementDimension(BarBVS.markers[id], v[5]) addEventHandler('onClientMarkerHit', BarBVS.markers[id], function(player) if player == localPlayer then if not isEventHandlerAdded("onClientRender", root, drawDrinks) and not isEventHandlerAdded("onClientClick", root, clickEffectDrink) then addEventHandler("onClientRender", root, drawDrinks) addEventHandler("onClientClick", root, clickEffectDrink) showCursor(true) end end end) addEventHandler('onClientMarkerLeave', BarBVS.markers[id], function(player) if player == localPlayer then if isEventHandlerAdded("onClientRender", root, drawDrinks) and isEventHandlerAdded("onClientClick", root, clickEffectDrink) then removeEventHandler("onClientRender", root, drawDrinks) removeEventHandler("onClientClick", root, clickEffectDrink) showCursor(false) end end end) end end addEventHandler("onClientResourceStart", resourceRoot, startClientDrinks) function drawDrinks() dxDrawRectangle(drawDrinksBVS.bgX, drawDrinksBVS.bgY, drawDrinksBVS.bgW, drawDrinksBVS.bgH, tocolor(0, 0, 0, 180)) dxDrawRectangle(drawDrinksBVS.bgX-2, drawDrinksBVS.bgY-2, drawDrinksBVS.bgW+4, drawDrinksBVS.bgH+4, tocolor(0, 0, 0, 150)) dxDrawRectangle(drawDrinksBVS.bgTopBarX, drawDrinksBVS.bgTopBarY, drawDrinksBVS.bgTopBarW, drawDrinksBVS.bgTopBarH, tocolor(30, 180, 65, 200)) closeDrinksAplha = isMouseInPosition(drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseH) and 255 or 180 dxDrawRectangle(drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseH, tocolor(255, 0, 0, closeDrinksAplha)) dxDrawText("X", drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseX+drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseY+drawDrinksBVS.bgCloseH, tocolor(255,255,255,255), 2, "pricedown", "center", "center") dxDrawText("BEBIDAS", drawDrinksBVS.bgX, drawDrinksBVS.bgY - 200, drawDrinksBVS.bgX+drawDrinksBVS.bgW, drawDrinksBVS.bgY+drawDrinksBVS.bgH, tocolor(255,255,255,255), 1.5, "pricedown", "center", "center") if isMouseInPosition(drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY, drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaH) then dxDrawImage(drawDrinksBVS.bgCatuabaX-1, drawDrinksBVS.bgCatuabaY-1, drawDrinksBVS.bgCatuabaW+2, drawDrinksBVS.bgCatuabaH+2, "files/icon.png") end dxDrawImage(drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY, drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaH, "files/icon.png") dxDrawText("CATUABA", drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY + 120, drawDrinksBVS.bgCatuabaX+drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaY+drawDrinksBVS.bgCatuabaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") dxDrawText("200$", drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY + 170, drawDrinksBVS.bgCatuabaX+drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaY+drawDrinksBVS.bgCatuabaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") if isMouseInPosition(drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY, drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaH) then dxDrawImage(drawDrinksBVS.bgVodkaX-1, drawDrinksBVS.bgVodkaY-1, drawDrinksBVS.bgVodkaW+2, drawDrinksBVS.bgVodkaH+2, "files/icon.png") end dxDrawImage(drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY, drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaH, "files/icon.png") dxDrawText("VODKA", drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY + 120, drawDrinksBVS.bgVodkaX+drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaY+drawDrinksBVS.bgVodkaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") dxDrawText("150$", drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY + 170, drawDrinksBVS.bgVodkaX+drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaY+drawDrinksBVS.bgVodkaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") if isMouseInPosition(drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY, drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaH) then dxDrawImage(drawDrinksBVS.bgCervejaX-1, drawDrinksBVS.bgCervejaY-1, drawDrinksBVS.bgCervejaW+2, drawDrinksBVS.bgCervejaH+2, "files/icon.png") end dxDrawImage(drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY, drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaH, "files/icon.png") dxDrawText("CERVEJA", drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY + 120, drawDrinksBVS.bgCervejaX+drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaY+drawDrinksBVS.bgCervejaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") dxDrawText("100$", drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY + 170, drawDrinksBVS.bgCervejaX+drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaY+drawDrinksBVS.bgCervejaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") end function clickEffectDrink(button,state) if button == "left" and state == "up" then if isMouseInPosition(drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY, drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 200) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY, drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 150) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY, drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 100) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseH) then if isEventHandlerAdded("onClientRender", root, drawDrinks) and isEventHandlerAdded("onClientClick", root, clickEffectDrink) then removeEventHandler("onClientRender", root, drawDrinks) removeEventHandler("onClientClick", root, clickEffectDrink) showCursor(false) end end end end function currentEffectDrinks() timerControlDrinks = setTimer(function() setPedControlState(localPlayer, "walk", true) end, 100, 0) setWindVelocity(100, 100, 0) setCameraShakeLevel(255) -------------------------------------------------------------------------------------------- timerExpireDrinks = setTimer(function() resetWindVelocity() setCameraShakeLevel(1) if isTimer(timerControlDrinks) then killTimer(timerControlDrinks) end setPedControlState(localPlayer, "walk", false) outputChatBox("O efeito da bebida acabou.", 0, 255, 0) triggerServerEvent("resetWalkingStyle",resourceRoot) end, math.random(40000, 60000), 1) end addEvent("client:currentEffectDrinks", true) addEventHandler("client:currentEffectDrinks", resourceRoot, currentEffectDrinks) function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end function setSellerLookAt(ped) if(isElement(ped)) then setPedLookAt(ped, 0.0, 0.0, 0.0, 3000, localPlayer) end end s.lua local markersBarPositions = { {2348.547, -1372.678, 24.398, 501.900, -67.600, 999.700, 11, 1}, -- 1 {1000.592, -919.914, 42.328, 501.900, -67.600, 999.700, 11, 2}, -- 2 {2369.240, 1984.234, 10.820, 501.900, -67.600, 999.700, 11, 3}, -- 3 {-2432.25, -183.043, 35.312, 501.900, -67.600, 999.700, 11, 4}, -- 4 } local markersBarEnter = {} local markersBarExit = {} for i=1, #markersBarPositions do local xEnter, yEnter, zEnter, xExit, yExit, zExit, intEnter, dimEnter = unpack(markersBarPositions[i]) markersBarEnter[i] = createMarker(xEnter, yEnter, zEnter+1, "arrow", 1.5, 0, 255, 0, 255) local blip = createBlip(xEnter, yEnter, zEnter, 49) setBlipVisibleDistance(blip, 300) markersBarExit[i] = createMarker(xExit, yExit, zExit+0.1, "arrow", 1.5, 255, 0, 0, 255) setElementInterior(markersBarExit[i], intEnter, xExit, yExit, zExit-1) setElementDimension(markersBarExit[i], dimEnter) function enterBarBV:~(hitElement, matchingDimension) if (getElementType(hitElement) == "player") and (matchingDimension) then local vehicle = getPedOccupiedVehicle(hitElement) local playerAccount = getPlayerAccount(hitElement) if (not vehicle) then if (playerAccount) then if (not isGuestAccount(playerAccount)) then setElementInterior(hitElement, intEnter, xExit, yExit-2, zExit) setElementDimension(hitElement, dimEnter) setElementPosition(hitElement, xExit, yExit-2, zExit) setElementRotation(hitElement, 0, 0, 180) end end end end end addEventHandler("onMarkerHit", markersBarEnter[i], enterBarBV:~) function exitBarBV:~(hitElement, matchingDimension) if (getElementType(hitElement) == "player") and (matchingDimension) then setElementInterior(hitElement, 0, xEnter, yEnter-5, zEnter) setElementDimension(hitElement, 0) setElementPosition(hitElement, xEnter, yEnter-5, zEnter) end end addEventHandler("onMarkerHit", markersBarExit[i], exitBarBV:~) end function onPlayerBuyDrinkBVS(price) local money = getPlayerMoney(client) if (money >= price) then takePlayerMoney(client, price) local atualHealth = getElementHealth(client) setElementHealth(client, atualHealth + 20) setPedWalkingStyle(client, 126) triggerClientEvent(client, "client:currentEffectDrinks", resourceRoot) outputChatBox("Drink comprado com sucesso.", client, 0, 255, 0) else playSoundFrontEnd(client, 6) outputChatBox("Você não possui dinheiro suficiente.", client, 255, 0, 0) end end addEvent("server:onPlayerBuyDrinkBVS", true) addEventHandler("server:onPlayerBuyDrinkBVS", resourceRoot, onPlayerBuyDrinkBVS) function resetWalkingStyle() setPedWalkingStyle(client, 0) end addEvent("resetWalkingStyle", true) addEventHandler("resetWalkingStyle", resourceRoot, resetWalkingStyle) Entendi as indentações perfeitamente agora.. é a ligação entre as estruturas ou seja ( Aqueles risquinho em vertical ligando primeiro if ao primeiro end, e assim sequencialmente de acordo com aonde o if esteja no notepad++ ), Ta mais legível ? Link to comment
Other Languages Moderators Lord Henry Posted January 8, 2019 Other Languages Moderators Share Posted January 8, 2019 Ainda tem erro de indentação. E vc ainda não corrigiu os símbolos :~ nos nomes das funções. Link to comment
#Horus Posted January 8, 2019 Author Share Posted January 8, 2019 7 hours ago, Lord Henry said: Ainda tem erro de indentação. E vc ainda não corrigiu os símbolos :~ nos nomes das funções. preciso indentar os else também ? Link to comment
Other Languages Moderators Lord Henry Posted January 8, 2019 Other Languages Moderators Share Posted January 8, 2019 Claro. O else é como um if sem condição. Link to comment
#Horus Posted January 8, 2019 Author Share Posted January 8, 2019 (edited) 29 minutes ago, Lord Henry said: Claro. O else é como um if sem condição. Meu bar: c.lua --[[ ################################################ # # # Resource Desenvolvido por: # # #Horus # # # # # ################################################ ]] local ped = createPed(240, 497.283, -77.876, 998.765, 0) local ped2 = createPed(240, 497.283, -77.876, 998.765, 0) local ped3 = createPed(240, 497.283, -77.876, 998.765, 0) local ped4 = createPed(240, 497.283, -77.876, 998.765, 0) setElementInterior(ped, 11) setElementDimension(ped, 1) setElementFrozen(ped, true) setElementInterior(ped2, 11) setElementDimension(ped2, 2) setElementFrozen(ped2, true) setElementInterior(ped3, 11) setElementDimension(ped3, 3) setElementFrozen(ped3, true) setElementInterior(ped4, 11) setElementDimension(ped4, 4) setElementFrozen(ped4, true) local dxfont0_fonte = dxCreateFont("font/fonte.ttf", 10) local screenW, screenH = guiGetScreenSize() local resW, resH = 1360,768 local x, y = (screenW/resW), (screenH/resH) function setBlur(state) setElementData(localPlayer, "showBlur", state) end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end function dxDrawLinedRectangle( x, y, width, height, color, _width, postGUI ) _width = _width or 1 dxDrawLine ( x, y, x+width, y, color, _width, postGUI ) -- Top dxDrawLine ( x, y, x, y+height, color, _width, postGUI ) -- Left dxDrawLine ( x, y+height, x+width, y+height, color, _width, postGUI ) -- Bottom return dxDrawLine ( x+width, y, x+width, y+height, color, _width, postGUI ) -- Right end function cancelPedDamage(attacker) cancelEvent() end addEventHandler("onClientPedDamage", ped, cancelPedDamage) addEventHandler("onClientPedDamage", ped2, cancelPedDamage) addEventHandler("onClientPedDamage", ped3, cancelPedDamage) addEventHandler("onClientPedDamage", ped4, cancelPedDamage) function drawDrinks() tocolor1 = tocolor(0, 0, 0, 150) if isCursorOnElement(screenW * 0.3257, screenH * 0.4115, screenW * 0.3272, screenH * 0.0469) then -- CATUABA tocolor1 = tocolor(16, 102, 231, 100) end tocolor2 = tocolor(0, 0, 0, 150) if isCursorOnElement(screenW * 0.3257, screenH * 0.4583, screenW * 0.3272, screenH * 0.0469) then -- VODCA tocolor2 = tocolor(16, 102, 231, 100) end tocolor3 = tocolor(0, 0, 0, 150) if isCursorOnElement(screenW * 0.3257, screenH * 0.5052, screenW * 0.3272, screenH * 0.0469) then -- CERVEJA tocolor3 = tocolor(16, 102, 231, 100) end tocolorF = tocolor(217, 0, 5, 0) if isCursorOnElement(screenW * 0.6426, screenH * 0.3490, screenW * 0.0221, screenH * 0.0417) then -- CLOSE tocolorF = tocolor(217, 0, 5, 150) end -- ################# BACKGROUND ################# dxDrawRectangle(screenW * 0.3140, screenH * 0.3490, screenW * 0.3507, screenH * 0.3997, tocolor(0, 0, 0, 150), false) dxDrawRectangle(screenW * 0.3140, screenH * 0.3490, screenW * 0.3507, screenH * 0.0417, tocolor(0, 0, 0, 150), false) -- ################# BUTTONS ################# dxDrawRectangle(screenW * 0.3257, screenH * 0.4115, screenW * 0.3272, screenH * 0.0469, tocolor1, false) -- CATUABA dxDrawRectangle(screenW * 0.3257, screenH * 0.4583, screenW * 0.3272, screenH * 0.0469, tocolor2, false) -- VODCA dxDrawRectangle(screenW * 0.3257, screenH * 0.5052, screenW * 0.3272, screenH * 0.0469, tocolor3, false) -- CERVEJA dxDrawRectangle(screenW * 0.6426, screenH * 0.3490, screenW * 0.0221, screenH * 0.0417, tocolorF, false) -- CLOSE -- ################# IMAGENS ################# dxDrawImage(screenW * 0.3287, screenH * 0.4180, screenW * 0.0191, screenH * 0.0352, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) dxDrawImage(screenW * 0.3287, screenH * 0.5573, screenW * 0.0191, screenH * 0.0339, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) dxDrawImage(screenW * 0.3257, screenH * 0.6458, screenW * 0.0265, screenH * 0.0430, "", 0, 0, 0, tocolor(254, 254, 254, 205), false) dxDrawImage(screenW * 0.3287, screenH * 0.4661, screenW * 0.0191, screenH * 0.0352, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) dxDrawImage(screenW * 0.3287, screenH * 0.5143, screenW * 0.0191, screenH * 0.0352, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) dxDrawImage(screenW * 0.3287, screenH * 0.6042, screenW * 0.0191, screenH * 0.0339, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) -- ################# TEXTOS ################# dxDrawText("Bar Passa Tempo - MENU", screenW * 0.4280, screenH * 0.3600, screenW * 0.4324, screenH * 0.3984, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("X", screenW * 0.6500, screenH * 0.3555, screenW * 0.7610, screenH * 0.3984, tocolor(255, 255, 255, 202), 1.30, "default-bold", "left", "top", false, false, false, true, false) dxDrawText("Catuaba", screenW * 0.3522, screenH * 0.4232, screenW * 0.4632, screenH * 0.4661, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("Vodca", screenW * 0.3522, screenH * 0.4714, screenW * 0.4632, screenH * 0.5143, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("Cerveja", screenW * 0.3522, screenH * 0.5183, screenW * 0.4632, screenH * 0.5573, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("#1066E7R$ #FFFFFF200", screenW * 0.6044, screenH * 0.4245, screenW * 0.7154, screenH * 0.4674, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("#1066E7R$ #FFFFFF150", screenW * 0.6044, screenH * 0.4674, screenW * 0.7154, screenH * 0.5104, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("#1066E7R$ #FFFFFF100", screenW * 0.6044, screenH * 0.5182, screenW * 0.7154, screenH * 0.5612, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("Selecione uma bebida abaixo:", screenW * 0.4350, screenH * 0.3898, screenW * 0.4324, screenH * 0.7487, tocolor(255, 255, 255, 202), 0.8, dxfont0_fonte, "left", "top", false, false, false, true, false) end function render() local screenx, screeny, worldx, worldy, worldz = getCursorPosition() local px, py, pz = getCameraMatrix() local hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, worldx, worldy, worldz ) local tx, ty, tz = getElementPosition(localPlayer) local rx, ry, rz = getElementPosition(ped) local distancia = getDistanceBetweenPoints3D(tx, ty, tz, rx, ry, rz) if not isEventHandlerAdded("onClientRender", root, drawDrink) then if (distancia < 5) then if hit then if elementHit == ped then addEventHandler("onClientRender", root, drawDrinks) showCursor(true) showChat(false) setElementData(localPlayer, "showBlur", true) end if elementHit == ped2 then addEventHandler("onClientRender", root, drawDrinks) showCursor(true) showChat(false) setElementData(localPlayer, "showBlur", true) end if elementHit == ped3 then addEventHandler("onClientRender", root, drawDrinks) showCursor(true) showChat(false) setElementData(localPlayer, "showBlur", true) end if elementHit == ped4 then addEventHandler("onClientRender", root, drawDrinks) showCursor(true) showChat(false) setElementData(localPlayer, "showBlur", true) end end end end end addEventHandler("onClientClick", root, render) local rootElement = getRootElement() local screenWidth, screenHeight = guiGetScreenSize() local maxrange = 9 function NPC2nametag() local pedX, pedY, pedZ = getElementPosition(ped) local sx, sy = getScreenFromWorldPosition (pedX,pedY,pedZ +1) local cameraX, cameraY, cameraZ = getCameraMatrix() if sx then if getDistanceBetweenPoints3D(cameraX,cameraY,cameraZ,pedX,pedY,pedZ) <= maxrange then if not getElementData(localPlayer, "showBlur") then dxDrawRectangle(sx - x*110,sy + y*57, screenW * 0.2514, screenH * 0.0630, tocolor(0, 0, 0, 165), false) dxDrawText("Garçom - Bebidas e Diversão;",sx - 25 ,sy + 60,screenWidth, screenHeight,tocolor ( 255, 255, 255, 230 ), 0.9,dxfont0_fonte) dxDrawText('Pressione #1066e7"M" #FFFFFFe clique no garçom para abrir o menu!',sx - 100,sy + 80,screenWidth, screenHeight,tocolor ( 255, 255, 255, 230 ), 0.8,dxfont0_fonte, "left", "top", false, false, false, true, false) end end end end addEventHandler("onClientRender",rootElement, NPC2nametag) function closePanel(_,state) if isEventHandlerAdded("onClientRender", root, drawDrinks) then if state == "down" then if isCursorOnElement(screenW * 0.6426, screenH * 0.3490, screenW * 0.0221, screenH * 0.0417) then showCursor(false) showChat(true) playSound("sfx/hit.mp3", false) removeEventHandler("onClientRender", root, drawDrinks) setElementData(localPlayer, "showBlur", false) end end end end addEventHandler("onClientClick", root, closePanel) function Catuaba(_,state) if isEventHandlerAdded("onClientRender", root, drawDrinks) then if state == "down" then if isCursorOnElement(screenW * 0.3522, screenH * 0.4714, screenW * 0.4632, screenH * 0.5143) then if (not isTimer(timerExpireDrinks)) then setBlur(false) triggerServerEvent("server:onPlayerBuyDrinkBVS", localPlayer, 150) removeEventHandler("onClientRender", root, drawDrinks) showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) else playSound("sfx/hit.mp3", false) outputChatBox("#1066E7Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", source, 255, 255, 255, true) end end end end end addEventHandler("onClientClick", root, Catuaba) function Vodca(_,state) if isEventHandlerAdded("onClientRender", root, drawDrinks) then if state == "down" then if isCursorOnElement(screenW * 0.3522, screenH * 0.4714, screenW * 0.4632, screenH * 0.5143) then if (not isTimer(timerExpireDrinks)) then setBlur(false) triggerServerEvent("server:onPlayerBuyDrinkBVS", localPlayer, 150) removeEventHandler("onClientRender", root, drawDrinks) showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) else playSound("sfx/hit.mp3", false) outputChatBox("#1066E7Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", source, 255, 255, 255, true) end end end end end addEventHandler("onClientClick", root, Vodca) function Cerveja(_,state) if isEventHandlerAdded("onClientRender", root, drawDrinks) then if state == "down" then if isCursorOnElement(screenW * 0.3522, screenH * 0.4714, screenW * 0.4632, screenH * 0.5143) then if (not isTimer(timerExpireDrinks)) then setBlur(false) triggerServerEvent("server:onPlayerBuyDrinkBVS", localPlayer, 100) removeEventHandler("onClientRender", root, drawDrinks) showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) else playSound("sfx/hit.mp3", false) outputChatBox("#1066E7Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", source, 255, 255, 255, true) end end end end end addEventHandler("onClientClick", root, Cerveja) function currentEffectDrinks() timerControlDrinks = setTimer(function() setPedControlState(localPlayer, "walk", true) end, 100, 0) setWindVelocity(100, 100, 0) setCameraShakeLevel(255) -------------------------------------------------------------------------------------------- timerExpireDrinks = setTimer(function() resetWindVelocity() setCameraShakeLevel(1) if isTimer(timerControlDrinks) then killTimer(timerControlDrinks) end setPedControlState(localPlayer, "walk", false) outputChatBox("O efeito da bebida acabou.", 0, 255, 0) triggerServerEvent("resetWalkingStyle",resourceRoot) end, math.random(40000, 60000), 1) end addEvent("client:currentEffectDrinks", true) addEventHandler("client:currentEffectDrinks", resourceRoot, currentEffectDrinks) function isCursorOnElement( posX, posY, width, height ) if isCursorShowing( ) then local mouseX, mouseY = getCursorPosition( ) local clientW, clientH = guiGetScreenSize( ) local mouseX, mouseY = mouseX * clientW, mouseY * clientH if ( mouseX > posX and mouseX < ( posX + width ) and mouseY > posY and mouseY < ( posY + height ) ) then return true end end return false end s.lua local markersBarPositions = { {2348.547, -1372.678, 24.398, 501.900, -67.600, 999.700, 11, 1}, -- 1 {1000.592, -919.914, 42.328, 501.900, -67.600, 999.700, 11, 2}, -- 2 {2369.240, 1984.234, 10.820, 501.900, -67.600, 999.700, 11, 3}, -- 3 {-2432.25, -183.043, 35.312, 501.900, -67.600, 999.700, 11, 4}, -- 4 } local markersBarEnter = {} local markersBarExit = {} for i=1, #markersBarPositions do local xEnter, yEnter, zEnter, xExit, yExit, zExit, intEnter, dimEnter = unpack(markersBarPositions[i]) markersBarEnter[i] = createMarker(xEnter, yEnter, zEnter+1, "arrow", 1.5, 0, 255, 0, 255) local blip = createBlip(xEnter, yEnter, zEnter, 49) setBlipVisibleDistance(blip, 300) markersBarExit[i] = createMarker(xExit, yExit, zExit+0.1, "arrow", 1.5, 255, 0, 0, 255) setElementInterior(markersBarExit[i], intEnter, xExit, yExit, zExit-1) setElementDimension(markersBarExit[i], dimEnter) function enterBarBV:~(hitElement, matchingDimension) if (getElementType(hitElement) == "player") and (matchingDimension) then local vehicle = getPedOccupiedVehicle(hitElement) local playerAccount = getPlayerAccount(hitElement) if (not vehicle) then if (playerAccount) then if (not isGuestAccount(playerAccount)) then setElementInterior(hitElement, intEnter, xExit, yExit-2, zExit) setElementDimension(hitElement, dimEnter) setElementPosition(hitElement, xExit, yExit-2, zExit) setElementRotation(hitElement, 0, 0, 180) end end end end end addEventHandler("onMarkerHit", markersBarEnter[i], enterBarBV:~) function exitBarBV:~(hitElement, matchingDimension) if (getElementType(hitElement) == "player") and (matchingDimension) then setElementInterior(hitElement, 0, xEnter, yEnter-5, zEnter) setElementDimension(hitElement, 0) setElementPosition(hitElement, xEnter, yEnter-5, zEnter) end end addEventHandler("onMarkerHit", markersBarExit[i], exitBarBV:~) end function onPlayerBuyDrinkBVS(price) local money = getPlayerMoney(client) if (money >= price) then takePlayerMoney(client, price) local atualHealth = getElementHealth(client) setElementHealth(client, atualHealth + 20) setPedWalkingStyle(client, 126) triggerClientEvent(client, "client:currentEffectDrinks", resourceRoot) outputChatBox("Drink comprado com sucesso.", client, 0, 255, 0) else playSoundFrontEnd(client, 6) outputChatBox("Você não possui dinheiro suficiente.", client, 255, 0, 0) end end addEvent("server:onPlayerBuyDrinkBVS", true) addEventHandler("server:onPlayerBuyDrinkBVS", resourceRoot, onPlayerBuyDrinkBVS) function resetWalkingStyle() setPedWalkingStyle(client, 0) end addEvent("resetWalkingStyle", true) addEventHandler("resetWalkingStyle", resourceRoot, resetWalkingStyle) 29 minutes ago, Lord Henry said: Claro. O else é como um if sem condição. Bar Original: c.lua local sWidth, sHeight = guiGetScreenSize() local drawDrinksBVS = {} drawDrinksBVS.bgX = sWidth / 2 - 200 drawDrinksBVS.bgY = sHeight / 2 - 200 drawDrinksBVS.bgW = 400 drawDrinksBVS.bgH = 250 drawDrinksBVS.bgTopBarX = sWidth / 2 - 200 drawDrinksBVS.bgTopBarY = sHeight / 2 - 200 drawDrinksBVS.bgTopBarW = 400 drawDrinksBVS.bgTopBarH = 50 drawDrinksBVS.bgCloseX = sWidth / 2 - 200 drawDrinksBVS.bgCloseY = sHeight / 2 - 200 drawDrinksBVS.bgCloseW = 50 drawDrinksBVS.bgCloseH = 50 drawDrinksBVS.bgCatuabaX = sWidth / 2 - 170 drawDrinksBVS.bgCatuabaY = sHeight / 2 - 120 drawDrinksBVS.bgCatuabaW = 96 drawDrinksBVS.bgCatuabaH = 96 drawDrinksBVS.bgVodkaX = sWidth / 2 - 50 drawDrinksBVS.bgVodkaY = sHeight / 2 - 120 drawDrinksBVS.bgVodkaW = 96 drawDrinksBVS.bgVodkaH = 96 drawDrinksBVS.bgCervejaX = sWidth / 2 + 70 drawDrinksBVS.bgCervejaY = sHeight / 2 - 120 drawDrinksBVS.bgCervejaW = 96 drawDrinksBVS.bgCervejaH = 96 BarBVS = {} BarBVS.peds = {} BarBVS.pedsPos = { {240, 498.4, -77.9, 998.7, 11, 1}, {240, 498.4, -77.9, 998.7, 11, 2}, {240, 498.4, -77.9, 998.7, 11, 3}, {240, 498.4, -77.9, 998.7, 11, 4}, {240, 498.4, -77.9, 998.7, 11, 5}, {240, 498.4, -77.9, 998.7, 11, 6}, } BarBVS.markers = {} BarBVS.markersPos = { {498.4, -75.7, 997.7, 11, 1}, {498.4, -75.7, 997.7, 11, 2}, {498.4, -75.7, 997.7, 11, 3}, {498.4, -75.7, 997.7, 11, 4}, {498.4, -75.7, 997.7, 11, 5}, {498.4, -75.7, 997.7, 11, 6}, } function startClientDrinks() for k, v in pairs(BarBVS.pedsPos) do local id = #BarBVS.peds + 1 BarBVS.peds[id] = createPed(v[1], v[2], v[3], v[4]) setElementInterior(BarBVS.peds[id], v[5]) setElementDimension(BarBVS.peds[id], v[6]) addEventHandler("onClientPedDamage", BarBVS.peds[id], function() cancelEvent() end) setElementData(BarBVS.peds[id], "Ped:Msg", "Que tal uma bebida?") addEventHandler("onClientRender", getRootElement(), function() setSellerLookAt(BarBVS.peds[id]) end) end for k, v in pairs(BarBVS.markersPos) do local id = #BarBVS.markers + 1 BarBVS.markers[id] = createMarker(v[1], v[2], v[3], "cylinder", 1, 30, 180, 65, 200) setElementInterior(BarBVS.markers[id], v[4]) setElementDimension(BarBVS.markers[id], v[5]) addEventHandler('onClientMarkerHit', BarBVS.markers[id], function(player) if player == localPlayer then if not isEventHandlerAdded("onClientRender", root, drawDrinks) and not isEventHandlerAdded("onClientClick", root, clickEffectDrink) then addEventHandler("onClientRender", root, drawDrinks) addEventHandler("onClientClick", root, clickEffectDrink) showCursor(true) end end end) addEventHandler('onClientMarkerLeave', BarBVS.markers[id], function(player) if player == localPlayer then if isEventHandlerAdded("onClientRender", root, drawDrinks) and isEventHandlerAdded("onClientClick", root, clickEffectDrink) then removeEventHandler("onClientRender", root, drawDrinks) removeEventHandler("onClientClick", root, clickEffectDrink) showCursor(false) end end end) end end addEventHandler("onClientResourceStart", resourceRoot, startClientDrinks) function drawDrinks() dxDrawRectangle(drawDrinksBVS.bgX, drawDrinksBVS.bgY, drawDrinksBVS.bgW, drawDrinksBVS.bgH, tocolor(0, 0, 0, 180)) dxDrawRectangle(drawDrinksBVS.bgX-2, drawDrinksBVS.bgY-2, drawDrinksBVS.bgW+4, drawDrinksBVS.bgH+4, tocolor(0, 0, 0, 150)) dxDrawRectangle(drawDrinksBVS.bgTopBarX, drawDrinksBVS.bgTopBarY, drawDrinksBVS.bgTopBarW, drawDrinksBVS.bgTopBarH, tocolor(30, 180, 65, 200)) closeDrinksAplha = isMouseInPosition(drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseH) and 255 or 180 dxDrawRectangle(drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseH, tocolor(255, 0, 0, closeDrinksAplha)) dxDrawText("X", drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseX+drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseY+drawDrinksBVS.bgCloseH, tocolor(255,255,255,255), 2, "pricedown", "center", "center") dxDrawText("BEBIDAS", drawDrinksBVS.bgX, drawDrinksBVS.bgY - 200, drawDrinksBVS.bgX+drawDrinksBVS.bgW, drawDrinksBVS.bgY+drawDrinksBVS.bgH, tocolor(255,255,255,255), 1.5, "pricedown", "center", "center") if isMouseInPosition(drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY, drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaH) then dxDrawImage(drawDrinksBVS.bgCatuabaX-1, drawDrinksBVS.bgCatuabaY-1, drawDrinksBVS.bgCatuabaW+2, drawDrinksBVS.bgCatuabaH+2, "files/icon.png") end dxDrawImage(drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY, drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaH, "files/icon.png") dxDrawText("CATUABA", drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY + 120, drawDrinksBVS.bgCatuabaX+drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaY+drawDrinksBVS.bgCatuabaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") dxDrawText("200$", drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY + 170, drawDrinksBVS.bgCatuabaX+drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaY+drawDrinksBVS.bgCatuabaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") if isMouseInPosition(drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY, drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaH) then dxDrawImage(drawDrinksBVS.bgVodkaX-1, drawDrinksBVS.bgVodkaY-1, drawDrinksBVS.bgVodkaW+2, drawDrinksBVS.bgVodkaH+2, "files/icon.png") end dxDrawImage(drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY, drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaH, "files/icon.png") dxDrawText("VODKA", drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY + 120, drawDrinksBVS.bgVodkaX+drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaY+drawDrinksBVS.bgVodkaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") dxDrawText("150$", drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY + 170, drawDrinksBVS.bgVodkaX+drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaY+drawDrinksBVS.bgVodkaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") if isMouseInPosition(drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY, drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaH) then dxDrawImage(drawDrinksBVS.bgCervejaX-1, drawDrinksBVS.bgCervejaY-1, drawDrinksBVS.bgCervejaW+2, drawDrinksBVS.bgCervejaH+2, "files/icon.png") end dxDrawImage(drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY, drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaH, "files/icon.png") dxDrawText("CERVEJA", drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY + 120, drawDrinksBVS.bgCervejaX+drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaY+drawDrinksBVS.bgCervejaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") dxDrawText("100$", drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY + 170, drawDrinksBVS.bgCervejaX+drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaY+drawDrinksBVS.bgCervejaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") end function clickEffectDrink(button,state) if button == "left" and state == "up" then if isMouseInPosition(drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY, drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 200) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY, drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 150) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY, drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 100) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseH) then if isEventHandlerAdded("onClientRender", root, drawDrinks) and isEventHandlerAdded("onClientClick", root, clickEffectDrink) then removeEventHandler("onClientRender", root, drawDrinks) removeEventHandler("onClientClick", root, clickEffectDrink) showCursor(false) end end end end function currentEffectDrinks() timerControlDrinks = setTimer(function() setPedControlState(localPlayer, "walk", true) end, 100, 0) setWindVelocity(100, 100, 0) setCameraShakeLevel(255) -------------------------------------------------------------------------------------------- timerExpireDrinks = setTimer(function() resetWindVelocity() setCameraShakeLevel(1) if isTimer(timerControlDrinks) then killTimer(timerControlDrinks) end setPedControlState(localPlayer, "walk", false) outputChatBox("O efeito da bebida acabou.", 0, 255, 0) triggerServerEvent("resetWalkingStyle",resourceRoot) end, math.random(40000, 60000), 1) end addEvent("client:currentEffectDrinks", true) addEventHandler("client:currentEffectDrinks", resourceRoot, currentEffectDrinks) function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end function setSellerLookAt(ped) if(isElement(ped)) then setPedLookAt(ped, 0.0, 0.0, 0.0, 3000, localPlayer) end end s.lua local markersBarPositions = { {2348.547, -1372.678, 24.398, 501.900, -67.600, 999.700, 11, 1}, -- 1 {1000.592, -919.914, 42.328, 501.900, -67.600, 999.700, 11, 2}, -- 2 {2369.240, 1984.234, 10.820, 501.900, -67.600, 999.700, 11, 3}, -- 3 {-2432.25, -183.043, 35.312, 501.900, -67.600, 999.700, 11, 4}, -- 4 } local markersBarEnter = {} local markersBarExit = {} for i=1, #markersBarPositions do local xEnter, yEnter, zEnter, xExit, yExit, zExit, intEnter, dimEnter = unpack(markersBarPositions[i]) markersBarEnter[i] = createMarker(xEnter, yEnter, zEnter+1, "arrow", 1.5, 0, 255, 0, 255) local blip = createBlip(xEnter, yEnter, zEnter, 49) setBlipVisibleDistance(blip, 300) markersBarExit[i] = createMarker(xExit, yExit, zExit+0.1, "arrow", 1.5, 255, 0, 0, 255) setElementInterior(markersBarExit[i], intEnter, xExit, yExit, zExit-1) setElementDimension(markersBarExit[i], dimEnter) function enterBarBV:~(hitElement, matchingDimension) if (getElementType(hitElement) == "player") and (matchingDimension) then local vehicle = getPedOccupiedVehicle(hitElement) local playerAccount = getPlayerAccount(hitElement) if (not vehicle) then if (playerAccount) then if (not isGuestAccount(playerAccount)) then setElementInterior(hitElement, intEnter, xExit, yExit-2, zExit) setElementDimension(hitElement, dimEnter) setElementPosition(hitElement, xExit, yExit-2, zExit) setElementRotation(hitElement, 0, 0, 180) end end end end end addEventHandler("onMarkerHit", markersBarEnter[i], enterBarBV:~) function exitBarBV:~(hitElement, matchingDimension) if (getElementType(hitElement) == "player") and (matchingDimension) then setElementInterior(hitElement, 0, xEnter, yEnter-5, zEnter) setElementDimension(hitElement, 0) setElementPosition(hitElement, xEnter, yEnter-5, zEnter) end end addEventHandler("onMarkerHit", markersBarExit[i], exitBarBV:~) end function onPlayerBuyDrinkBVS(price) local money = getPlayerMoney(client) if (money >= price) then takePlayerMoney(client, price) local atualHealth = getElementHealth(client) setElementHealth(client, atualHealth + 20) setPedWalkingStyle(client, 126) triggerClientEvent(client, "client:currentEffectDrinks", resourceRoot) outputChatBox("Drink comprado com sucesso.", client, 0, 255, 0) else playSoundFrontEnd(client, 6) outputChatBox("Você não possui dinheiro suficiente.", client, 255, 0, 0) end end addEvent("server:onPlayerBuyDrinkBVS", true) addEventHandler("server:onPlayerBuyDrinkBVS", resourceRoot, onPlayerBuyDrinkBVS) function resetWalkingStyle() setPedWalkingStyle(client, 0) end addEvent("resetWalkingStyle", true) addEventHandler("resetWalkingStyle", resourceRoot, resetWalkingStyle) Edited January 8, 2019 by #Horus Link to comment
DNL291 Posted January 8, 2019 Share Posted January 8, 2019 9 hours ago, Lord Henry said: E vc ainda não corrigiu os símbolos :~ nos nomes das funções. -- Ainda faltou indentar as tabelas do c.lua e as linhas: 138,145,152,157 Link to comment
#Horus Posted January 10, 2019 Author Share Posted January 10, 2019 On 08/01/2019 at 20:01, DNL291 said: -- Ainda faltou indentar as tabelas do c.lua e as linhas: 138,145,152,157 Acho que agora está tudo correto Meu Bar: c.lua - bar do horus ( pra facilitar ) --[[ ################################################ # # # Resource Desenvolvido por: # # #Horus # # # # # ################################################ ]] local ped = createPed(240, 497.283, -77.876, 998.765, 0) local ped2 = createPed(240, 497.283, -77.876, 998.765, 0) local ped3 = createPed(240, 497.283, -77.876, 998.765, 0) local ped4 = createPed(240, 497.283, -77.876, 998.765, 0) setElementInterior(ped, 11) setElementDimension(ped, 1) setElementFrozen(ped, true) setElementInterior(ped2, 11) setElementDimension(ped2, 2) setElementFrozen(ped2, true) setElementInterior(ped3, 11) setElementDimension(ped3, 3) setElementFrozen(ped3, true) setElementInterior(ped4, 11) setElementDimension(ped4, 4) setElementFrozen(ped4, true) local dxfont0_fonte = dxCreateFont("font/fonte.ttf", 10) local screenW, screenH = guiGetScreenSize() local resW, resH = 1360,768 local x, y = (screenW/resW), (screenH/resH) function setBlur(state) setElementData(localPlayer, "showBlur", state) end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end function dxDrawLinedRectangle( x, y, width, height, color, _width, postGUI ) _width = _width or 1 dxDrawLine ( x, y, x+width, y, color, _width, postGUI ) -- Top dxDrawLine ( x, y, x, y+height, color, _width, postGUI ) -- Left dxDrawLine ( x, y+height, x+width, y+height, color, _width, postGUI ) -- Bottom return dxDrawLine ( x+width, y, x+width, y+height, color, _width, postGUI ) -- Right end function cancelPedDamage(attacker) cancelEvent() end addEventHandler("onClientPedDamage", ped, cancelPedDamage) addEventHandler("onClientPedDamage", ped2, cancelPedDamage) addEventHandler("onClientPedDamage", ped3, cancelPedDamage) addEventHandler("onClientPedDamage", ped4, cancelPedDamage) function drawDrinks() tocolor1 = tocolor(0, 0, 0, 150) if isCursorOnElement(screenW * 0.3257, screenH * 0.4115, screenW * 0.3272, screenH * 0.0469) then -- CATUABA tocolor1 = tocolor(16, 102, 231, 100) end tocolor2 = tocolor(0, 0, 0, 150) if isCursorOnElement(screenW * 0.3257, screenH * 0.4583, screenW * 0.3272, screenH * 0.0469) then -- VODCA tocolor2 = tocolor(16, 102, 231, 100) end tocolor3 = tocolor(0, 0, 0, 150) if isCursorOnElement(screenW * 0.3257, screenH * 0.5052, screenW * 0.3272, screenH * 0.0469) then -- CERVEJA tocolor3 = tocolor(16, 102, 231, 100) end tocolorF = tocolor(217, 0, 5, 0) if isCursorOnElement(screenW * 0.6426, screenH * 0.3490, screenW * 0.0221, screenH * 0.0417) then -- CLOSE tocolorF = tocolor(217, 0, 5, 150) end -- ################# BACKGROUND ################# dxDrawRectangle(screenW * 0.3140, screenH * 0.3490, screenW * 0.3507, screenH * 0.3997, tocolor(0, 0, 0, 150), false) dxDrawRectangle(screenW * 0.3140, screenH * 0.3490, screenW * 0.3507, screenH * 0.0417, tocolor(0, 0, 0, 150), false) -- ################# BUTTONS ################# dxDrawRectangle(screenW * 0.3257, screenH * 0.4115, screenW * 0.3272, screenH * 0.0469, tocolor1, false) -- CATUABA dxDrawRectangle(screenW * 0.3257, screenH * 0.4583, screenW * 0.3272, screenH * 0.0469, tocolor2, false) -- VODCA dxDrawRectangle(screenW * 0.3257, screenH * 0.5052, screenW * 0.3272, screenH * 0.0469, tocolor3, false) -- CERVEJA dxDrawRectangle(screenW * 0.6426, screenH * 0.3490, screenW * 0.0221, screenH * 0.0417, tocolorF, false) -- CLOSE -- ################# IMAGENS ################# dxDrawImage(screenW * 0.3287, screenH * 0.4180, screenW * 0.0191, screenH * 0.0352, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) dxDrawImage(screenW * 0.3287, screenH * 0.5573, screenW * 0.0191, screenH * 0.0339, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) dxDrawImage(screenW * 0.3257, screenH * 0.6458, screenW * 0.0265, screenH * 0.0430, "", 0, 0, 0, tocolor(254, 254, 254, 205), false) dxDrawImage(screenW * 0.3287, screenH * 0.4661, screenW * 0.0191, screenH * 0.0352, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) dxDrawImage(screenW * 0.3287, screenH * 0.5143, screenW * 0.0191, screenH * 0.0352, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) dxDrawImage(screenW * 0.3287, screenH * 0.6042, screenW * 0.0191, screenH * 0.0339, "", 0, 0, 0, tocolor(255, 255, 255, 217), false) -- ################# TEXTOS ################# dxDrawText("Bar Passa Tempo - MENU", screenW * 0.4280, screenH * 0.3600, screenW * 0.4324, screenH * 0.3984, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("X", screenW * 0.6500, screenH * 0.3555, screenW * 0.7610, screenH * 0.3984, tocolor(255, 255, 255, 202), 1.30, "default-bold", "left", "top", false, false, false, true, false) dxDrawText("Catuaba", screenW * 0.3522, screenH * 0.4232, screenW * 0.4632, screenH * 0.4661, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("Vodca", screenW * 0.3522, screenH * 0.4714, screenW * 0.4632, screenH * 0.5143, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("Cerveja", screenW * 0.3522, screenH * 0.5183, screenW * 0.4632, screenH * 0.5573, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("#1066E7R$ #FFFFFF200", screenW * 0.6044, screenH * 0.4245, screenW * 0.7154, screenH * 0.4674, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("#1066E7R$ #FFFFFF150", screenW * 0.6044, screenH * 0.4674, screenW * 0.7154, screenH * 0.5104, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("#1066E7R$ #FFFFFF100", screenW * 0.6044, screenH * 0.5182, screenW * 0.7154, screenH * 0.5612, tocolor(255, 255, 255, 202), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false) dxDrawText("Selecione uma bebida abaixo:", screenW * 0.4350, screenH * 0.3898, screenW * 0.4324, screenH * 0.7487, tocolor(255, 255, 255, 202), 0.8, dxfont0_fonte, "left", "top", false, false, false, true, false) end function render() local screenx, screeny, worldx, worldy, worldz = getCursorPosition() local px, py, pz = getCameraMatrix() local hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, worldx, worldy, worldz ) local tx, ty, tz = getElementPosition(localPlayer) local rx, ry, rz = getElementPosition(ped) local distancia = getDistanceBetweenPoints3D(tx, ty, tz, rx, ry, rz) if not isEventHandlerAdded("onClientRender", root, drawDrink) then if (distancia < 5) then if hit then if elementHit == ped then addEventHandler("onClientRender", root, drawDrinks) showCursor(true) showChat(false) setElementData(localPlayer, "showBlur", true) end if elementHit == ped2 then addEventHandler("onClientRender", root, drawDrinks) showCursor(true) showChat(false) setElementData(localPlayer, "showBlur", true) end if elementHit == ped3 then addEventHandler("onClientRender", root, drawDrinks) showCursor(true) showChat(false) setElementData(localPlayer, "showBlur", true) end if elementHit == ped4 then addEventHandler("onClientRender", root, drawDrinks) showCursor(true) showChat(false) setElementData(localPlayer, "showBlur", true) end end end end end addEventHandler("onClientClick", root, render) local rootElement = getRootElement() local screenWidth, screenHeight = guiGetScreenSize() local maxrange = 9 function NPC2nametag() local pedX, pedY, pedZ = getElementPosition(ped) local sx, sy = getScreenFromWorldPosition (pedX,pedY,pedZ +1) local cameraX, cameraY, cameraZ = getCameraMatrix() if sx then if getDistanceBetweenPoints3D(cameraX,cameraY,cameraZ,pedX,pedY,pedZ) <= maxrange then if not getElementData(localPlayer, "showBlur") then dxDrawRectangle(sx - x*110,sy + y*57, screenW * 0.2514, screenH * 0.0630, tocolor(0, 0, 0, 165), false) dxDrawText("Garçom - Bebidas e Diversão;",sx - 25 ,sy + 60,screenWidth, screenHeight,tocolor ( 255, 255, 255, 230 ), 0.9,dxfont0_fonte) dxDrawText('Pressione #1066e7"M" #FFFFFFe clique no garçom para abrir o menu!',sx - 100,sy + 80,screenWidth, screenHeight,tocolor ( 255, 255, 255, 230 ), 0.8,dxfont0_fonte, "left", "top", false, false, false, true, false) end end end end addEventHandler("onClientRender",rootElement, NPC2nametag) function closePanel(_,state) if isEventHandlerAdded("onClientRender", root, drawDrinks) then if state == "down" then if isCursorOnElement(screenW * 0.6426, screenH * 0.3490, screenW * 0.0221, screenH * 0.0417) then showCursor(false) showChat(true) playSound("sfx/hit.mp3", false) removeEventHandler("onClientRender", root, drawDrinks) setElementData(localPlayer, "showBlur", false) end end end end addEventHandler("onClientClick", root, closePanel) function Catuaba(_,state) if isEventHandlerAdded("onClientRender", root, drawDrinks) then if state == "down" then if isCursorOnElement(screenW * 0.3257, screenH * 0.4115, screenW * 0.3272, screenH * 0.0469) then if (not isTimer(timerExpireDrinks)) then setBlur(false) triggerServerEvent("server:onPlayerBuyDrinkBVS", localPlayer, 200) removeEventHandler("onClientRender", root, drawDrinks) showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) else outputChatBox("#1066E7Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", source, 255, 255, 255, true) end end end end end addEventHandler("onClientClick", root, Catuaba) function Vodca(_,state) if isEventHandlerAdded("onClientRender", root, drawDrinks) then if state == "down" then if isCursorOnElement(screenW * 0.3257, screenH * 0.4583, screenW * 0.3272, screenH * 0.0469) then if (not isTimer(timerExpireDrinks)) then setBlur(false) triggerServerEvent("server:onPlayerBuyDrinkBVS", localPlayer, 150) removeEventHandler("onClientRender", root, drawDrinks) showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) else outputChatBox("#1066E7Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", source, 255, 255, 255, true) end end end end end addEventHandler("onClientClick", root, Vodca) function Cerveja(_,state) if isEventHandlerAdded("onClientRender", root, drawDrinks) then if state == "down" then if isCursorOnElement(screenW * 0.3257, screenH * 0.5052, screenW * 0.3272, screenH * 0.0469) then if (not isTimer(timerExpireDrinks)) then setBlur(false) triggerServerEvent("server:onPlayerBuyDrinkBVS", localPlayer, 100) removeEventHandler("onClientRender", root, drawDrinks) showChat(true) showCursor(false) playSound("sfx/hit.mp3", false) else outputChatBox("#1066E7Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", source, 255, 255, 255, true) end end end end end addEventHandler("onClientClick", root, Cerveja) function currentEffectDrinks() timerControlDrinks = setTimer(function() setPedControlState(localPlayer, "walk", true) end, 100, 0) setWindVelocity(100, 100, 0) setCameraShakeLevel(255) -------------------------------------------------------------------------------------------- timerExpireDrinks = setTimer(function() resetWindVelocity() setCameraShakeLevel(1) if isTimer(timerControlDrinks) then killTimer(timerControlDrinks) end setPedControlState(localPlayer, "walk", false) outputChatBox("O efeito da bebida acabou.", 0, 255, 0) triggerServerEvent("resetWalkingStyle",resourceRoot) end, math.random(40000, 60000), 1) end addEvent("client:currentEffectDrinks", true) addEventHandler("client:currentEffectDrinks", resourceRoot, currentEffectDrinks) function isCursorOnElement( posX, posY, width, height ) if isCursorShowing( ) then local mouseX, mouseY = getCursorPosition( ) local clientW, clientH = guiGetScreenSize( ) local mouseX, mouseY = mouseX * clientW, mouseY * clientH if ( mouseX > posX and mouseX < ( posX + width ) and mouseY > posY and mouseY < ( posY + height ) ) then return true end end return false end s.lua - bar do horus ( pra facilitar ) local markersBarPositions = { {2348.547, -1372.678, 24.398, 501.900, -67.600, 999.700, 11, 1}, -- 1 {1000.592, -919.914, 42.328, 501.900, -67.600, 999.700, 11, 2}, -- 2 {2369.240, 1984.234, 10.820, 501.900, -67.600, 999.700, 11, 3}, -- 3 {-2432.25, -183.043, 35.312, 501.900, -67.600, 999.700, 11, 4}, -- 4 } local markersBarEnter = {} local markersBarExit = {} for i=1, #markersBarPositions do local xEnter, yEnter, zEnter, xExit, yExit, zExit, intEnter, dimEnter = unpack(markersBarPositions[i]) markersBarEnter[i] = createMarker(xEnter, yEnter, zEnter+1, "arrow", 1.5, 0, 255, 0, 255) local blip = createBlip(xEnter, yEnter, zEnter, 49) setBlipVisibleDistance(blip, 300) markersBarExit[i] = createMarker(xExit, yExit, zExit+0.1, "arrow", 1.5, 255, 0, 0, 255) setElementInterior(markersBarExit[i], intEnter, xExit, yExit, zExit-1) setElementDimension(markersBarExit[i], dimEnter) function enterBarBV:~(hitElement, matchingDimension) if (getElementType(hitElement) == "player") and (matchingDimension) then local vehicle = getPedOccupiedVehicle(hitElement) local playerAccount = getPlayerAccount(hitElement) if (not vehicle) then if (playerAccount) then if (not isGuestAccount(playerAccount)) then setElementInterior(hitElement, intEnter, xExit, yExit-2, zExit) setElementDimension(hitElement, dimEnter) setElementPosition(hitElement, xExit, yExit-2, zExit) setElementRotation(hitElement, 0, 0, 180) end end end end end addEventHandler("onMarkerHit", markersBarEnter[i], enterBarBV:~) function exitBarBV:~(hitElement, matchingDimension) if (getElementType(hitElement) == "player") and (matchingDimension) then setElementInterior(hitElement, 0, xEnter, yEnter-5, zEnter) setElementDimension(hitElement, 0) setElementPosition(hitElement, xEnter, yEnter-5, zEnter) end end addEventHandler("onMarkerHit", markersBarExit[i], exitBarBV:~) end function onPlayerBuyDrinkBVS(price) local money = getPlayerMoney(client) if (money >= price) then takePlayerMoney(client, price) local atualHealth = getElementHealth(client) setElementHealth(client, atualHealth + 20) setPedWalkingStyle(client, 126) triggerClientEvent(client, "client:currentEffectDrinks", resourceRoot) outputChatBox("Drink comprado com sucesso.", client, 0, 255, 0) else playSoundFrontEnd(client, 6) outputChatBox("Você não possui dinheiro suficiente.", client, 255, 0, 0) end end addEvent("server:onPlayerBuyDrinkBVS", true) addEventHandler("server:onPlayerBuyDrinkBVS", resourceRoot, onPlayerBuyDrinkBVS) function resetWalkingStyle() setPedWalkingStyle(client, 0) end addEvent("resetWalkingStyle", true) addEventHandler("resetWalkingStyle", resourceRoot, resetWalkingStyle) On 08/01/2019 at 20:01, DNL291 said: -- Ainda faltou indentar as tabelas do c.lua e as linhas: 138,145,152,157 Bar Original: c.lua - bar original ( pra facilitar ) local sWidth, sHeight = guiGetScreenSize() local drawDrinksBVS = {} drawDrinksBVS.bgX = sWidth / 2 - 200 drawDrinksBVS.bgY = sHeight / 2 - 200 drawDrinksBVS.bgW = 400 drawDrinksBVS.bgH = 250 drawDrinksBVS.bgTopBarX = sWidth / 2 - 200 drawDrinksBVS.bgTopBarY = sHeight / 2 - 200 drawDrinksBVS.bgTopBarW = 400 drawDrinksBVS.bgTopBarH = 50 drawDrinksBVS.bgCloseX = sWidth / 2 - 200 drawDrinksBVS.bgCloseY = sHeight / 2 - 200 drawDrinksBVS.bgCloseW = 50 drawDrinksBVS.bgCloseH = 50 drawDrinksBVS.bgCatuabaX = sWidth / 2 - 170 drawDrinksBVS.bgCatuabaY = sHeight / 2 - 120 drawDrinksBVS.bgCatuabaW = 96 drawDrinksBVS.bgCatuabaH = 96 drawDrinksBVS.bgVodkaX = sWidth / 2 - 50 drawDrinksBVS.bgVodkaY = sHeight / 2 - 120 drawDrinksBVS.bgVodkaW = 96 drawDrinksBVS.bgVodkaH = 96 drawDrinksBVS.bgCervejaX = sWidth / 2 + 70 drawDrinksBVS.bgCervejaY = sHeight / 2 - 120 drawDrinksBVS.bgCervejaW = 96 drawDrinksBVS.bgCervejaH = 96 BarBVS = {} BarBVS.peds = {} BarBVS.pedsPos = { {240, 498.4, -77.9, 998.7, 11, 1}, {240, 498.4, -77.9, 998.7, 11, 2}, {240, 498.4, -77.9, 998.7, 11, 3}, {240, 498.4, -77.9, 998.7, 11, 4}, {240, 498.4, -77.9, 998.7, 11, 5}, {240, 498.4, -77.9, 998.7, 11, 6}, } BarBVS.markers = {} BarBVS.markersPos = { {498.4, -75.7, 997.7, 11, 1}, {498.4, -75.7, 997.7, 11, 2}, {498.4, -75.7, 997.7, 11, 3}, {498.4, -75.7, 997.7, 11, 4}, {498.4, -75.7, 997.7, 11, 5}, {498.4, -75.7, 997.7, 11, 6}, } function startClientDrinks() for k, v in pairs(BarBVS.pedsPos) do local id = #BarBVS.peds + 1 BarBVS.peds[id] = createPed(v[1], v[2], v[3], v[4]) setElementInterior(BarBVS.peds[id], v[5]) setElementDimension(BarBVS.peds[id], v[6]) addEventHandler("onClientPedDamage", BarBVS.peds[id], function() cancelEvent() end) setElementData(BarBVS.peds[id], "Ped:Msg", "Que tal uma bebida?") addEventHandler("onClientRender", getRootElement(), function() setSellerLookAt(BarBVS.peds[id]) end) end for k, v in pairs(BarBVS.markersPos) do local id = #BarBVS.markers + 1 BarBVS.markers[id] = createMarker(v[1], v[2], v[3], "cylinder", 1, 30, 180, 65, 200) setElementInterior(BarBVS.markers[id], v[4]) setElementDimension(BarBVS.markers[id], v[5]) addEventHandler('onClientMarkerHit', BarBVS.markers[id], function(player) if player == localPlayer then if not isEventHandlerAdded("onClientRender", root, drawDrinks) and not isEventHandlerAdded("onClientClick", root, clickEffectDrink) then addEventHandler("onClientRender", root, drawDrinks) addEventHandler("onClientClick", root, clickEffectDrink) showCursor(true) end end end) addEventHandler('onClientMarkerLeave', BarBVS.markers[id], function(player) if player == localPlayer then if isEventHandlerAdded("onClientRender", root, drawDrinks) and isEventHandlerAdded("onClientClick", root, clickEffectDrink) then removeEventHandler("onClientRender", root, drawDrinks) removeEventHandler("onClientClick", root, clickEffectDrink) showCursor(false) end end end) end end addEventHandler("onClientResourceStart", resourceRoot, startClientDrinks) function drawDrinks() dxDrawRectangle(drawDrinksBVS.bgX, drawDrinksBVS.bgY, drawDrinksBVS.bgW, drawDrinksBVS.bgH, tocolor(0, 0, 0, 180)) dxDrawRectangle(drawDrinksBVS.bgX-2, drawDrinksBVS.bgY-2, drawDrinksBVS.bgW+4, drawDrinksBVS.bgH+4, tocolor(0, 0, 0, 150)) dxDrawRectangle(drawDrinksBVS.bgTopBarX, drawDrinksBVS.bgTopBarY, drawDrinksBVS.bgTopBarW, drawDrinksBVS.bgTopBarH, tocolor(30, 180, 65, 200)) closeDrinksAplha = isMouseInPosition(drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseH) and 255 or 180 dxDrawRectangle(drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseH, tocolor(255, 0, 0, closeDrinksAplha)) dxDrawText("X", drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseX+drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseY+drawDrinksBVS.bgCloseH, tocolor(255,255,255,255), 2, "pricedown", "center", "center") dxDrawText("BEBIDAS", drawDrinksBVS.bgX, drawDrinksBVS.bgY - 200, drawDrinksBVS.bgX+drawDrinksBVS.bgW, drawDrinksBVS.bgY+drawDrinksBVS.bgH, tocolor(255,255,255,255), 1.5, "pricedown", "center", "center") if isMouseInPosition(drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY, drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaH) then dxDrawImage(drawDrinksBVS.bgCatuabaX-1, drawDrinksBVS.bgCatuabaY-1, drawDrinksBVS.bgCatuabaW+2, drawDrinksBVS.bgCatuabaH+2, "files/icon.png") end dxDrawImage(drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY, drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaH, "files/icon.png") dxDrawText("CATUABA", drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY + 120, drawDrinksBVS.bgCatuabaX+drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaY+drawDrinksBVS.bgCatuabaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") dxDrawText("200$", drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY + 170, drawDrinksBVS.bgCatuabaX+drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaY+drawDrinksBVS.bgCatuabaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") if isMouseInPosition(drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY, drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaH) then dxDrawImage(drawDrinksBVS.bgVodkaX-1, drawDrinksBVS.bgVodkaY-1, drawDrinksBVS.bgVodkaW+2, drawDrinksBVS.bgVodkaH+2, "files/icon.png") end dxDrawImage(drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY, drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaH, "files/icon.png") dxDrawText("VODKA", drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY + 120, drawDrinksBVS.bgVodkaX+drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaY+drawDrinksBVS.bgVodkaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") dxDrawText("150$", drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY + 170, drawDrinksBVS.bgVodkaX+drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaY+drawDrinksBVS.bgVodkaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") if isMouseInPosition(drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY, drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaH) then dxDrawImage(drawDrinksBVS.bgCervejaX-1, drawDrinksBVS.bgCervejaY-1, drawDrinksBVS.bgCervejaW+2, drawDrinksBVS.bgCervejaH+2, "files/icon.png") end dxDrawImage(drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY, drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaH, "files/icon.png") dxDrawText("CERVEJA", drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY + 120, drawDrinksBVS.bgCervejaX+drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaY+drawDrinksBVS.bgCervejaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") dxDrawText("100$", drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY + 170, drawDrinksBVS.bgCervejaX+drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaY+drawDrinksBVS.bgCervejaH, tocolor(255,255,255,255), 1.5, "clear", "center", "center") end function clickEffectDrink(button,state) if button == "left" and state == "up" then if isMouseInPosition(drawDrinksBVS.bgCatuabaX, drawDrinksBVS.bgCatuabaY, drawDrinksBVS.bgCatuabaW, drawDrinksBVS.bgCatuabaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 200) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgVodkaX, drawDrinksBVS.bgVodkaY, drawDrinksBVS.bgVodkaW, drawDrinksBVS.bgVodkaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 150) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgCervejaX, drawDrinksBVS.bgCervejaY, drawDrinksBVS.bgCervejaW, drawDrinksBVS.bgCervejaH) then if (not isTimer(timerExpireDrinks)) then triggerServerEvent("server:onPlayerBuyDrinkBVS", resourceRoot, 100) else playSoundFrontEnd(6) outputChatBox("Você ainda está com efeito da bebida, espere mais um pouco para beber de novo.", 255, 0, 0) end elseif isMouseInPosition(drawDrinksBVS.bgCloseX, drawDrinksBVS.bgCloseY, drawDrinksBVS.bgCloseW, drawDrinksBVS.bgCloseH) then if isEventHandlerAdded("onClientRender", root, drawDrinks) and isEventHandlerAdded("onClientClick", root, clickEffectDrink) then removeEventHandler("onClientRender", root, drawDrinks) removeEventHandler("onClientClick", root, clickEffectDrink) showCursor(false) end end end end function currentEffectDrinks() timerControlDrinks = setTimer(function() setPedControlState(localPlayer, "walk", true) end, 100, 0) setWindVelocity(100, 100, 0) setCameraShakeLevel(255) -------------------------------------------------------------------------------------------- timerExpireDrinks = setTimer(function() resetWindVelocity() setCameraShakeLevel(1) if isTimer(timerControlDrinks) then killTimer(timerControlDrinks) end setPedControlState(localPlayer, "walk", false) outputChatBox("O efeito da bebida acabou.", 0, 255, 0) triggerServerEvent("resetWalkingStyle",resourceRoot) end, math.random(40000, 60000), 1) end addEvent("client:currentEffectDrinks", true) addEventHandler("client:currentEffectDrinks", resourceRoot, currentEffectDrinks) function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end function setSellerLookAt(ped) if(isElement(ped)) then setPedLookAt(ped, 0.0, 0.0, 0.0, 3000, localPlayer) end end s.lua - bar original ( pra facilitar ) local markersBarPositions = { {2348.547, -1372.678, 24.398, 501.900, -67.600, 999.700, 11, 1}, -- 1 {1000.592, -919.914, 42.328, 501.900, -67.600, 999.700, 11, 2}, -- 2 {2369.240, 1984.234, 10.820, 501.900, -67.600, 999.700, 11, 3}, -- 3 {-2432.25, -183.043, 35.312, 501.900, -67.600, 999.700, 11, 4}, -- 4 } local markersBarEnter = {} local markersBarExit = {} for i=1, #markersBarPositions do local xEnter, yEnter, zEnter, xExit, yExit, zExit, intEnter, dimEnter = unpack(markersBarPositions[i]) markersBarEnter[i] = createMarker(xEnter, yEnter, zEnter+1, "arrow", 1.5, 0, 255, 0, 255) local blip = createBlip(xEnter, yEnter, zEnter, 49) setBlipVisibleDistance(blip, 300) markersBarExit[i] = createMarker(xExit, yExit, zExit+0.1, "arrow", 1.5, 255, 0, 0, 255) setElementInterior(markersBarExit[i], intEnter, xExit, yExit, zExit-1) setElementDimension(markersBarExit[i], dimEnter) function enterBarBV:~(hitElement, matchingDimension) if (getElementType(hitElement) == "player") and (matchingDimension) then local vehicle = getPedOccupiedVehicle(hitElement) local playerAccount = getPlayerAccount(hitElement) if (not vehicle) then if (playerAccount) then if (not isGuestAccount(playerAccount)) then setElementInterior(hitElement, intEnter, xExit, yExit-2, zExit) setElementDimension(hitElement, dimEnter) setElementPosition(hitElement, xExit, yExit-2, zExit) setElementRotation(hitElement, 0, 0, 180) end end end end end addEventHandler("onMarkerHit", markersBarEnter[i], enterBarBV:~) function exitBarBV:~(hitElement, matchingDimension) if (getElementType(hitElement) == "player") and (matchingDimension) then setElementInterior(hitElement, 0, xEnter, yEnter-5, zEnter) setElementDimension(hitElement, 0) setElementPosition(hitElement, xEnter, yEnter-5, zEnter) end end addEventHandler("onMarkerHit", markersBarExit[i], exitBarBV:~) end function onPlayerBuyDrinkBVS(price) local money = getPlayerMoney(client) if (money >= price) then takePlayerMoney(client, price) local atualHealth = getElementHealth(client) setElementHealth(client, atualHealth + 20) setPedWalkingStyle(client, 126) triggerClientEvent(client, "client:currentEffectDrinks", resourceRoot) outputChatBox("Drink comprado com sucesso.", client, 0, 255, 0) else playSoundFrontEnd(client, 6) outputChatBox("Você não possui dinheiro suficiente.", client, 255, 0, 0) end end addEvent("server:onPlayerBuyDrinkBVS", true) addEventHandler("server:onPlayerBuyDrinkBVS", resourceRoot, onPlayerBuyDrinkBVS) function resetWalkingStyle() setPedWalkingStyle(client, 0) end addEvent("resetWalkingStyle", true) addEventHandler("resetWalkingStyle", resourceRoot, resetWalkingStyle) @Repostando o codigo atualizado Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now