mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-07 13:45:42 +12:00
Add %UNBAN
This commit is contained in:
parent
49522e9fef
commit
3be40efc5e
4 changed files with 53 additions and 5 deletions
|
@ -66,6 +66,8 @@ namespace HISP.Game.Chat
|
|||
return Command.NoClip(message, args, user);
|
||||
if (message.StartsWith("%BAN"))
|
||||
return Command.Ban(message, args, user);
|
||||
if (message.StartsWith("%UNBAN"))
|
||||
return Command.UnBan(message, args, user);
|
||||
return false;
|
||||
}
|
||||
if (message[0] == '!')
|
||||
|
|
|
@ -62,6 +62,31 @@ namespace HISP.Game.Chat
|
|||
user.LoggedinClient.SendPacket(chatPacket);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool UnBan(string message, string[] args, User user)
|
||||
{
|
||||
if(args.Length <= 0)
|
||||
return false;
|
||||
if(!user.Administrator || !user.Moderator)
|
||||
return false;
|
||||
|
||||
try{
|
||||
string userName = args[0];
|
||||
int id = Database.GetUserid(userName);
|
||||
Database.UnBanUser(id);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Logger.ErrorPrint(e.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||
user.LoggedinClient.SendPacket(chatPacket);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Ban(string message, string[] args, User user)
|
||||
{
|
||||
if (args.Length <= 0)
|
||||
|
@ -79,13 +104,19 @@ namespace HISP.Game.Chat
|
|||
}
|
||||
|
||||
Database.BanUser(id, ip, reason);
|
||||
User bannedUser = GameServer.GetUserByName(args[0]);
|
||||
bannedUser.LoggedinClient.Kick(Messages.KickReasonBanned);
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
try{
|
||||
User bannedUser = GameServer.GetUserByName(args[0]);
|
||||
bannedUser.LoggedinClient.Kick(Messages.KickReasonBanned);
|
||||
}
|
||||
catch(KeyNotFoundException){};
|
||||
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||
user.LoggedinClient.SendPacket(chatPacket);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -134,7 +165,7 @@ 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;
|
||||
|
|
|
@ -122,7 +122,10 @@ namespace HISP.Game.Horse
|
|||
{
|
||||
get
|
||||
{
|
||||
return baseHorse.Equipment.Companion.GetMiscFlag(0);
|
||||
if(baseHorse.Equipment.Companion != null)
|
||||
return baseHorse.Equipment.Companion.GetMiscFlag(0);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public int TackOffset
|
||||
|
|
|
@ -53,7 +53,6 @@ namespace HISP.Server
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.DebugPrint(e.GetType().ToString());
|
||||
Logger.WarnPrint(e.Message);
|
||||
};
|
||||
|
||||
|
@ -667,6 +666,19 @@ namespace HISP.Server
|
|||
}
|
||||
}
|
||||
|
||||
public static void UnBanUser(int userId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "DELETE FROM BannedPlayers WHERE playerId=@playerId";
|
||||
sqlCommand.Parameters.AddWithValue("@playerId", userId);
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool IsIpBanned(string ip)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue