Jump to content

Não consigo abrir meu painel com o marker me ajudem!!


Recommended Posts

Tenho um painel de rebaixar veículos, mas eu queria abrir esse painel quando um veiculo passa-se encima do marker.

Server

local marcacao = createMarker (338, -1776, 4.1, "cylinder", 2, 0, 255, 255, 255)

function open (source)
triggerClientEvent (source, "open", root)
end
addEventHandler ("onMarkerHit", marcacao, open)



-------[SUSPENS�O]-------
function Susp1()
        local vehicle = getPedOccupiedVehicle(source)
                if not vehicle then return end
                setVehicleHandling ( vehicle, "suspensionLowerLimit", (getVehicleHandling(vehicle)['suspensionLowerLimit'])-0.1 )
        end
addEvent("subir", true)
addEventHandler("subir", root, Susp1)


function Susp2()
        local vehicle = getPedOccupiedVehicle(source)
                if not vehicle then return end
                setVehicleHandling ( vehicle, "suspensionLowerLimit", (getVehicleHandling(vehicle)['suspensionLowerLimit'])+0.1 )
        end
addEvent("descer", true)
addEventHandler("descer", root, Susp2)

Client

local screenW2,screenH2 = guiGetScreenSize()
local resW2, resH2 = 1280,960
local x, y =  (screenW2/resW2), (screenH2/resH2)

local newFont1 = dxCreateFont( "font/font.ttf", 32 )

function dx (_,state)
if painel == false then
showCursor(true)
showChat(false)
playSound("")
addEventHandler("onClientRender", root, dx)
painel = true
else
showCursor(false)
showChat(true)
playSound("")
removeEventHandler("onClientRender", root, dx)
painel = false
end
end

function abrirpainel ()
if painel == false then
addEventHandler ("onClientRender", root, dx)
showCursor (true)
painel = true
end
end
addEvent ("open", true)
addEventHandler ("open", root, abrirpainel)

function fecharpainel (_,state)
if painel == true then
if state == "down" then
if isCursorOnElement (685, 537, 719, 563) then
removeEventHandler ("onClientRender", root, dx)
showCursor (false)
painel = false
end
end
end
end
addEventHandler ("onClientClick", root, fecharpainel)
    
local x,y = guiGetScreenSize()
 function isCursorOnElement(x,y,w,h)
        local mx,my = getCursorPosition ()
        local fullx,fully = guiGetScreenSize()
        cursorx,cursory = mx*fullx,my*fully
        if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
            return true
        else
            return false
        end
    end
end



painel = false
function dx ()

     

        dxDrawImage(x*565, y*534, x*316, y*236, "fotos/car.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(x*611, y*701, x*65, y*88, "fotos/seta1.png", 180, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(x*788, y*701, x*65, y*88, "fotos/seta1.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)

  


	


      
        dxDrawText("Rebaixar carro", x*240, y*227, x*1170, y*307, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "center", false, false, false, false, false)
   
		
    end
end
    


-------[SUSPENSÃO]-------
function subir (_, state)
if painel == true then
if state == "down" then
if isCursorOnElement (x*788, y*701, x*65, y*88) then
local theVehicle = getPedOccupiedVehicle(localPlayer)
if theVehicle and getVehicleController(theVehicle) == localPlayer then
triggerServerEvent ("subir", getLocalPlayer())
playSound("Som/murchado.mp3")
end
end
end
end
end
addEventHandler ("onClientClick", root, subir)

function descer (_, state)
if painel == true then
if state == "down" then
if isCursorOnElement (x*611, y*701, x*65, y*88) then
local theVehicle = getPedOccupiedVehicle(localPlayer)
if theVehicle and getVehicleController(theVehicle) == localPlayer then
triggerServerEvent ("descer", getLocalPlayer())
playSound("Som/murchado.mp3")
end
end
end
end
end
addEventHandler ("onClientClick", root, descer)

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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