Plus Emu Userpeak or record online fix

Results 1 to 2 of 2
  1. #1
    Member CtarikC is offline
    MemberRank
    Feb 2012 Join Date
    63Posts

    note Plus Emu Userpeak or record online fix

    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: [C#] ServerStatusUpdater.cs - Pastebin.com

    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` = @users, `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` = @userpeak 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)


  2. #2
    The **** Keiz is offline
    MemberRank
    Nov 2015 Join Date
    238Posts

    Re: Plus Emu Userpeak or record online fix

    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.



Advertisement