Notice: Failed to invoke Pygments: [Called from MediaWiki\SyntaxHighlight\SyntaxHighlight::highlightInner in /home/pi/www/gtac/wiki/wiki/extensions/SyntaxHighlight_GeSHi/includes/SyntaxHighlight.php at line 334] in /home/pi/www/gtac/wiki/wiki/includes/debug/MWDebug.php on line 507

Notice: Failed to invoke Pygments: [Called from MediaWiki\SyntaxHighlight\SyntaxHighlight::highlightInner in /home/pi/www/gtac/wiki/wiki/extensions/SyntaxHighlight_GeSHi/includes/SyntaxHighlight.php at line 334] in /home/pi/www/gtac/wiki/wiki/includes/debug/MWDebug.php on line 507
Game Command for own player - GTA Connected

Game Command for own player

Revision as of 10:46, 3 October 2021 by Lyuu (talk | contribs) (remove gta ug refs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

This code adds a blue chat message to the chat box for all players, displaying the game name that the player typing the message is playing, when any player types /game


Code

Lua, Server-Side:

addCommandHandler('game', function(cmd, args, client)
	message(client.player.name .. ' is playing ' .. getGameNameFromGameId(client.game), COLOUR_BLUE)
end)

function getGameNameFromGameId(gameId)
	if gameId == GAME_GTA_III then return 'GTA III'
	elseif gameId == GAME_GTA_VC then return 'GTA VC'
	elseif gameId == GAME_GTA_SA then return 'GTA SA'
	elseif gameId == GAME_GTA_IV then return 'GTA IV'
	end
	return 'Unknown Game'
end


JavaScript, Server-Side:

addCommandHandler("game", function(cmd, args, client) {
	message(client.player.name + " is playing " + getGameNameFromGameId(client.game), COLOUR_BLUE);
});

function getGameNameFromGameId(gameId) {
	switch(gameId) {
		case GAME_GTA_III:
			return "GTA III";
		case GAME_GTA_VC:
			return "GTA Vice City";
		case GAME_GTA_SA:
			return "GTA San Andreas";
		case GAME_GTA_IV:
			return "GTA IV";
	}
	
	return "Unknown Game";
}


Squirrel, Server-Side:

addCommandHandler("game", function(cmd, args, client) {
	message(client.player.name + " is playing " + getGameNameFromGameId(client.game), COLOUR_BLUE);
});

function getGameNameFromGameId(gameId) {
	switch(gameId) {
		case GAME_GTA_III:
			return "GTA III";
		case GAME_GTA_VC:
			return "GTA Vice City";
		case GAME_GTA_SA:
			return "GTA San Andreas";
		case GAME_GTA_IV:
			return "GTA IV";
	}
	
	return "Unknown Game";
}