Jump to content

dx script problem


Snow-Man

Recommended Posts

Hello guys.

i have been working on new script but i have had a problem that event doesnt continue i mean some parts doesnt work and it double click 

first of all it gets the right element is the vehicle then gets another click when dx opened 

function clickVehicle(button, state, absX, absY, wx, wy, wz, clickedElement)
    if isActivated == false then return false end 
    --if action ~= nil then return false end
    action = ""
    if (clickedElement) and (getElementType(clickedElement)== 'vehicle') and (button=='right') and (state=='down') then
        outputDebugString(getElementType(clickedElement))
    element = clickedElement
    isOpened = true
        outputDebugString('1')
       if isCursorOverText((407/x)*w, (448/y)*h, (507/x)*w, (496/y)*h) then 
    action = "repair"
    outputDebugString(action)
    elseif isCursorOverText((529/x)*w, (448/y)*h, (629/x)*w, (496/y)*h) then
    action = 'getinto'
    outputDebugString(action)
elseif isCursorOverText((647/x)*w, (448/y)*h, (747/x)*w, (496/y)*h) then
    action = 'recover'
    outputDebugString(action)
elseif isCursorOverText((761/x)*w, (448/y)*h, (861/x)*w, (496/y)*h)  then
    action = 'mark'
    outputDebugString(action)

    triggerServerEvent("onClientClickOnVehicle", getLocalPlayer(), action, element) outputDebugString ( element )
    end

end
end

 

Link to comment

hello , use this function for get the mouse position

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

 

Link to comment

Hello idk why these doesnt work about numbers of table this one #(vehicleBlip[vehicle]) >= 2

vehicleBlip = {}

function createBlipAttachedToVehicle(player, vehicle)
    if isElement( player ) and isElement(vehicle) and getElementType( player ) == "player" and getElementType( vehicle ) == "vehicle" then 
        if isElement(vehicleBlip[vehicle]) then destroyElement( vehicleBlip[vehicle] ) vehicleBlip[vehicle] = nil end
        
        vehicleBlip[vehicle] = createBlipAttachedTo(vehicle, 48, 2, 255, 255, 255, 255, 0, 99999, player )
        if #(vehicleBlip[vehicle]) >= 2 then destroyElement( vehicleBlip[vehicle] ) end
        outputDebugString( vehicleBlip[vehicle], 3)

    end 
end    

 

sometimes it says event isnt added

addEvent("onClientClickOnVehicle", true)


function vehicleOption(action, element )
	if action == "repair" then
end
end
addEventHandler("onClientClickOnVehicle", root, vehicleOption)

 

Edited by Snow-Man
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...