mirror of
https://github.com/Resxt/Plutonium-IW5-Scripts.git
synced 2025-04-19 12:42:54 +00:00
chat_commands 1.1.2
Added changeteam command to swap a player to the other team !changeteam Resxt
This commit is contained in:
parent
9a875b2669
commit
caeacbf3d4
@ -37,6 +37,7 @@ InitCommands()
|
|||||||
CreateCommand(level.commands_servers_ports, "map", "function", ::ChangeMapCommand, ["Example: " + level.commands_prefix + "map mp_dome"]);
|
CreateCommand(level.commands_servers_ports, "map", "function", ::ChangeMapCommand, ["Example: " + level.commands_prefix + "map mp_dome"]);
|
||||||
CreateCommand(level.commands_servers_ports, "mode", "function", ::ChangeModeCommand, ["Example: " + level.commands_prefix + "mode FFA_default"]);
|
CreateCommand(level.commands_servers_ports, "mode", "function", ::ChangeModeCommand, ["Example: " + level.commands_prefix + "mode FFA_default"]);
|
||||||
CreateCommand(level.commands_servers_ports, "mapmode", "function", ::ChangeMapAndModeCommand, ["Example: " + level.commands_prefix + "mapmode mp_seatown TDM_default"]);
|
CreateCommand(level.commands_servers_ports, "mapmode", "function", ::ChangeMapAndModeCommand, ["Example: " + level.commands_prefix + "mapmode mp_seatown TDM_default"]);
|
||||||
|
CreateCommand(level.commands_servers_ports, "changeteam", "function", ::ChangeTeamCommand, ["Example: " + level.commands_prefix + "changeteam Resxt"]);
|
||||||
|
|
||||||
// Specific server(s) text commands
|
// Specific server(s) text commands
|
||||||
CreateCommand(["27016", "27017"], "rules", "text", ["Do not camp", "Do not spawnkill", "Do not disrespect other players"]);
|
CreateCommand(["27016", "27017"], "rules", "text", ["Do not camp", "Do not spawnkill", "Do not disrespect other players"]);
|
||||||
@ -237,6 +238,21 @@ ChangeMapAndModeCommand(args)
|
|||||||
ChangeMap(args[0]);
|
ChangeMap(args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChangeTeamCommand(args)
|
||||||
|
{
|
||||||
|
if (args.size < 1)
|
||||||
|
{
|
||||||
|
return NotEnoughArgsError(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
error = ChangeTeam(args[0]);
|
||||||
|
|
||||||
|
if (IsDefined(error))
|
||||||
|
{
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Logic functions section */
|
/* Logic functions section */
|
||||||
@ -256,6 +272,25 @@ ChangeMode(modeName, restart)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChangeTeam(playerName)
|
||||||
|
{
|
||||||
|
player = FindPlayerByName(playerName);
|
||||||
|
|
||||||
|
if (!IsDefined(player))
|
||||||
|
{
|
||||||
|
return PlayerDoesNotExistError(playerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.team == "axis")
|
||||||
|
{
|
||||||
|
player [[level.allies]]();
|
||||||
|
}
|
||||||
|
else if (player.team == "allies")
|
||||||
|
{
|
||||||
|
player [[level.axis]]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Error functions section */
|
/* Error functions section */
|
||||||
@ -274,3 +309,23 @@ NotEnoughArgsError(minimumArgs)
|
|||||||
{
|
{
|
||||||
return ["Not enough arguments supplied", "At least " + minimumArgs + " argument expected"];
|
return ["Not enough arguments supplied", "At least " + minimumArgs + " argument expected"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayerDoesNotExistError(playerName)
|
||||||
|
{
|
||||||
|
return ["Player " + playerName + " was not found"];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Utils section */
|
||||||
|
|
||||||
|
FindPlayerByName(name)
|
||||||
|
{
|
||||||
|
foreach (player in level.players)
|
||||||
|
{
|
||||||
|
if (ToLower(player.name) == ToLower(name))
|
||||||
|
{
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user