IsCursorShowing: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
(8 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
{{Server client function}}
This fake function is for use with blah & blah and does blahblahblabhalbhl
This function is used to determine whether or not a player's cursor is showing.
 
{{Note|This retrieves the cursor state that has been set using [[showCursor]], and thus doesn't take into account the cursor shown while the chatbox, menu or console are open. Also, keep in mind that while the client is aware of cursor states set from the server, the server doesn't know about cursor states set from the client.}}
==Syntax==  
==Syntax==  
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd -->
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
returnType functionName ( arguments )
bool isCursorShowing ( player thePlayer )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type -->
*'''thePlayer:''' The [[player]] you want to get cursor state of.
*'''argumentName:''' description


<!-- Only include this section below if there are optional arguments -->
===Returns===
===Optional Arguments===  
Returns ''true'' if the player's cursor is showing, ''false'' if it isn't or if invalid parameters were passed.
{{OptionalArg}}
</section>
*'''argumentName2:''' description
*'''argumentName3:''' description


<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
bool isCursorShowing ( )
</syntaxhighlight>
===Returns===
===Returns===
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
Returns ''true'' if the player's cursor is showing, ''false'' if it isn't.
Returns ''true'' if blah, ''false'' otherwise.
</section>


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
<section name="Example" class="server" show="true">
This example does...
This serverside function toggles a player's cursor state.
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function toggleCursor ( thePlayer )
blabhalbalhb --abababa
local currentState = isCursorShowing ( thePlayer )  -- get the current cursor state as a boolean
--This line does this...
local oppositeState = not currentState              -- get the new state as its logical opposite
mooo
showCursor ( thePlayer, oppositeState )            -- set it as the new cursor state
end
</syntaxhighlight>
</syntaxhighlight>
</section>
<section name="Clientside Example" class="client" show="true">
With little of tweaking this can also be used clientside
<syntaxhighlight lang="lua">
function toggleCursor ()
        local currentState = isCursorShowing ()  -- get the current cursor state as a boolean
        local oppositeState = not currentState              -- get the new state as its logical opposite
        showCursor ( oppositeState )            -- set it as the new cursor state
end
</syntaxhighlight>
And a more compact version
<syntaxhighlight lang="lua">
[lua]
bindKey ("b", "down",                            -- binds B key to toggle cursor state
        function()
                showCursor( not isCursorShowing() )
        end)
</syntaxhighlight>
</section>


==See Also==
==See Also==
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
{{Cursor_functions}}
{{FunctionArea_functions}}
 
[[Category:Incomplete]]
[[hu:isCursorShowing]]

Revision as of 10:33, 13 October 2018

This function is used to determine whether or not a player's cursor is showing.

[[{{{image}}}|link=|]] Note: This retrieves the cursor state that has been set using showCursor, and thus doesn't take into account the cursor shown while the chatbox, menu or console are open. Also, keep in mind that while the client is aware of cursor states set from the server, the server doesn't know about cursor states set from the client.

Syntax

Click to collapse [-]
Server
bool isCursorShowing ( player thePlayer )

Required Arguments

  • thePlayer: The player you want to get cursor state of.

Returns

Returns true if the player's cursor is showing, false if it isn't or if invalid parameters were passed.

Click to collapse [-]
Client
bool isCursorShowing ( )

Returns

Returns true if the player's cursor is showing, false if it isn't.

Example

Click to collapse [-]
Example

This serverside function toggles a player's cursor state.

function toggleCursor ( thePlayer )
	local currentState = isCursorShowing ( thePlayer )  -- get the current cursor state as a boolean
	local oppositeState = not currentState              -- get the new state as its logical opposite
	showCursor ( thePlayer, oppositeState )             -- set it as the new cursor state
end
Click to collapse [-]
Clientside Example

With little of tweaking this can also be used clientside

function toggleCursor ()
        local currentState = isCursorShowing ()  -- get the current cursor state as a boolean
        local oppositeState = not currentState              -- get the new state as its logical opposite
        showCursor ( oppositeState )             -- set it as the new cursor state
end

And a more compact version

[lua]
bindKey ("b", "down",                            -- binds B key to toggle cursor state
        function()
                showCursor( not isCursorShowing() )
        end)

See Also