From 1a4c6a3ceeb4237bf02b4af718e241151be39e9c Mon Sep 17 00:00:00 2001 From: Resxt <55228336+Resxt@users.noreply.github.com> Date: Thu, 16 Feb 2023 04:15:15 +0100 Subject: [PATCH] chat_command_norecoil 1.0.0 --- chat_commands/README.md | 9 +++++ chat_commands/chat_command_norecoil.gsc | 51 +++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 chat_commands/chat_command_norecoil.gsc diff --git a/chat_commands/README.md b/chat_commands/README.md index 0b326b9..924df9b 100644 --- a/chat_commands/README.md +++ b/chat_commands/README.md @@ -45,6 +45,15 @@ Example: `!changteam Resxt` | 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_norecoil.gsc + +Toggles norecoil on the targeted player + +| Examples | +|---| +| `!norecoil me` | +| `!norecoil Resxt` | + ## chat_command_suicide.gsc The player who runs the command dies. diff --git a/chat_commands/chat_command_norecoil.gsc b/chat_commands/chat_command_norecoil.gsc new file mode 100644 index 0000000..2692f5b --- /dev/null +++ b/chat_commands/chat_command_norecoil.gsc @@ -0,0 +1,51 @@ +#include scripts\chat_commands; + +Init() +{ + CreateCommand(level.commands_servers_ports, "norecoil", "function", ::NoRecoilCommand, ["default_help_one_player"]); +} + + + +/* Command section */ + +NoRecoilCommand(args) +{ + if (args.size < 1) + { + return NotEnoughArgsError(1); + } + + error = ToggleNoRecoil(args[0]); + + if (IsDefined(error)) + { + return error; + } +} + + + +/* Logic section */ + +ToggleNoRecoil(playerName) +{ + player = FindPlayerByName(playerName); + + if (!IsDefined(player)) + { + return PlayerDoesNotExistError(playerName); + } + + recoilModifier = 100; + + if (IsDefined(player.recoilscale) && player.recoilscale == 100) + { + recoilModifier = 0; + } + + player maps\mp\_utility::setrecoilscale( recoilModifier, recoilModifier ); + player.recoilscale = recoilModifier; + + ToggleStatus("no_recoil", "No Recoil", player); +} \ No newline at end of file