Fix mod commands being able to be used by all userse

This commit is contained in:
Bluzume 2021-11-28 02:38:34 -05:00
parent 68c6cdcd51
commit 2f023a55c1
5 changed files with 37 additions and 31 deletions

View file

@ -223,7 +223,7 @@ namespace HISP.Game.Chat
if (args.Length <= 2) if (args.Length <= 2)
return false; return false;
if (!(user.Administrator || user.Moderator)) if (!user.Administrator && !user.Moderator)
return false; return false;
try try
@ -260,7 +260,7 @@ namespace HISP.Game.Chat
{ {
if(args.Length <= 0) if(args.Length <= 0)
return false; return false;
if(!(user.Administrator || user.Moderator)) if(!user.Administrator && !user.Moderator)
return false; return false;
try{ try{
@ -295,9 +295,11 @@ namespace HISP.Game.Chat
{ {
if (args.Length <= 0) if (args.Length <= 0)
return false; return false;
if (!(user.Administrator || user.Moderator)) if (!user.Administrator && !user.Moderator)
return false; return false;
try{
try
{
string userName = args[0]; string userName = args[0];
int id = Database.GetUserid(userName); int id = Database.GetUserid(userName);
string ip = Database.GetIpAddress(id); string ip = Database.GetIpAddress(id);
@ -316,7 +318,6 @@ namespace HISP.Game.Chat
try{ try{
User bannedUser = GameServer.GetUserByName(args[0]); User bannedUser = GameServer.GetUserByName(args[0]);
bannedUser.LoggedinClient.Kick(Messages.KickReasonBanned); bannedUser.LoggedinClient.Kick(Messages.KickReasonBanned);
} }
catch(KeyNotFoundException){}; catch(KeyNotFoundException){};
@ -327,10 +328,9 @@ namespace HISP.Game.Chat
} }
public static bool Escape(string message, string[] args, User user) public static bool Escape(string message, string[] args, User user)
{ {
if (!(user.Administrator || user.Moderator)) if (!user.Administrator && !user.Moderator)
return false; return false;
user.Teleport(Map.ModIsleX, Map.ModIsleY); user.Teleport(Map.ModIsleX, Map.ModIsleY);
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)) + Messages.ModIsleMessage, PacketBuilder.CHAT_BOTTOM_LEFT); byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)) + Messages.ModIsleMessage, PacketBuilder.CHAT_BOTTOM_LEFT);
@ -340,7 +340,7 @@ namespace HISP.Game.Chat
public static bool Stealth(string message, string[] args, User user) public static bool Stealth(string message, string[] args, User user)
{ {
if (!(user.Administrator || user.Moderator)) if (!user.Administrator && !user.Moderator)
return false; return false;
user.Stealth = !user.Stealth; user.Stealth = !user.Stealth;
@ -361,8 +361,9 @@ namespace HISP.Game.Chat
public static bool Rules(string message, string[] args, User user) public static bool Rules(string message, string[] args, User user)
{ {
if (!(user.Administrator || user.Moderator)) if (!user.Administrator && !user.Moderator)
return false; return false;
if (args.Length <= 0) if (args.Length <= 0)
return false; return false;
@ -386,8 +387,9 @@ namespace HISP.Game.Chat
public static bool Prison(string message, string[] args, User user) public static bool Prison(string message, string[] args, User user)
{ {
if (!(user.Administrator || user.Moderator)) if (!user.Administrator && !user.Moderator)
return false; return false;
if (args.Length <= 0) if (args.Length <= 0)
return false; return false;
@ -411,8 +413,9 @@ namespace HISP.Game.Chat
} }
public static bool Kick(string message, string[] args, User user) public static bool Kick(string message, string[] args, User user)
{ {
if (!(user.Administrator || user.Moderator)) if (!user.Administrator && !user.Moderator)
return false; return false;
if (args.Length <= 0) if (args.Length <= 0)
return false; return false;
@ -426,7 +429,9 @@ namespace HISP.Game.Chat
toKick.LoggedinClient.Kick(reason); toKick.LoggedinClient.Kick(reason);
} }
else else
{
toKick.LoggedinClient.Kick(Messages.KickReasonKicked); toKick.LoggedinClient.Kick(Messages.KickReasonKicked);
}
} }
catch (KeyNotFoundException) catch (KeyNotFoundException)
{ {

View file

@ -2707,27 +2707,27 @@ namespace HISP.Game
{ {
return YouEarnedAnItemFormat.Replace("%ITEM%", itemName); return YouEarnedAnItemFormat.Replace("%ITEM%", itemName);
} }
public static string FormatSellMessage(string itemName, int price) public static string FormatSellMessage(string itemName, UInt64 price)
{ {
return Sold1Format.Replace("%ITEM%", itemName).Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture)); return Sold1Format.Replace("%ITEM%", itemName).Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture));
} }
public static string FormatSellAllMessage(string itemName, int price, int sellAmount) public static string FormatSellAllMessage(string itemName, UInt64 price, int sellAmount)
{ {
return SoldAllFormat.Replace("%AMOUNT%",sellAmount.ToString()).Replace("%ITEM%", itemName).Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture)); return SoldAllFormat.Replace("%AMOUNT%",sellAmount.ToString()).Replace("%ITEM%", itemName).Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture));
} }
public static string FormatBuy25Message(string itemName, int price) public static string FormatBuy25Message(string itemName, UInt64 price)
{ {
return Brought25Format.Replace("%ITEM%", itemName).Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture)); return Brought25Format.Replace("%ITEM%", itemName).Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture));
} }
public static string FormatBuy5Message(string itemName, int price) public static string FormatBuy5Message(string itemName, UInt64 price)
{ {
return Brought5Format.Replace("%ITEM%", itemName).Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture)); return Brought5Format.Replace("%ITEM%", itemName).Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture));
} }
public static string FormatBuyMessage(string itemName, int price) public static string FormatBuyMessage(string itemName, UInt64 price)
{ {
return Brought1Format.Replace("%ITEM%", itemName).Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture)); return Brought1Format.Replace("%ITEM%", itemName).Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture));
} }
public static string FormatShopEntry(int iconid, string count, string name, int price) public static string FormatShopEntry(int iconid, string count, string name, UInt64 price)
{ {
return ShopEntryFormat.Replace("%ICONID%", iconid.ToString()).Replace("%COUNT%", count).Replace("%TITLE%", name).Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture)); return ShopEntryFormat.Replace("%ICONID%", iconid.ToString()).Replace("%COUNT%", count).Replace("%TITLE%", name).Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture));
} }

