mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-10 07:05:41 +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);
|
return Command.NoClip(message, args, user);
|
||||||
if (message.StartsWith("%BAN"))
|
if (message.StartsWith("%BAN"))
|
||||||
return Command.Ban(message, args, user);
|
return Command.Ban(message, args, user);
|
||||||
|
if (message.StartsWith("%UNBAN"))
|
||||||
|
return Command.UnBan(message, args, user);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (message[0] == '!')
|
if (message[0] == '!')
|
||||||
|
|
|
@ -62,6 +62,31 @@ namespace HISP.Game.Chat
|
||||||
user.LoggedinClient.SendPacket(chatPacket);
|
user.LoggedinClient.SendPacket(chatPacket);
|
||||||
return true;
|
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)
|
public static bool Ban(string message, string[] args, User user)
|
||||||
{
|
{
|
||||||
if (args.Length <= 0)
|
if (args.Length <= 0)
|
||||||
|
@ -79,13 +104,19 @@ namespace HISP.Game.Chat
|
||||||
}
|
}
|
||||||
|
|
||||||
Database.BanUser(id, ip, reason);
|
Database.BanUser(id, ip, reason);
|
||||||
User bannedUser = GameServer.GetUserByName(args[0]);
|
|
||||||
bannedUser.LoggedinClient.Kick(Messages.KickReasonBanned);
|
|
||||||
}
|
}
|
||||||
catch(Exception)
|
catch(Exception)
|
||||||
{
|
{
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +165,7 @@ namespace HISP.Game.Chat
|
||||||
if (!user.Administrator)
|
if (!user.Administrator)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
user.NoClip = !user.NoClip;
|
||||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||||
user.LoggedinClient.SendPacket(chatPacket);
|
user.LoggedinClient.SendPacket(chatPacket);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -122,7 +122,10 @@ namespace HISP.Game.Horse
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return baseHorse.Equipment.Companion.GetMiscFlag(0);
|
if(baseHorse.Equipment.Companion != null)
|
||||||
|
return baseHorse.Equipment.Companion.GetMiscFlag(0);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int TackOffset
|
public int TackOffset
|
||||||
|
|
|
@ -53,7 +53,6 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.DebugPrint(e.GetType().ToString());
|
|
||||||
Logger.WarnPrint(e.Message);
|
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)
|
public static bool IsIpBanned(string ip)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue