setGameType | Multi Theft Auto: Wiki Skip to content

setGameType

Client-side
Server-side
Shared

Pair: getGameType

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

  • bool: result

Returns true if the game type was set, false if an invalid argument was passed to the function.

Code Examples

server

This example adds a command to change the game type.

local 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)