mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-23 05:05:53 +12:00
added stats idk!!
This commit is contained in:
parent
b678936384
commit
8078554918
5 changed files with 367 additions and 230 deletions
|
@ -24,6 +24,9 @@ namespace HISP.Server
|
|||
string ShopInventory = "CREATE TABLE ShopInventory(ShopID INT, RandomID INT, ItemID INT)";
|
||||
string DroppedItems = "CREATE TABLE DroppedItems(X INT, Y INT, RandomID INT, ItemID INT, DespawnTimer INT)";
|
||||
string TrackedQuest = "CREATE TABLE TrackedQuest(playerId INT, questId INT, timesCompleted INT)";
|
||||
string OnlineUsers = "CREATE TABLE OnlineUsers(playerId INT, Admin TEXT(3), Moderator TEXT(3))";
|
||||
string DeleteOnlineUsers = "DELETE FROM OnlineUsers";
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -148,6 +151,29 @@ namespace HISP.Server
|
|||
{
|
||||
Logger.WarnPrint(e.Message);
|
||||
};
|
||||
try
|
||||
{
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = OnlineUsers;
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.WarnPrint(e.Message);
|
||||
};
|
||||
try
|
||||
{
|
||||
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = DeleteOnlineUsers;
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.WarnPrint(e.Message);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -379,6 +405,36 @@ namespace HISP.Server
|
|||
sqlCommand.Dispose();
|
||||
}
|
||||
}
|
||||
public static void AddOnlineUser(int playerId, bool Admin, bool Moderator)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
|
||||
sqlCommand.CommandText = "INSERT INTO OnlineUsers VALUES(@playerId, @admin, @moderator)";
|
||||
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||
sqlCommand.Parameters.AddWithValue("@admin", Admin ? "YES" : "NO");
|
||||
sqlCommand.Parameters.AddWithValue("@moderator", Moderator ? "YES" : "NO");
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
}
|
||||
public static void RemoveOnlineUser(int playerId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
|
||||
sqlCommand.CommandText = "DELETE FROM OnlineUsers WHERE (playerId=@playerId)";
|
||||
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
}
|
||||
public static List<ItemInstance> GetShopInventory(int shopId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
|
|
|
@ -198,7 +198,7 @@ namespace HISP.Server
|
|||
|
||||
public void Disconnect()
|
||||
{
|
||||
recvPackets.Abort();
|
||||
|
||||
if(updateTimer != null)
|
||||
updateTimer.Dispose();
|
||||
if(inactivityTimer != null)
|
||||
|
@ -213,6 +213,7 @@ namespace HISP.Server
|
|||
LoggedinUser = null;
|
||||
ClientSocket.Close();
|
||||
ClientSocket.Dispose();
|
||||
recvPackets.Abort();
|
||||
}
|
||||
|
||||
public void Kick(string Reason)
|
||||
|
|
|
@ -65,6 +65,7 @@ namespace HISP.Server
|
|||
Logger.ErrorPrint(sender.RemoteIp + " Requested user information when not logged in.");
|
||||
return;
|
||||
}
|
||||
Database.AddOnlineUser(sender.LoggedinUser.Id, sender.LoggedinUser.Administrator, sender.LoggedinUser.Moderator);
|
||||
Logger.DebugPrint(sender.LoggedinUser.Username + " Requested user information.");
|
||||
|
||||
User user = sender.LoggedinUser;
|
||||
|
@ -1205,9 +1206,10 @@ namespace HISP.Server
|
|||
public static void OnDisconnect(GameClient sender)
|
||||
{
|
||||
connectedClients.Remove(sender);
|
||||
|
||||
Logger.DebugPrint("owoo disconnect");
|
||||
if (sender.LoggedIn)
|
||||
{
|
||||
Database.RemoveOnlineUser(sender.LoggedinUser.Id);
|
||||
// Send disconnect message
|
||||
byte[] logoutMessageBytes = PacketBuilder.CreateChat(Messages.FormatLogoutMessage(sender.LoggedinUser.Username), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||
foreach (GameClient client in ConnectedClients)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue