IsPlayerCrosshairVisible: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 8: Line 8:
<syntaxhighlight lang="lua">bool isPlayerCrosshairVisible()</syntaxhighlight>
<syntaxhighlight lang="lua">bool isPlayerCrosshairVisible()</syntaxhighlight>


=Return=
===Returns===
'''True'''true  if the crosshair is visible.
Returns ''true'' if the player has the crosshair visible, ''false'' otherwise.
'''False''' if the crosshair is not visible.


=Examples=
==Example==
 
function aim()
function aim()
     if isPlayerCrosshairVisible() then
     if isPlayerCrosshairVisible() then
         outputChatBox("your sight is visible")
         outputChatBox("succes, aim its true", 0, 255, 0) -- green text if is true
     else
     else
         outputChatBox("your crosshair is not visible")
         outputChatBox("erro, your aim is false", 255, 0, 0) -- red text if is false
     end
     end
end
addCommandHandler("aim", aim)


end
addCommandHandler("aimcheck", aim)


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

Revision as of 21:34, 4 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

function aim()
   if isPlayerCrosshairVisible() then
       outputChatBox("succes, aim its true", 0, 255, 0) -- green text if is true
   else
       outputChatBox("erro, your aim is false", 255, 0, 0) -- red text if is false
   end
end
addCommandHandler("aim", aim)


See Also