IsPlayerCrosshairVisible: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 12: Line 12:


==Example==
==Example==
function aim()
<syntaxhighlight lang="lua">
    if isPlayerCrosshairVisible() then
addCommandHandler("crosshair", function()
        outputChatBox("succes, aim its true", 0, 255, 0) -- green text if is true
     local crosshairStatus = isPlayerCrosshairVisible() and "visible" or "hidden"
     else
        outputChatBox("erro, your aim is false", 255, 0, 0) -- red text if is false
    end
end
addCommandHandler("aim", aim)


    outputChatBox("Your crosshair is: "..crosshairStatus)
end)
</syntaxhighlight>


==See Also==
==See Also==
{{Client player functions}}
{{Client player functions}}

Latest revision as of 08:38, 5 December 2024

ADDED/UPDATED IN VERSION 1.6.0 r22751:
This function checks if the local player has showing crosshair.
[[{{{image}}}|link=|]] Note: This function checks if the crosshair is rendered by GTA. Please note that hud components are not associated with this function, so the function may return true even if the "crosshair" component is hidden with setPlayerHudComponentVisible. If you need checking use isPlayerHudComponentVisible.

Syntax

bool isPlayerCrosshairVisible()

Returns

Returns true if the player has the crosshair visible, false otherwise.

Example

addCommandHandler("crosshair", function()
    local crosshairStatus = isPlayerCrosshairVisible() and "visible" or "hidden"

    outputChatBox("Your crosshair is: "..crosshairStatus)
end) 

See Also