start work on auto sell

This commit is contained in:
SilicaAndPina 2021-03-20 16:48:44 +13:00
parent adc52f3b35
commit 770f078992
6 changed files with 94 additions and 4 deletions

View file

@ -10,6 +10,9 @@ namespace HISP.Game
{
public static int RequiredChatViolations;
// Message Queue
public static string MessageQueueHeader;
// Mod isle
public static string ModIsleMessage;
@ -677,6 +680,7 @@ namespace HISP.Game
public static string HorseProfileButtonFormat;
public static string HorseNoAutoSell;
public static string HorseAutoSellOthersFormat;
public static string HorseAutoSellFormat;
public static string HorseAutoSellPriceFormat;
public static string HorseCantAutoSellTacked;
@ -1994,6 +1998,10 @@ namespace HISP.Game
{
return HorseAutoSellPriceFormat.Replace("%MONEY%", money.ToString("N0", CultureInfo.InvariantCulture));
}
public static string FormatAutoSellOthers(int price)
{
return HorseAutoSellOthersFormat.Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture));
}
public static string FormatAutoSell(string autoSellStr)
{
return HorseAutoSellFormat.Replace("%AUTOSELL%", autoSellStr);

View file

@ -2325,10 +2325,16 @@ namespace HISP.Game
message += Messages.R1;
}
}
else
{
if (horse.AutoSell > 0)
message += Messages.FormatAutoSellOthers(horse.AutoSell);
}
if (horse.Leaser == 0)
{
if (isMyHorse)
message += Messages.FormatHorseCategory(horse.Category, Messages.HorseMarkAsCategory);
else

View file

@ -26,6 +26,7 @@ namespace HISP.Server
string ExtTable = "CREATE TABLE IF NOT EXISTS UserExt(Id INT, X INT, Y INT, LastLogin INT, Money INT, QuestPoints INT, BankBalance DOUBLE, BankInterest DOUBLE, ProfilePage Text(1028),IpAddress TEXT(1028),PrivateNotes Text(1028), CharId INT, ChatViolations INT,Subscriber TEXT(3), SubscribedUntil INT, Experience INT, Tiredness INT, Hunger INT, Thirst INT, FreeMinutes INT)";
string MailTable = "CREATE TABLE IF NOT EXISTS Mailbox(RandomId INT, IdTo INT, IdFrom INT, Subject TEXT(128), Message Text(1028), TimeSent INT, BeenRead TEXT(3))";
string BuddyTable = "CREATE TABLE IF NOT EXISTS BuddyList(Id INT, IdFriend INT)";
string MessageQueue = "CREATE TABLE IF NOT EXISTS MessageQueue(Id INT, Message TEXT(1028))";
string WorldTable = "CREATE TABLE World(Time INT, Day INT, Year INT, StartTime INT)";
string WeatherTable = "CREATE TABLE IF NOT EXISTS Weather(Area TEXT(1028), Weather TEXT(64))";
string InventoryTable = "CREATE TABLE IF NOT EXISTS Inventory(PlayerID INT, RandomID INT, ItemID INT, Data INT)";
@ -56,6 +57,17 @@ namespace HISP.Server
string SolvedRealTimeRiddle = "CREATE TABLE IF NOT EXISTS SolvedRealTimeRiddles(playerId INT, riddleId INT)";
string DeleteOnlineUsers = "DELETE FROM OnlineUsers";
try
{
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = MessageQueue;
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
catch (Exception e)
{
Logger.WarnPrint(e.Message);
};
try
{
@ -543,6 +555,53 @@ namespace HISP.Server
}
}
public static void AddMessageToQueue(int userId, string message)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "INSERT INTO MessageQueue VALUES(@id,@message)";
sqlCommand.Parameters.AddWithValue("@id", userId);
sqlCommand.Parameters.AddWithValue("@message", message);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void ClearMessageQueue(int userId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "DELETE FROM MessageQueue WHERE Id=@id";
sqlCommand.Parameters.AddWithValue("@id", userId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static string[] GetMessageQueue(int userId)
{
List<string> msgQueue = new List<string>();
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT message FROM MessageQueue WHERE Id=@id";
sqlCommand.Parameters.AddWithValue("@id", userId);
sqlCommand.Prepare();
MySqlDataReader reader = sqlCommand.ExecuteReader();
while(reader.Read())
{
msgQueue.Add(reader.GetString(0));
}
sqlCommand.Dispose();
}
return msgQueue.ToArray();
}
public static void SetDressupRoomPeiceX(int roomId, int peiceId, int newX)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))

View file

@ -867,6 +867,8 @@ namespace HISP.Server
Messages.SocialTypeFormat = gameData.messages.meta.player_interaction.socials.socials_menu_type;
Messages.SocialPlayerNoLongerNearby = gameData.messages.meta.player_interaction.socials.no_longer_nearby;
// Message Queue
Messages.MessageQueueHeader = gameData.messages.message_queue;
// Events : Real Time Riddle
@ -1512,6 +1514,7 @@ namespace HISP.Server
Messages.HorseNoAutoSell = gameData.messages.meta.horse.horse_inventory.no_auto_sell;
Messages.HorseAutoSellPriceFormat = gameData.messages.meta.horse.horse_inventory.auto_sell_format;
Messages.HorseAutoSellOthersFormat = gameData.messages.meta.horse.horse_inventory.auto_sell_others;
Messages.HorseAutoSellFormat = gameData.messages.meta.horse.horse_inventory.auto_sell;
Messages.HorseCantAutoSellTacked = gameData.messages.meta.horse.horse_inventory.cannot_auto_sell_tacked;

View file

@ -3286,6 +3286,15 @@ namespace HISP.Server
byte[] MotdData = PacketBuilder.CreateMotd();
sender.SendPacket(MotdData);
// Send Queued Messages
string[] queuedMessages = Database.GetMessageQueue(sender.LoggedinUser.Id);
foreach(string queuedMessage in queuedMessages)
{
byte[] msg = PacketBuilder.CreateChat(Messages.MessageQueueHeader+queuedMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(msg);
}
Database.ClearMessageQueue(sender.LoggedinUser.Id);
}
public static void OnSwfModuleCommunication(GameClient sender, byte[] packet)