GetGameType: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ {{Server function}}<!-- Change this to "Client function" or "Server function" appropriately--> <!-- Describe in plain english what this function does. Don't go into details, jus...) |
mNo edit summary |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
{{Server function}}<!-- Change this to "Client function" or "Server function" appropriately--> | {{Server function}}<!-- Change this to "Client function" or "Server function" appropriately--> | ||
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --> | <!-- Describe in plain english what this function does. Don't go into details, just give an overview --> | ||
This function retrieves the current gametype as set by [[setGameType]]. | This function retrieves the current gametype as set by [[setGameType]]. The game type is displayed in the server browser next to the server's name. | ||
==Syntax== | ==Syntax== | ||
Line 12: | Line 12: | ||
===Returns=== | ===Returns=== | ||
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --> | <!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --> | ||
Returns the gametype as a string | Returns the gametype as a string. If no gametype is set it returns ''nil''. | ||
==Example== | ==Example== | ||
This example sends a message to player when he joins, if the current game type is Race. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function playerJoinHandler( ) | |||
if getGameType() == "Race" then | |||
outputChatBox( "Ready... Get set... GO!!", source ) | |||
end | |||
end | |||
addEventHandler( "onPlayerJoin", getRootElement(), playerJoinHandler ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==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 --> | <!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --> | ||
{{ | {{Announce functions}} | ||
Latest revision as of 16:18, 30 January 2009
This function retrieves the current gametype as set by setGameType. The game type is displayed in the server browser next to the server's name.
Syntax
string getGameType ()
Returns
Returns the gametype as a string. If no gametype is set it returns nil.
Example
This example sends a message to player when he joins, if the current game type is Race.
function playerJoinHandler( ) if getGameType() == "Race" then outputChatBox( "Ready... Get set... GO!!", source ) end end addEventHandler( "onPlayerJoin", getRootElement(), playerJoinHandler )
See Also