Jump to content

Cursor enter/leave


HunT

Recommended Posts

Posted

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.

Posted
Oh... https://wiki.multitheftauto.com/wiki/GetCursorPosition

Look at example that I sent you

:mrgreen: 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

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

  • 2 months later...
Posted

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

Posted

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.

Posted
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) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
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

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...