Page 1 of 15 12311 ... LastLast
Results 1 to 10 of 143
  1. #1
    Procon Addict
    Join Date
    Dec 2013
    Location
    Sydney, Australia
    Posts
    502

    Insane Limits: BF4 Gunmaster Random Presets

    This limit will randomly select and set a different Gunmaster presets after each round whilst ensuring that the next preset is not the same as the previous one.

    Updated to support Zavod: Graveyard Shift and Night weapons preset.

    Options:
    • The value highlighted in red is the delay in seconds before selecting and setting a new weapons preset, if this is set to 0 then there will be no delay. (Useful for mixed mode servers and servers running xVoteMap and/or UMM, a good value would be 40 seconds).
    • If you added vars.gunMasterWeaponsPreset to your startup.txt, change the value highlighted in green to the same value as your startup.txt, otherwise leave this set to 0.
    • If the value highlighted in blue is set to true, then the next weapons preset will always be the new Night preset if the next gun master map is Zavod Graveyard Shift, regardless of which presets are or are not allowed. If set to false, then the preset will be randomly selected from the allowed presets.
    • The values highlighted in orange control which presets can be selected. If set to true, then the preset will be available for random selection. If set to false, then the preset will be unavailable.
    • The values highlighted in purple are for sending an in-game yell message and/or chat message displaying the next weapons preset. If set to true, then the message/yell will be displayed. If set to false the message/yell will not be displayed.
    • The value highlighted in turquoise controls logging to Procon. If set to true, then logging will occur. If set to false, then logging will not occur.


    BF4 Gunmaster Random Presets

    Create a new limit to evaluate OnRoundOver. Set action to None.

    Set first_check to this Code:
    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;

    End of post.
    Last edited by LCARSx64; 03-09-2015 at 05:59. Reason: Updated to support Zavod Graveyard Shift and Night preset

  2. #2
    Hi LCARSx64,

    Beside DICE presets, is there any way we can create our own custom list and add it into (Insane Limits: BF4 Gunmaster Random Presets)?

  3. #3
    Procon Addict
    Join Date
    Dec 2013
    Location
    Sydney, Australia
    Posts
    502
    Quote Originally Posted by moacco07 View Post
    Hi LCARSx64,

    Beside DICE presets, is there any way we can create our own custom list and add it into (Insane Limits: BF4 Gunmaster Random Presets)?
    Do you mean adding your own custom gun progression like magnum then mtar then phantom etc.? If so, then no there's no way that I'm aware of. I was hoping to have the same option.

  4. #4
    That's too bad.. But thank you for the codes. Appreciate it.

  5. #5
    Procon Plugin Tester
    Join Date
    Nov 2011
    Posts
    472
    We're running GM in a mixed-mode environment. Would someone be able to assist with code to check if next map set to run IS gun master? If it is, select one of the random presets. If it's not, take no action.

    Example for on round over:

    If next round gun master = true. Select random preset and inform server.
    If next round gun master = false. Do nothing.

    Thank you
    Last edited by dyn; 27-05-2015 at 19:15. Reason: added a bit

  6. #6
    Procon Addict
    Join Date
    Dec 2013
    Location
    Sydney, Australia
    Posts
    502
    Quote Originally Posted by dyn View Post
    We're running GM in a mixed-mode environment. Would someone be able to assist with code to check if next map set to run IS gun master? If it is, select one of the random presets. If it's not, take no action.

    Example for on round over:

    If next round gun master = true. Select random preset and inform server.
    If next round gun master = false. Do nothing.

    Thank you!

    Edit:

    I think this is correct - adding this to the first line?
    Add the following at the start of the code:
    Code:
    if (server.NextGamemode != "GunMaster0") return false;
    NOTE: I haven't tested this.

  7. #7
    Procon Plugin Tester
    Join Date
    Nov 2011
    Posts
    472
    It displayed the message for Gun Master (in game / procon) and then didn't do anything on a different mode, using your code example. Looked to be working! Woot! I have edited my post to remove conflicting info.

    The item that I did not see was any vars.gunMasterWeaponsPreset command being issued which would have changed it to Pistol preset. The message displayed in chat saying that the next preset was to be 'pistols' but then we had, what I believe to be, the standard preset.

    On a round other than GM I have set it to go to Pistol. Would the multiple game modes cause issues with it not knowing what previous modes have been... then not knowing which preset to randomly select?

  8. #8
    Procon Addict
    Join Date
    Dec 2013
    Location
    Sydney, Australia
    Posts
    502
    Quote Originally Posted by dyn View Post
    It displayed the message for Gun Master (in game / procon) and then didn't do anything on a different mode, using your code example. Looked to be working! Woot! I have edited my post to remove conflicting info.

    The item that I did not see was any vars.gunMasterWeaponsPreset command being issued which would have changed it to Pistol preset. The message displayed in chat saying that the next preset was to be 'pistols' but then we had, what I believe to be, the standard preset.

    On a round other than GM I have set it to go to Pistol. Would the multiple game modes cause issues with it not knowing what previous modes have been... then not knowing which preset to randomly select?
    I'm not sure I fully understand. Are you saying it's working before the other gamemode and then doesn't work after it?
    If you manually change the preset to Pistol during the non-gunmaster round, it will not stay set at that, the limit will see that the next gamemode is gunmaster and then randomly select a different preset then what had been set during the last gunmaster round.

  9. #9
    Procon Plugin Tester
    Join Date
    Nov 2011
    Posts
    472
    Sorry -- after vacation brain farts for me.

    The limit DID fire on round end as it saw that the next round was going to be GM and sent the message out to the server stating that. This same message was visible in Procon chat.

    However, once the level actually loaded the preset was actually Standard... Not pistols like it should have been. So game mode loaded the wrong preset.

  10. #10
    Procon Addict
    Join Date
    Dec 2013
    Location
    Sydney, Australia
    Posts
    502
    Quote Originally Posted by dyn View Post
    Sorry -- after vacation brain farts for me.

    The limit DID fire on round end as it saw that the next round was going to be GM and sent the message out to the server stating that. This same message was visible in Procon chat.

    However, once the level actually loaded the preset was actually Standard... Not pistols like it should have been. So game mode loaded the wrong preset.
    Ah I see, unfortunately when you manually set the preset before then end of a round, the limit has no way of knowing this and then selects a random preset for the next (gunmaster) round.
    I'll change the code when I get a chance and add a command to enable manual preset selection.

 

 

Posting Permissions

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