View file

@ -36,13 +36,13 @@ namespace HISP.Game.Services
Shop.ShopList.Add(this); Shop.ShopList.Add(this);
} }
public int CalculateBuyCost(Item.ItemInformation item) public UInt64 CalculateBuyCost(Item.ItemInformation item)
{ {
return (int)Math.Round((float)item.SellPrice * (100.0 / (float)BuyPricePercentage)); return (UInt64)Math.Round((float)item.SellPrice * (100.0 / (float)BuyPricePercentage));
} }
public int CalculateSellCost(Item.ItemInformation item) public UInt64 CalculateSellCost(Item.ItemInformation item)
{ {
return (int)Math.Round((float)item.SellPrice * (100.0 / (float)SellPricePercentage)); return (UInt64)Math.Round((float)item.SellPrice * (100.0 / (float)SellPricePercentage));
} }
public bool CanSell(Item.ItemInformation item) public bool CanSell(Item.ItemInformation item)

View file

@ -68,8 +68,8 @@ namespace HISP.Player
public int SecCodeCount = 0; public int SecCodeCount = 0;
public int Id; public int Id;
public string Username; public string Username;
public bool Administrator; public bool Administrator = false;
public bool Moderator; public bool Moderator = false;
public bool NewPlayer = false; public bool NewPlayer = false;
public GameClient LoggedinClient; public GameClient LoggedinClient;
public CompetitionGear EquipedCompetitionGear; public CompetitionGear EquipedCompetitionGear;

View file

