Add %KICK

This commit is contained in:
AtelierWindows 2021-01-24 17:22:48 +13:00
parent 74b948fe61
commit b8376e9451
9 changed files with 45 additions and 21 deletions

View file

@ -97,6 +97,7 @@
},
"disconnect":{
"banned":"Your account has been BANNED. You will no longer be able to login",
"kicked":"You have been KICKED by a Moderator. No reason was provided.",
"dupe_login":"Duplicate Login. Disconnecting Previous.",
"no_playtime":"You have run out of Time for this session. As an unsubscriber you gain one minute of playtime every 8 minutes. Please come back later! ",
"client_timeout":{

View file

@ -60,6 +60,8 @@ namespace HISP.Game.Chat
return Command.Give(message, args, user);
if (message.StartsWith("%GOTO"))
return Command.Goto(message, args, user);
if (message.StartsWith("%KICK"))
return Command.Kick(message, args, user);
if (message.StartsWith("%NOCLIP"))
return Command.NoClip(message, args, user);
return false;

View file

@ -104,7 +104,36 @@ namespace HISP.Game.Chat
{
if (!user.Administrator)
return false;
user.NoClip = !user.NoClip;
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
user.LoggedinClient.SendPacket(chatPacket);
return true;
}
public static bool Kick(string message, string[] args, User user)
{
if (!user.Administrator || !user.Moderator)
return false;
if (args.Length <= 0)
return false;
try
{
User toKick = GameServer.GetUserByName(args[0]);
if (args.Length >= 2)
{
string reason = string.Join(" ", args, 1, args.Length - 1);
toKick.LoggedinClient.Kick(reason);
}
else
toKick.LoggedinClient.Kick(Messages.KickReasonKicked);
}
catch (KeyNotFoundException)
{
return false;
}
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
user.LoggedinClient.SendPacket(chatPacket);
@ -119,7 +148,7 @@ namespace HISP.Game.Chat
return false;
if(args[0] == "PLAYER")
{
if(args.Length <= 1)
if(args.Length <= 2)
return false;
try
{

View file

@ -477,6 +477,7 @@ namespace HISP.Game
// Disconnect Messages
public static string KickReasonBanned;
public static string KickReasonKicked;
public static string KickReasonDuplicateLogin;
public static string KickReasonIdleFormat;
public static string KickReasonNoTime;

View file

@ -35,11 +35,6 @@ enable_word_filter=true
# (NOTE: This feature is also used to filter some less-'bad' words disabling it will allow users to say them!)
enable_corrections=true
# Custom Banner Settings
# This will replace the "Connected to server!" message
enable_custom_banner=false
custom_banner=HISP Alpha 0.1
# Wether or not to consider all users "Subscribers"
all_users_subscribed=false

View file

@ -19,13 +19,11 @@ namespace HISP.Server
public static string MapFile;
public static string GameDataFile;
public static string CrossDomainPolicyFile;
public static string BannerText;
public static bool Debug;
public static bool AllUsersSubbed;
public static bool BadWords;
public static bool DoCorrections;
public static bool CustomBanner;
public const int MAX_STACK = 40;
@ -92,12 +90,6 @@ namespace HISP.Server
case "gamedata":
GameDataFile = data;
break;
case "enable_custom_banner":
CustomBanner = data == "true";
break;
case "custom_banner":
BannerText = data;
break;
case "crossdomain":
CrossDomainPolicyFile = data;
break;

View file

@ -332,11 +332,7 @@ namespace HISP.Server
receivePackets();
});
recvPackets.Start();
if(ConfigReader.CustomBanner)
{
byte[] loginFailedPacket = PacketBuilder.
}
}
}
}

View file

@ -989,6 +989,7 @@ namespace HISP.Server
// Disconnect Reasons
Messages.KickReasonKicked = gameData.messages.disconnect.kicked;
Messages.KickReasonBanned = gameData.messages.disconnect.banned;
Messages.KickReasonIdleFormat = gameData.messages.disconnect.client_timeout.kick_message;
Messages.KickReasonNoTime = gameData.messages.disconnect.no_playtime;

View file

@ -134,6 +134,7 @@ namespace HISP.Server
public const byte ITEM_SHOVEL = 0x5A;
public const byte LOGIN_INVALID_USER_PASS = 0x15;
public const byte LOGIN_CUSTOM_MESSAGE = 0x16;
public const byte LOGIN_SUCCESS = 0x14;
public const byte DIRECTION_UP = 0;
@ -256,10 +257,16 @@ namespace HISP.Server
{
MemoryStream ms = new MemoryStream();
ms.WriteByte(PACKET_LOGIN);
if (Success)
if (message != "")
ms.WriteByte(LOGIN_CUSTOM_MESSAGE);
else if (Success)
ms.WriteByte(LOGIN_SUCCESS);
else
ms.WriteByte(LOGIN_INVALID_USER_PASS);
byte[] loginFailMessage = Encoding.UTF8.GetBytes(message);
ms.Write(loginFailMessage, 0x00, loginFailMessage.Length);
ms.WriteByte(PACKET_TERMINATOR);
ms.Seek(0x00, SeekOrigin.Begin);