From a51165558c4e0265acc4c8d0135e9097046b51ca Mon Sep 17 00:00:00 2001 From: Resxt <55228336+Resxt@users.noreply.github.com> Date: Mon, 6 Feb 2023 04:14:53 +0100 Subject: [PATCH] chat_commands 1.1.8 Added wallhack command to grant or remove access to a wallhack (red boxes) to a player (toggle) [DEV] This showcases how to implement a status/toggle command with a non permanent logic (implementing OnPlayerSpawned()) --- small_scripts/chat_commands.gsc | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/small_scripts/chat_commands.gsc b/small_scripts/chat_commands.gsc index d024a65..470fb36 100644 --- a/small_scripts/chat_commands.gsc +++ b/small_scripts/chat_commands.gsc @@ -41,6 +41,7 @@ InitCommands() 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"); + CreateCommand(level.commands_servers_ports, "wallhack", "function", ::WallhackCommand, "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"]); @@ -312,6 +313,21 @@ InvisibleCommand(args) } } +WallhackCommand(args) +{ + if (args.size < 1) + { + return NotEnoughArgsError(1); + } + + error = ToggleWallhack(args[0]); + + if (IsDefined(error)) + { + return error; + } +} + /* Logic functions section */ @@ -417,6 +433,56 @@ ToggleInvisible(playerName) } } +ToggleWallhack(playerName) +{ + player = FindPlayerByName(playerName); + + if (!IsDefined(player)) + { + return PlayerDoesNotExistError(playerName); + } + + commandName = "wallhack"; + + ToggleStatus(commandName, "Wallhack", player); + + if (GetStatus(commandName, player)) + { + player DoWallhack(true); + player thread ThreadWallhack(); + } + else + { + player DoWallhack(false); + player notify("chat_commands_wallhack_off"); + } +} + +ThreadWallhack() +{ + self endon("disconnect"); + self endon("chat_commands_wallhack_off"); + + for(;;) + { + self waittill("spawned_player"); + + DoWallhack(true); + } +} + +DoWallhack(enabled) +{ + if (enabled) + { + self ThermalVisionFOFOverlayOn(); + } + else + { + self ThermalVisionFOFOverlayOff(); + } +} + /* Error functions section */