Results 1 to 2 of 2
  1. #1

    Hosted Server Procon Crashing

    Hello All,

    Having some issues with my hosted Procon causing my server to become unresponsive after a couple of hours of running. We have very little running on it. Mainly MultiBalancer, ServerKills, TeamKill Tracker, and Insane Limits. After the first couple of lock ups, I disabled most of the stat caching and any kind of querying of external servers. i.e. bf4db, battlelog... etc.

    My theory is that the limit I am using is causing this. I feel like it might now be properly releasing resources. I'm not super familiar with C, but have a high level of experience in scripting across multiple languages. So, I understand most of what's going on in this script, it's really pretty simple, but I feel like it's missing something, and I'm not familiar enough with C to understand 100% how this stuff runs, exits and releases resources. I know that garbage collection how this kind of stuff is clean up, but everything out there says I shouldn't directly call it.

    I'm not sure where to go from here... So, I need someone more adept at this to help me out.

    Code:
    // BF4 Gunmaster Random Presets - Limit 1 of 1
    // v3.0 - OnRoundOver - first_check
    //
    
    Thread gmrnd = new Thread(
        new ThreadStart(
            delegate
            {
                try
                {
                    // USER SETTINGS
                    //
                    int iDelay = 0;
                    int lastPreset = 0;
                    bool ensureNight = true;
                    bool allowStandard = true;
                    bool allowClassic = true;
                    bool allowPistol = true;
                    bool allowDLC = true;
                    bool allowTroll = true;
                    bool allowNight = true;
                    bool showChat = true;
                    bool showYell = true;
                    bool showProcon = true;
                    //
                    // END OF USER SETTINGS
                    if (iDelay > 0)
                    {
                        Thread.Sleep(iDelay * 1000);
                    }
                    if (server.NextGamemode == "GunMaster0" || server.NextGamemode == "GunMaster1")
                    {
                        bool bGetting = true;
                        int nextPreset = 0;
                        int maxPreset = 6;
                        Random rnd = new Random();
                        String lastKey = "_LASTGM_";
                        String[] presets = { "Standard",
                                             "Classic",
                                             "Pistol",
                                             "DLC",
                                             "Troll",
                                             "Night" };
                        String msg = "Next GunMaster preset will be: ";
                        if (server.Data.issetInt(lastKey)) lastPreset = server.Data.getInt(lastKey);
                        nextPreset = rnd.Next(maxPreset);
                        if (ensureNight && server.NextMapFileName == "XP5_Night_01")
                        {
                            nextPreset = 5;
                        }
                        else
                        {
                            while (bGetting)
                            {
                                nextPreset = rnd.Next(maxPreset);
                                if (!allowStandard && nextPreset == 0) nextPreset = lastPreset;
                                if (!allowClassic && nextPreset == 1) nextPreset = lastPreset;
                                if (!allowPistol && nextPreset == 2) nextPreset = lastPreset;
                                if (!allowDLC && nextPreset == 3) nextPreset = lastPreset;
                                if (!allowTroll && nextPreset == 4) nextPreset = lastPreset;
                                if (!allowNight && nextPreset == 5) nextPreset = lastPreset;
                                if (nextPreset != lastPreset) bGetting = false;
                            }
                        }
                        plugin.ServerCommand("vars.gunMasterWeaponsPreset", nextPreset.ToString());
                        if (showChat) plugin.SendGlobalMessage(msg + presets[nextPreset]);
                        if (showYell) plugin.SendGlobalYell("\n" + msg + presets[nextPreset], 8);
                        if (showProcon) plugin.PRoConChat(msg + "^b^1" + presets[nextPreset] + "^0^n.");
                        server.Data.setInt(lastKey, nextPreset);
                    }
                }
                catch (Exception e)
                {
                    plugin.ConsoleException(e.ToString());
                }
            }
        )
    );
    
    gmrnd.Name = "GMPresetRandomizer";
    gmrnd.Start();
    
    return false;

  2. #2
    Procon Addict
    Join Date
    Dec 2013
    Location
    Sydney, Australia
    Posts
    502
    Quote Originally Posted by DrJerkit View Post
    Hello All,

    Having some issues with my hosted Procon causing my server to become unresponsive after a couple of hours of running. We have very little running on it. Mainly MultiBalancer, ServerKills, TeamKill Tracker, and Insane Limits. After the first couple of lock ups, I disabled most of the stat caching and any kind of querying of external servers. i.e. bf4db, battlelog... etc.

    My theory is that the limit I am using is causing this. I feel like it might now be properly releasing resources. I'm not super familiar with C, but have a high level of experience in scripting across multiple languages. So, I understand most of what's going on in this script, it's really pretty simple, but I feel like it's missing something, and I'm not familiar enough with C to understand 100% how this stuff runs, exits and releases resources. I know that garbage collection how this kind of stuff is clean up, but everything out there says I shouldn't directly call it.

    I'm not sure where to go from here... So, I need someone more adept at this to help me out.
    That is actually my code and it works fine for me and many others, however, I noticed your delay setting in the code:
    Code:
    int iDelay = 0;
    Since this value is set to 0, I'm going to assume that you don't require a delay before changing the weapons preset. If this is indeed the case then there is also no need to create a new thread every RoundOver event, so you could use the following code instead and see if that fixes your problem:
    Code:
    // BF4 Gunmaster Random Presets - Limit 1 of 1
    // v3.0.1 - OnRoundOver - first_check
    //
    
    // USER SETTINGS
    //
    int lastPreset = 1;
    bool ensureNight = true;
    bool allowStandard = true;
    bool allowClassic = true;
    bool allowPistol = true;
    bool allowDLC = true;
    bool allowTroll = false;
    bool allowNight = true;
    bool showChat = true;
    bool showYell = true;
    bool showProcon = true;
    
    if (server.NextGamemode == "GunMaster0" || server.NextGamemode == "GunMaster1")
    {
        bool bGetting = true;
        int nextPreset = 0;
        int maxPreset = 6;
        Random rnd = new Random();
        String lastKey = "_LASTGM_";
        String[] presets = { "Standard",
                             "Classic",
                             "Pistol",
                             "DLC",
                             "Troll",
                             "Night" };
        String msg = "Next GunMaster preset will be: ";
        if (server.Data.issetInt(lastKey)) lastPreset = server.Data.getInt(lastKey);
        nextPreset = rnd.Next(maxPreset);
        if (ensureNight && server.NextMapFileName == "XP5_Night_01")
        {
            nextPreset = 5;
        }
        else
        {
            while (bGetting)
            {
                nextPreset = rnd.Next(maxPreset);
                if (!allowStandard && nextPreset == 0) nextPreset = lastPreset;
                if (!allowClassic && nextPreset == 1) nextPreset = lastPreset;
                if (!allowPistol && nextPreset == 2) nextPreset = lastPreset;
                if (!allowDLC && nextPreset == 3) nextPreset = lastPreset;
                if (!allowTroll && nextPreset == 4) nextPreset = lastPreset;
                if (!allowNight && nextPreset == 5) nextPreset = lastPreset;
                if (nextPreset != lastPreset) bGetting = false;
            }
        }
        plugin.ServerCommand("vars.gunMasterWeaponsPreset", nextPreset.ToString());
        if (showChat) plugin.SendGlobalMessage(msg + presets[nextPreset]);
        if (showYell) plugin.SendGlobalYell("\n" + msg + presets[nextPreset], 8);
        if (showProcon) plugin.PRoConChat(msg + "^b^1" + presets[nextPreset] + "^0^n.");
        server.Data.setInt(lastKey, nextPreset);
    }
    
    return false;

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •