Plus Emu Userpeak or record online fix

Newbie Spellweaver
Joined
Feb 4, 2012
Messages
46
Reaction score
3
Hello to everybody (sa turkler icin),

I noticed a problem on the server_status table userpeak column, this one does not produce update the new user record amount in the db.
I share this if people have the same problem as me I know it is a little fix, but maybe it can help some people out.
Sorry for my bad English, I am Dutch.

Here you go The solution:

For the people that only want to have the method:
Code:
private void UpdateOnlineUsers()
        {
            TimeSpan Uptime = DateTime.Now - PlusEnvironment.ServerStarted;

            int UsersOnline = Convert.ToInt32(PlusEnvironment.GetGame().GetClientManager().Count);
            int RoomCount = PlusEnvironment.GetGame().GetRoomManager().Count;

            Console.Title = "Baykus Emulator - " + UsersOnline + " users online - " + RoomCount + "geladen kamers - " + Uptime.Days + " dag(en) " + Uptime.Hours + " uur(en) aan";

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `server_status` SET `users_online` = [USER=1335]user[/USER]s, `loaded_rooms` = @loadedRooms LIMIT 1;");
                dbClient.AddParameter("users", UsersOnline);
                dbClient.AddParameter("loadedRooms", RoomCount);
                dbClient.RunQuery();
            }

            int userPeak;
            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `userpeak` FROM `server_status` LIMIT 1");
                userPeak = dbClient.getInteger();
            }
            if (UsersOnline > userPeak)
            {
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `server_status` SET `userpeak` = [USER=1335]user[/USER]peak LIMIT 1;");
                    dbClient.AddParameter("userpeak", UsersOnline);
                    dbClient.RunQuery();
                }
            }
        }
Source: ServerStatusUpdater.cs in linenumber 39.

And maybe people that are better than me in coding could help with performans? Or pascalcases. camelcase that I dit forget.I'm always open for new ideas! Even though it is 6 lines code.
Enjoy !

-Baykus (ctarikc)
 
Experienced Elementalist
Joined
Nov 11, 2015
Messages
238
Reaction score
89
Console.Title = "Baykus Emulator - " + UsersOnline + " users online - " + RoomCount + "geladen kamers - " + Uptime.Days + " dag(en) " + Uptime.Hours + " uur(en) aan";

Horrible,
the fix itself might be useful though.