SetGameType: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
Fernando187 (talk | contribs) m (Fix examples header) |
||
(One intermediate revision by the same user not shown) | |||
Line 11: | Line 11: | ||
[[File:GameType.png|thumb|Gamemode column that shows a server's game type.]] | [[File:GameType.png|thumb|Gamemode column that shows a server's game type.]] | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''gameType:''' A string containing a name for the game mode, or ''false'' to clear it. | *'''gameType:''' A string containing a name for the game mode, or ''false'' to clear it. '''(MAX 200 characters)''' | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the game type was set, ''false'' if an invalid argument was passed to the function. | Returns ''true'' if the game type was set, ''false'' if an invalid argument was passed to the function. | ||
== | |||
==Examples== | |||
This example sets the game type to ''Capture The Flag''. | This example sets the game type to ''Capture The Flag''. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 21: | Line 22: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
This example adds a command to change the game type. | This example adds a command to change the game type. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> |
Latest revision as of 13:49, 8 June 2025
This function sets a string containing a name for the game type. This should be the game-mode that is active, for example "Capture The Flag" or "Deathmatch". This is then displayed in the server browser and external server browsers.
It should be noted that mapmanager handles this automatically for gamemodes that utilise the map/gamemode system.
Syntax
bool setGameType ( string gameType )
Required Arguments
- gameType: A string containing a name for the game mode, or false to clear it. (MAX 200 characters)
Returns
Returns true if the game type was set, false if an invalid argument was passed to the function.
Examples
This example sets the game type to Capture The Flag.
setGameType ( "Capture The Flag" )
This example adds a command to change the game type.
function setNewGameType( source, commandName, newGameType ) local oldGameType = getGameType() -- check old Game Type setGameType( newGameType ) -- set new Game Type outputChatBox( "Game Type " .. oldGameType .. " changed to " .. newGameType .. ".", getRootElement(), 255, 128, 0 ) end addCommandHandler( "setgametype", setNewGameType )
See Also