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
This commit is contained in:
Resxt 2023-02-06 03:51:17 +01:00
parent 7766d9ecb9
commit 6bf08da690

View File

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