From 7a3e2e24908156cdfe63d400f68a8f8cf7cf9ec6 Mon Sep 17 00:00:00 2001 From: Resxt <55228336+Resxt@users.noreply.github.com> Date: Fri, 28 Jul 2023 12:53:42 +0200 Subject: [PATCH] chat_command_balance_teams 1.0.0 --- chat_commands/README.md | 13 ++++++++ chat_commands/chat_command_balance_teams.gsc | 32 ++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 chat_commands/chat_command_balance_teams.gsc diff --git a/chat_commands/README.md b/chat_commands/README.md index 5f180b6..f102363 100644 --- a/chat_commands/README.md +++ b/chat_commands/README.md @@ -69,6 +69,19 @@ set cc_permission_4 "" - If you use [IW4MAdmin](https://github.com/RaidMax/IW4M-Admin) make sure you have a different commands prefix to avoid conflicts. For example `!` for IW4MAdmin commands and `.` for this script. The commands prefix can be modified by changing the value of the `cc_prefix` dvar. As for [IW4MAdmin](https://github.com/RaidMax/IW4M-Admin), at the time of writing, if you want to change it you'll need to change the value of [CommandPrefix](https://github.com/RaidMax/IW4M-Admin/wiki/Configuration#advanced-configuration) - If you prefer to display information (error messages, status change etc.) on the player's screen rather than in the chat you can edit the `TellPlayer` function. For this you simply need to change `self tell(message);` to `self IPrintLnBold(message);` +## chat_command_balance_teams.gsc + +Balances the teams so that both teams have a fair amount of players. +This also counts bots but most likely doesn't differentiate bots and players. + +| Example | +|---| +| `!balanceteams` | + +| Permission level | +|---| +| 3 | + ## chat_command_change_team.gsc The player affected by the command dies and swaps to the other team. diff --git a/chat_commands/chat_command_balance_teams.gsc b/chat_commands/chat_command_balance_teams.gsc new file mode 100644 index 0000000..5fea213 --- /dev/null +++ b/chat_commands/chat_command_balance_teams.gsc @@ -0,0 +1,32 @@ +#include scripts\chat_commands; + +Init() +{ + CreateCommand(level.chat_commands["ports"], "balanceteams", "function", ::BalanceTeamsCommand, 3, [], ["bt"]); +} + + + +/* Command section */ + +BalanceTeamsCommand(args) +{ + BalanceTeams(); +} + + + +/* Logic section */ + +BalanceTeams() +{ + if (!maps\mp\gametypes\_teams::getteambalance()) + { + self thread TellPlayer(["Balancing teams"], 1); + level maps\mp\gametypes\_teams::balanceteams(); + } + else + { + self thread TellPlayer(["Teams are already balanced"], 1); + } +} \ No newline at end of file