Snow-Man Posted September 4, 2022 Share Posted September 4, 2022 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
AliGR Posted September 4, 2022 Share Posted September 4, 2022 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
Snow-Man Posted September 4, 2022 Author Share Posted September 4, 2022 hello thank you for the reply the problem isnt on that function, mine works great and tested it on other dx effects but didnt know solution to click on element then to click on option showed on dx so it get element each time i click even showing one from options Link to comment
Snow-Man Posted September 5, 2022 Author Share Posted September 5, 2022 (edited) 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 September 5, 2022 by Snow-Man 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