ShowCursor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(adding note of cursor bahvior in another resource)
 
(14 intermediate revisions by 10 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__
This function is used to show or hide a player's cursor for 'click-events'.
{{Server client function}}
This function is used to show or hide a [[player]]'s cursor.
{{Note|Regardless of the cursor state you set using this function, the cursor will always be visible while the menu, the chatbox input line or the console are active, or if another resource has called this function.}}
{{Note| Be aware of that if showCursor enbaled by a resource you can't disabled it from a different ressource showCursor(false) will not works, in order to make it works, disable it from the original resource that enabled it or use export }}


==Syntax==  
==Syntax==  
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool showCursor ( player thePlayer, bool show )
bool showCursor ( player thePlayer, bool show, [ bool toggleControls = true ] )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''thePlayer''' The player you want to show or hide the cursor of.
*'''thePlayer:''' The [[player]] you want to show or hide the cursor of.
*'''show''' A boolean value determining whether to show ( true ) or hide ( false ) the cursor.
*'''show:''' A boolean value determining whether to show (''true'') or hide (''false'') the cursor.
 
===Optional Arguments===
{{OptionalArg}}
*'''toggleControls:''' A boolean value determining whether to disable controls whilst the cursor is showing.  ''true'' implies controls are disabled, ''false'' implies controls remain enabled.
</section>
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
bool showCursor ( bool show, [ bool toggleControls = true ]  )
</syntaxhighlight>
 
===Required Arguments===
*'''show:''' A boolean value determining whether to show (''true'') or hide (''false'') the cursor.
 
===Optional Arguments===
{{OptionalArg}}
*'''toggleControls:''' A boolean value determining whether to disable controls whilst the cursor is showing.  ''true'' implies controls are disabled, ''false'' implies controls remain enabled.
</section>


===Returns===
===Returns===
Returns ''true'' if the player's cursor was shown or hidden successfully, otherwise ''false''.
Returns ''true'' if the player's cursor was shown or hidden successfully, ''false'' otherwise.


==Example==  
==Example==
This example shows the players cursor, then prints "success" if it was shown successfully.
<section name="Server" class="server" show="true">
This example shows the cursor for a player named "Dave", then outputs a message if it was shown successfully.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
thePlayer = getPlayerFromNick ( "Dave" ) -- grab the player named Dave
local thePlayer = getPlayerFromName ( "Dave" )             -- get the player named Dave
if ( thePlayer ) then -- if we got him
if thePlayer then                                           -- if we got him
  showCursor ( thePlayer, true ) -- make his cursor show
    showCursor ( thePlayer, true )                         -- make his cursor show
  if ( isCursorShowing ( thePlayer ) ) then -- did it show?
    if isCursorShowing ( thePlayer ) then                   -- did it show?
    outputChatBox ( "success" ) -- print "success" to the chat box
        outputChatBox ( "Cursor is now showing for Dave." ) -- print a message to the chat box
  end
    end
end
end
</syntaxhighlight>
</syntaxhighlight>
</section>
<section name="Client" class="client" show="true">
This example shows the cursor all the time
<syntaxhighlight lang="lua">
showCursor ( true ) -- Shows cursor
showCursor ( false ) -- Doesnt Show Cursor
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Cursor_functions}}
{{Cursor_functions}}
[[hu:showCursor]]

Latest revision as of 10:05, 15 August 2024

This function is used to show or hide a player's cursor.

[[{{{image}}}|link=|]] Note: Regardless of the cursor state you set using this function, the cursor will always be visible while the menu, the chatbox input line or the console are active, or if another resource has called this function.
[[{{{image}}}|link=|]] Note: Be aware of that if showCursor enbaled by a resource you can't disabled it from a different ressource showCursor(false) will not works, in order to make it works, disable it from the original resource that enabled it or use export

Syntax

Click to collapse [-]
Server
bool showCursor ( player thePlayer, bool show, [ bool toggleControls = true ] )

Required Arguments

  • thePlayer: The player you want to show or hide the cursor of.
  • show: A boolean value determining whether to show (true) or hide (false) the cursor.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • toggleControls: A boolean value determining whether to disable controls whilst the cursor is showing. true implies controls are disabled, false implies controls remain enabled.
Click to collapse [-]
Client
bool showCursor ( bool show, [ bool toggleControls = true ]  )

Required Arguments

  • show: A boolean value determining whether to show (true) or hide (false) the cursor.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • toggleControls: A boolean value determining whether to disable controls whilst the cursor is showing. true implies controls are disabled, false implies controls remain enabled.

Returns

Returns true if the player's cursor was shown or hidden successfully, false otherwise.

Example

Click to collapse [-]
Server

This example shows the cursor for a player named "Dave", then outputs a message if it was shown successfully.

local thePlayer = getPlayerFromName ( "Dave" )              -- get the player named Dave
if thePlayer then                                           -- if we got him
    showCursor ( thePlayer, true )                          -- make his cursor show
    if isCursorShowing ( thePlayer ) then                   -- did it show?
        outputChatBox ( "Cursor is now showing for Dave." ) -- print a message to the chat box
    end
end
Click to collapse [-]
Client

This example shows the cursor all the time

showCursor ( true ) -- Shows cursor
showCursor ( false ) -- Doesnt Show Cursor


See Also