diff --git a/chat_commands/README.md b/chat_commands/README.md index adb2311..42e60b7 100644 --- a/chat_commands/README.md +++ b/chat_commands/README.md @@ -24,6 +24,20 @@ 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_map_mode.gsc + +3 related commands in one file: + +- Change map +- Change mode +- Change map and mode + +| Name | Description | Arguments expected | Example | +|---|---|---|---| +| map | Changes the map on the server | (1) the map codename | `!map mp_dome` | +| mode | Charges a new DSR/mode on the server and restarts the current map | (1) the DSR file name, found in the `admin` folder of your game | `!mode FFA_default` | +| mapmode | Charges a new DSR/mode on the server and rotates to the requested map | (1) the map codename (2) the DSR file name, found in the `admin` folder of your game | `!mapmode mp_seatown TDM_default` | + ## chat_command_suicide.gsc The player who runs the command dies. diff --git a/chat_commands/chat_command_map_mode.gsc b/chat_commands/chat_command_map_mode.gsc new file mode 100644 index 0000000..397ed0d --- /dev/null +++ b/chat_commands/chat_command_map_mode.gsc @@ -0,0 +1,62 @@ +#include scripts\chat_commands; + +Init() +{ + CreateCommand(level.commands_servers_ports, "map", "function", ::ChangeMapCommand, ["Example: " + level.commands_prefix + "map mp_dome"]); + CreateCommand(level.commands_servers_ports, "mode", "function", ::ChangeModeCommand, ["Example: " + level.commands_prefix + "mode FFA_default"]); + CreateCommand(level.commands_servers_ports, "mapmode", "function", ::ChangeMapAndModeCommand, ["Example: " + level.commands_prefix + "mapmode mp_seatown TDM_default"]); +} + + + +/* Command section */ + +ChangeMapCommand(args) +{ + if (args.size < 1) + { + return NotEnoughArgsError(1); + } + + ChangeMap(args[0]); +} + +ChangeModeCommand(args) +{ + if (args.size < 1) + { + return NotEnoughArgsError(1); + } + + ChangeMode(args[0], true); +} + +ChangeMapAndModeCommand(args) +{ + if (args.size < 2) + { + return NotEnoughArgsError(2); + } + + ChangeMode(args[1], false); + ChangeMap(args[0]); +} + + + +/* Logic section */ + +ChangeMap(mapName) +{ + cmdexec("map " + mapName); +} + +ChangeMode(modeName, restart) +{ + cmdexec("load_dsr " + modeName + ";"); + + if (restart) + { + cmdexec("map_restart"); + } +} \ No newline at end of file