mirror of
https://github.com/Resxt/Plutonium-IW5-Scripts.git
synced 2025-04-19 12:42:54 +00:00
chat_commands 1.1.5
All commands that require a player name to be passed now work both with a player name or with "me" to target yourself [Dev] All commands that use FindPlayerByName will now work with "me" passed as the player out of the box since FindPlayerByName now returns self if the name param is "me" [Refactor] Fix undefined errors when calling a status command for the first time on a player
This commit is contained in:
parent
b1ec92bd0c
commit
8ee3ca5bc7
@ -332,21 +332,14 @@ TeleportPlayer(teleportedPlayerName, destinationPlayerName)
|
|||||||
{
|
{
|
||||||
name = names[i];
|
name = names[i];
|
||||||
|
|
||||||
if (name == "me")
|
player = FindPlayerByName(name);
|
||||||
{
|
|
||||||
players = AddElementToArray(players, self);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player = FindPlayerByName(name);
|
|
||||||
|
|
||||||
if (!IsDefined(player))
|
if (!IsDefined(player))
|
||||||
{
|
{
|
||||||
return PlayerDoesNotExistError(name);
|
return PlayerDoesNotExistError(name);
|
||||||
}
|
|
||||||
|
|
||||||
players = AddElementToArray(players, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
players = AddElementToArray(players, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
players[0] SetOrigin(players[1].origin);
|
players[0] SetOrigin(players[1].origin);
|
||||||
@ -404,6 +397,11 @@ PlayerDoesNotExistError(playerName)
|
|||||||
|
|
||||||
FindPlayerByName(name)
|
FindPlayerByName(name)
|
||||||
{
|
{
|
||||||
|
if (name == "me")
|
||||||
|
{
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (player in level.players)
|
foreach (player in level.players)
|
||||||
{
|
{
|
||||||
if (ToLower(player.name) == ToLower(name))
|
if (ToLower(player.name) == ToLower(name))
|
||||||
@ -437,9 +435,19 @@ ToggleStatus(commandName, commandDisplayName, player)
|
|||||||
|
|
||||||
GetStatus(commandName, player)
|
GetStatus(commandName, player)
|
||||||
{
|
{
|
||||||
if (!IsDefined(player.chat_commands["status"][commandName]))
|
if (!IsDefined(player.chat_commands)) // avoid undefined errors in the console
|
||||||
{
|
{
|
||||||
return false;
|
player.chat_commands = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsDefined(player.chat_commands["status"])) // avoid undefined errors in the console
|
||||||
|
{
|
||||||
|
player.chat_commands["status"] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsDefined(player.chat_commands["status"][commandName])) // status is set to OFF/false by default
|
||||||
|
{
|
||||||
|
SetStatus(commandName, player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return player.chat_commands["status"][commandName];
|
return player.chat_commands["status"][commandName];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user