HunT Posted March 6, 2015 Share Posted March 6, 2015 How i can make the event like onClientMouseEnter/onClientMouseLeave in the world objects and peds? I need start the function if the cursor is over an object or ped. Any solution? Tnx. Link to comment
3B00DG4MER Posted March 6, 2015 Share Posted March 6, 2015 https://wiki.multitheftauto.com/wiki/OnClientClick there's a Parameter in that Event checks the Clicked Element Link to comment
HunT Posted March 6, 2015 Author Share Posted March 6, 2015 https://wiki.multitheftauto.com/wiki/OnClientClickthere's a Parameter in that Event checks the Clicked Element Thanks for reply but i know this event . I need start the function only with cursor enter/leave on an object created like : object_1 = createObject cursor over object_1 start the function without click. Link to comment
Cadu12 Posted March 6, 2015 Share Posted March 6, 2015 You can make your own custom event using: getPedTarget Link to comment
HunT Posted March 6, 2015 Author Share Posted March 6, 2015 You can make your own custom event using: getPedTarget I know that, Is good with weapon but not for cursor Link to comment
Cadu12 Posted March 6, 2015 Share Posted March 6, 2015 Oh... https://wiki.multitheftauto.com/wiki/GetCursorPosition Look at example that I sent you Link to comment
Addlibs Posted March 6, 2015 Share Posted March 6, 2015 onClientMouseEnter/onClientMouseLeave in the world objects I'm afraid you cannot detect whether a cursor moved over a world object, only elements, unless you want to continuously proceedLineOfSight and detect changes in model number or whatever. Some functions which might be helpful: getCursorPosition getWorldFromScreenPosition proceedLineOfSight Link to comment
HunT Posted March 6, 2015 Author Share Posted March 6, 2015 Oh... https://wiki.multitheftauto.com/wiki/GetCursorPositionLook at example that I sent you Thank You. Can i use onClientCursorMove getCursorPosition Link to comment
.:HyPeX:. Posted March 6, 2015 Share Posted March 6, 2015 Oh... https://wiki.multitheftauto.com/wiki/GetCursorPositionLook at example that I sent you Thank You. Can i use onClientCursorMove getCursorPosition Its usless hunterix, the onClientCursorMove already retrives the cursor position values, it even give the 3 types, screen relative, screen pixels and world XYZ. onClientCursorMove - Check it out Link to comment
HunT Posted May 21, 2015 Author Share Posted May 21, 2015 Again here about that MTAsa really need the events onMouseEnter and onMouseLeave like onClientClick. I need start the function if the cursor enter in the world objects. Any solution? Tnx Link to comment
Anubhav Posted May 21, 2015 Share Posted May 21, 2015 _, _, x, y, z = getCursorPosition() Use a onClientRender even if the cursor is shown, then check if coordinates match (X,Y,Z). Link to comment
3B00DG4MER Posted May 21, 2015 Share Posted May 21, 2015 it's should onWorldMouseEnter and onWorldMouseLeave Link to comment
HunT Posted May 21, 2015 Author Share Posted May 21, 2015 i have find that in the editor_gui/client/guiGetMouseOverElement.lua --GUI's onClientMouseMove is flawed in the fact that it does not trigger when you move your mouse without a gui element on top --this script works around that for the highlighter when the mouse is not on top of gui --it also provides a guiGetMouseOverElement to retrieve the current mouse over element. local worldDetector function createWorldDetector() worldDetector = guiCreateProgressBar ( 0,0,1,1,true ) guiSetAlpha ( worldDetector, 0 ) guiMoveToBack( worldDetector ) addEventHandler ( "onClientGUIWorldClick",worldDetector,function() if source == worldDetector or source == getRootElement() then guiMoveToBack(worldDetector) end end ) end local mouseOverElement = false addEventHandler ( "onClientMouseMove", getRootElement(), function ( cursorX, cursorY ) if not isGUICreated then return end if source == worldDetector then hideHighlighter() mouseOverElement = false else showHighlighter(source) mouseOverElement = source end end ) function guiGetMouseOverElement() return mouseOverElement end Only the PRO scripter can make the useful function mouse enter/leave like in map editor. Link to comment
Walid Posted May 21, 2015 Share Posted May 21, 2015 How i can make the event like onClientMouseEnter/onClientMouseLeave in the world objects and peds?I need start the function if the cursor is over an object or ped. Any solution? Tnx. All what you need is local Target = false function YourFunction() if (not Target) then return end local sX, sY, wX, wY, wZ = getCursorPosition() local oX, oY, oZ = getCameraMatrix() local hit, hitX, hitY, hitZ, hitEl = processLineOfSight(oX, oY, oZ, wX, wY, wZ) if (hit and hitEl and isElement(hitEl)) then if (getElementType(hitEl) == "object") then -- You code here elseif (getElementType(hitEl) == "ped") then -- You code here end end end addEventHandler("onClientRender", root, YourFunction) Link to comment
HunT Posted May 21, 2015 Author Share Posted May 21, 2015 How i can make the event like onClientMouseEnter/onClientMouseLeave in the world objects and peds?I need start the function if the cursor is over an object or ped. Any solution? Tnx. All what you need is local Target = false function YourFunction() if (not Target) then return end local sX, sY, wX, wY, wZ = getCursorPosition() local oX, oY, oZ = getCameraMatrix() local hit, hitX, hitY, hitZ, hitEl = processLineOfSight(oX, oY, oZ, wX, wY, wZ) if (hit and hitEl and isElement(hitEl)) then if (getElementType(hitEl) == "object") then -- You code here elseif (getElementType(hitEl) == "ped") then -- You code here end end end addEventHandler("onClientRender", root, YourFunction) Mhh now i cant try Tnx 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