Added ForceKillAll to kick all players.

This commit is contained in:
ricky 2011-06-15 13:49:42 +10:00
parent 3af6e990dc
commit 3ced4fc089
3 changed files with 19 additions and 21 deletions

View file

@ -443,13 +443,7 @@ namespace TShockAPI
public static void Off(CommandArgs args) public static void Off(CommandArgs args)
{ {
for (int player = 0; player < Main.maxPlayers; player++) Tools.ForceKickAll("Server shutting down!");
{
if (Main.player[player].active)
{
Tools.ForceKick(player, "Server shutting down!");
}
}
WorldGen.saveWorld(); WorldGen.saveWorld();
Netplay.disconnect = true; Netplay.disconnect = true;
} }
@ -1066,13 +1060,7 @@ namespace TShockAPI
Process.Start(new ProcessStartInfo("UpdateTShock.exe")); Process.Start(new ProcessStartInfo("UpdateTShock.exe"));
for (int player = 0; player < Main.maxPlayers; player++) Tools.ForceKickAll("Server shutting down for update!");
{
if (Main.player[player].active)
{
Tools.ForceKick(player, "Server shutting down for update!");
}
}
WorldGen.saveWorld(); WorldGen.saveWorld();
Netplay.disconnect = true; Netplay.disconnect = true;
} }

View file

@ -231,13 +231,7 @@ namespace TShockAPI
} }
if (text.StartsWith("exit")) if (text.StartsWith("exit"))
{ {
for (int player = 0; player < Main.maxPlayers; player++) Tools.ForceKickAll("Server shutting down!");
{
if (Main.player[player].active)
{
Tools.ForceKick(player, "Server shutting down!");
}
}
} }
if (text.StartsWith("playing")) if (text.StartsWith("playing"))
{ {

View file

@ -196,6 +196,22 @@ namespace TShockAPI
} }
} }
/// <summary>
/// Kicks all player from the server without checking for immunetokick permission.
/// </summary>
/// <param name="ply">int player</param>
/// <param name="reason">string reason</param>
public static void ForceKickAll(string reason)
{
for (int player = 0; player < Main.maxPlayers; player++)
{
if (Main.player[player].active)
{
Tools.ForceKick(player, reason);
}
}
}
/// <summary> /// <summary>
/// Kicks a player from the server without checking for immunetokick permission. /// Kicks a player from the server without checking for immunetokick permission.
/// </summary> /// </summary>