From 6bf08da690f05cdf6cb6b5527900f473acc21ef9 Mon Sep 17 00:00:00 2001 From: Resxt <55228336+Resxt@users.noreply.github.com> Date: Mon, 6 Feb 2023 03:51:17 +0100 Subject: [PATCH] chat_commands 1.1.7 Added invisible command to grant or remove the invisible state to a player (toggle) Note that this does not make you invisible to bots in the sense that even if they can't see you they will still know your position and shoot you on sight --- small_scripts/chat_commands.gsc | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/small_scripts/chat_commands.gsc b/small_scripts/chat_commands.gsc index c341a9b..d024a65 100644 --- a/small_scripts/chat_commands.gsc +++ b/small_scripts/chat_commands.gsc @@ -40,6 +40,7 @@ InitCommands() CreateCommand(level.commands_servers_ports, "changeteam", "function", ::ChangeTeamCommand, "default_help_one_player"); CreateCommand(level.commands_servers_ports, "teleport", "function", ::TeleportCommand, "default_help_two_players"); CreateCommand(level.commands_servers_ports, "norecoil", "function", ::NoRecoilCommand, "default_help_one_player"); + CreateCommand(level.commands_servers_ports, "invisible", "function", ::InvisibleCommand, "default_help_one_player"); // Specific server(s) text commands CreateCommand(["27016", "27017"], "rules", "text", ["Do not camp", "Do not spawnkill", "Do not disrespect other players"]); @@ -296,6 +297,21 @@ NoRecoilCommand(args) } } +InvisibleCommand(args) +{ + if (args.size < 1) + { + return NotEnoughArgsError(1); + } + + error = ToggleInvisible(args[0]); + + if (IsDefined(error)) + { + return error; + } +} + /* Logic functions section */ @@ -378,6 +394,29 @@ ToggleNoRecoil(playerName) ToggleStatus("no_recoil", "No Recoil", player); } +ToggleInvisible(playerName) +{ + player = FindPlayerByName(playerName); + + if (!IsDefined(player)) + { + return PlayerDoesNotExistError(playerName); + } + + commandName = "invisible"; + + ToggleStatus(commandName, "Invisible", player); + + if (GetStatus(commandName, player)) + { + player hide(); + } + else + { + player show(); + } +} + /* Error functions section */