From f029c48373860ea4b1a0621eb97b003fd37a6def Mon Sep 17 00:00:00 2001 From: Resxt <55228336+Resxt@users.noreply.github.com> Date: Fri, 24 Mar 2023 20:29:48 +0100 Subject: [PATCH] chat_command_invisible 1.0.0 --- chat_commands/README.md | 19 +++++++++ chat_commands/chat_command_invisible.gsc | 54 ++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 chat_commands/chat_command_invisible.gsc diff --git a/chat_commands/README.md b/chat_commands/README.md index 1845971..88b7ac5 100644 --- a/chat_commands/README.md +++ b/chat_commands/README.md @@ -119,6 +119,25 @@ Toggles whether the targeted player is in god mode (invincible) or not. |---| | 3 | +## chat_command_invisible.gsc + +Toggles invisibility on the targeted player. +Note that this does not make the player invisible to bots in multiplayer, in the sense that even if they can't see the player, they will still know his position and shoot him. +However, in addition to being invisible, you will also be ignored by zombies in the zombies mode. + +| # | Argument | Mandatory | +|---|---|---| +| 1 | The name of the player to make invisible/visible | :white_check_mark: | + +| Examples | +|---| +| `!invisible me` | +| `!invisible Resxt` | + +| Permission level | +|---| +| 3 | + ## chat_command_permissions.gsc 2 related commands in one file: diff --git a/chat_commands/chat_command_invisible.gsc b/chat_commands/chat_command_invisible.gsc new file mode 100644 index 0000000..d20f668 --- /dev/null +++ b/chat_commands/chat_command_invisible.gsc @@ -0,0 +1,54 @@ +#include scripts\chat_commands; + +Init() +{ + CreateCommand(level.chat_commands["ports"], "invisible", "function", ::InvisibleCommand, 3, array("default_help_one_player")); +} + + + +/* Command section */ + +InvisibleCommand(args) +{ + if (args.size < 1) + { + return NotEnoughArgsError(1); + } + + error = ToggleInvisible(args[0]); + + if (IsDefined(error)) + { + return error; + } +} + + + +/* Logic section */ + +ToggleInvisible(playerName) +{ + player = FindPlayerByName(playerName); + + if (!IsDefined(player)) + { + return PlayerDoesNotExistError(playerName); + } + + commandName = "invisible"; + + ToggleStatus(commandName, "Invisible", player); + + if (GetStatus(commandName, player)) + { + player Hide(); + player.ignoreme = 1; // zombies won't target the player + } + else + { + player Show(); + player.ignoreme = 0; // zombies will target the player again + } +} \ No newline at end of file