ScriptingExamples/GameCommand: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(remove gta ug refs) |
||
Line 17: | Line 17: | ||
elseif gameId == GAME_GTA_VC then return 'GTA VC' | elseif gameId == GAME_GTA_VC then return 'GTA VC' | ||
elseif gameId == GAME_GTA_SA then return 'GTA SA' | elseif gameId == GAME_GTA_SA then return 'GTA SA' | ||
elseif gameId == GAME_GTA_IV then return 'GTA IV' | elseif gameId == GAME_GTA_IV then return 'GTA IV' | ||
end | end | ||
Line 38: | Line 37: | ||
case GAME_GTA_SA: | case GAME_GTA_SA: | ||
return "GTA San Andreas"; | return "GTA San Andreas"; | ||
case GAME_GTA_IV: | case GAME_GTA_IV: | ||
return "GTA IV"; | return "GTA IV"; | ||
Line 62: | Line 59: | ||
case GAME_GTA_SA: | case GAME_GTA_SA: | ||
return "GTA San Andreas"; | return "GTA San Andreas"; | ||
case GAME_GTA_IV: | case GAME_GTA_IV: | ||
return "GTA IV"; | return "GTA IV"; |
Latest revision as of 10:46, 3 October 2021
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";
}