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())
This commit is contained in:
Resxt 2023-02-06 04:14:53 +01:00
parent 6bf08da690
commit a51165558c

View File

@ -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 */