diff --git a/chat_commands/README.md b/chat_commands/README.md index 42e60b7..68b527b 100644 --- a/chat_commands/README.md +++ b/chat_commands/README.md @@ -24,6 +24,13 @@ Also note that this script doesn't provide any command on its own. You must inst - Permissions/ranks to restrict some commands to a certain type of players (admin, VIP etc.) - Configurable text colors/accent. As of now the majority of the text will be white +## chat_command_change_team.gsc + +The player affected by the command dies and swaps to the other team. + +Arguments expected: the complete name of a player. +Example: `!changteam Resxt` + ## chat_command_map_mode.gsc 3 related commands in one file: diff --git a/chat_commands/chat_command_change_team.gsc b/chat_commands/chat_command_change_team.gsc new file mode 100644 index 0000000..6fef328 --- /dev/null +++ b/chat_commands/chat_command_change_team.gsc @@ -0,0 +1,48 @@ +#include scripts\chat_commands; + +Init() +{ + CreateCommand(level.commands_servers_ports, "changeteam", "function", ::ChangeTeamCommand, ["default_help_one_player"]); +} + + + +/* Command section */ + +ChangeTeamCommand(args) +{ + if (args.size < 1) + { + return NotEnoughArgsError(1); + } + + error = ChangeTeam(args[0]); + + if (IsDefined(error)) + { + return error; + } +} + + + +/* Logic section */ + +ChangeTeam(playerName) +{ + player = FindPlayerByName(playerName); + + if (!IsDefined(player)) + { + return PlayerDoesNotExistError(playerName); + } + + if (player.team == "axis") + { + player [[level.allies]](); + } + else if (player.team == "allies") + { + player [[level.axis]](); + } +} \ No newline at end of file