@ -6909,11 +6909,11 @@ namespace HISP.Server
Shop shop = sender.LoggedinUser.LastShoppedAt; Shop shop = sender.LoggedinUser.LastShoppedAt;
if (shop != null) if (shop != null)
{ {
int sellPrice = shop.CalculateSellCost(itemInfo) * totalSold; UInt64 sellPrice = (shop.CalculateSellCost(itemInfo) * (UInt64)totalSold);
if (shop.CanSell(itemInfo)) if (shop.CanSell(itemInfo))
{ {
// Check if goes over 2.1b // Check if goes over 2.1b
if (sender.LoggedinUser.Money + sellPrice > 2100000000) if ((UInt64)sender.LoggedinUser.Money + sellPrice > 2100000000)
{ {
byte[] cantSellMoneyCapCheck = PacketBuilder.CreateChat(Messages.CannotSellYoudGetTooMuchMoney, PacketBuilder.CHAT_BOTTOM_RIGHT); byte[] cantSellMoneyCapCheck = PacketBuilder.CreateChat(Messages.CannotSellYoudGetTooMuchMoney, PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(cantSellMoneyCapCheck); sender.SendPacket(cantSellMoneyCapCheck);
@ -6928,7 +6928,7 @@ namespace HISP.Server
shop.Inventory.Add(itemInstance); shop.Inventory.Add(itemInstance);
} }
sender.LoggedinUser.AddMoney(sellPrice); sender.LoggedinUser.AddMoney((int)sellPrice);
UpdateAreaForAll(sender.LoggedinUser.X, sender.LoggedinUser.Y, true); UpdateAreaForAll(sender.LoggedinUser.X, sender.LoggedinUser.Y, true);
if(message == 1) if(message == 1)
@ -6939,10 +6939,11 @@ namespace HISP.Server
if(message == 2) if(message == 2)
{ {
string name = itemInfo.Name; string name = itemInfo.Name;
if (totalSold > 1) if (totalSold > 1)
name = itemInfo.PluralName; name = itemInfo.PluralName;
byte[] soldItemMessage = PacketBuilder.CreateChat(Messages.FormatSellAllMessage(name, sellPrice,totalSold), PacketBuilder.CHAT_BOTTOM_RIGHT); byte[] soldItemMessage = PacketBuilder.CreateChat(Messages.FormatSellAllMessage(name, sellPrice, totalSold), PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(soldItemMessage); sender.SendPacket(soldItemMessage);
} }
@ -7058,7 +7059,7 @@ namespace HISP.Server
shop = sender.LoggedinUser.LastShoppedAt; shop = sender.LoggedinUser.LastShoppedAt;
if (shop != null) if (shop != null)
{ {
int buyCost = shop.CalculateBuyCost(itemInfo) * count; UInt64 buyCost = (shop.CalculateBuyCost(itemInfo) * (UInt64)count);
if (sender.LoggedinUser.Bids.Length > 0) if (sender.LoggedinUser.Bids.Length > 0)
{ {
byte[] cantBuyWhileAuctioning = PacketBuilder.CreateChat(Messages.AuctionNoOtherTransactionAllowed, PacketBuilder.CHAT_BOTTOM_RIGHT); byte[] cantBuyWhileAuctioning = PacketBuilder.CreateChat(Messages.AuctionNoOtherTransactionAllowed, PacketBuilder.CHAT_BOTTOM_RIGHT);
@ -7066,7 +7067,7 @@ namespace HISP.Server
return; return;
} }
if (sender.LoggedinUser.Money < buyCost) if ((UInt64)sender.LoggedinUser.Money < buyCost)
{ {
byte[] cantAffordMessage = PacketBuilder.CreateChat(Messages.CantAfford1, PacketBuilder.CHAT_BOTTOM_RIGHT); byte[] cantAffordMessage = PacketBuilder.CreateChat(Messages.CantAfford1, PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(cantAffordMessage); sender.SendPacket(cantAffordMessage);
@ -7085,7 +7086,7 @@ namespace HISP.Server
if (sender.LoggedinUser.Inventory.HasItemId(itemId)) if (sender.LoggedinUser.Inventory.HasItemId(itemId))
{ {
InventoryItem items = sender.LoggedinUser.Inventory.GetItemByItemId(itemId); InventoryItem items = sender.LoggedinUser.Inventory.GetItemByItemId(itemId);
if (items.ItemInstances.Length + count > Item.MAX_STACK) if (items.ItemInstances.Length + (int)count > Item.MAX_STACK)
{ {
goto showError; goto showError;
} }
@ -7111,7 +7112,7 @@ namespace HISP.Server
shop.Inventory.Remove(itemInstance); shop.Inventory.Remove(itemInstance);
} }
sender.LoggedinUser.TakeMoney(buyCost); sender.LoggedinUser.TakeMoney((int)buyCost);
// Send chat message to client. // Send chat message to client.