HU/isCursorShowing

From Multi Theft Auto: Wiki
Revision as of 10:56, 13 October 2018 by Surge (talk | contribs)
Jump to navigation Jump to search

Ez a function arra szolgál, hogy meghatározza, hogy a játékos kurzora megvan-e jelenítve, vagy nincs.

[[{{{image}}}|link=|]] Megjegyzés: Ez visszaadja a HU/showCursor segítségével beállított kurzorállapotot, ami így nem veszi figyelembe a kurzor megjelénését, ha a chatbox, a menü, vagy a console nyitva van. Ezenkívül vegye figyelembe, hogy a client oldal értesül a server oldal által beállított kurzorállapotokról, viszont a server oldal nem tud a client oldalról beállított kurzorállapotokról.

Szintaxis

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

Kötelező paraméretek

  • thePlayer: A player, akinek a kurzor állapotát szeretné megkapni.

Visszatérési érték

Visszatérési értéke true, ha a játékos kurzorja megjelenik, false, ha nem, vagy ha érvétnytelen paraméterek lettek megadva.

Click to collapse [-]
Client
bool isCursorShowing ( )

Visszatérési érték

Visszatérési értéke true, ha a játékos kurzorja megjelenik, false, ha nem.

Példa

Click to collapse [-]
Example

Ez a serverside function átkapcsolja a játékos kurzorállapotát.

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

Egy kis csavarral ez is használható client oldalon is

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

És egy kompaktabb verzió

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

Lásd még

Fordította