Loadout Script

Does this sound interesting?

  • Yes

    Votes: 0 0.0%
  • No

    Votes: 0 0.0%

  • Total voters
    0
  • Poll closed .

Inkko

Valued Member!
I created a loadout script a while ago, since dayz doesn't have the hive 999 call anymore, is anyone interested in something like this at all?

Its a server side/mission side addon. All loadout info is stored server side so there is no re-downloading the mission file with every change and mission side just handles the actual gear giving portion. I currently have it so players can earn ingame rewards and it'll auto give loadouts ect but it can also handle player ID loadouts etc.

Currently it is tied in with ESSv2 with the class selection taken out but it should be easy for me to seperate it out into its own script if anyone is interested I'll put it together into an addon.

How it works:
Player enters game, takes a step and broadcast info to server. Server finds info and sends back to client for loadout info if found. Has a fail safe to execute default loadout if nothing is found. Also is configurable to what you would like the default loadout to be.
 
i'm kinda interested, yes. Right now I wrote one that spawns a box in front of you based on humanity. It took a while to make sure that I got the humanity set from the server before spawn. I wanted to place the gear on the player but it was an issue with server_playerLogin having access to the character, but not humanity and server_playerSetup having humanity (or vice versa).
 
i'm kinda interested, yes. Right now I wrote one that spawns a box in front of you based on humanity. It took a while to make sure that I got the humanity set from the server before spawn. I wanted to place the gear on the player but it was an issue with server_playerLogin having access to the character, but not humanity and server_playerSetup having humanity (or vice versa).

Its practically the sever player login but pulls from a PVEH server side to see what to give to the player.
 
Here is pretty much all the code for the loadout system I put together.

Code:
if (isServer) exitwith {};

waitUntil {!isNil "PVDZ_plr_LoginRecord"};

if (count PVCDZ_plr_Login2 > 3) then {
    /* Initial Variables */
    player addWeapon "ItemMap";
    systemchat format["BRLS :: Welcome %1, loadout system initializing...",name player];
    sleep 1;
    systemchat "BRLS :: Loadout system waiting for player to fully enter game...";
    waituntil {alive player};
    systemchat "BRLS :: Loadout system awaiting player movement...";
    waituntil {speed player > 1};
    systemchat "BRLS :: Loadout system starting...";
    PVCDZ_Loadout_Client = [];
    BRLS_DefaultP = ["M9_DZ","M9_SD_DZ","G17_SD_DZ","G17_DZ"] call bis_fnc_selectrandom;
    BRLS_DefaultW = ["ItemFlashlight","ItemCompass","ItemMap","ItemMachete"];
    BRLS_CustomTools = ["ItemCompass","ItemMachete","ItemMap","ItemFlashlight","ItemEtool","ItemGPS","ItemHatchet","ItemKnife","ItemMatchbox","ItemToolbox","ItemWatch","NVGoggles","Binocular_Vector"];
    BRLS_DefaultM = ["ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemMorphine","ItemAntibiotic","bloodBagONEG","FoodBeefCooked","ItemPainkiller","ItemWaterbottle","PartGeneric"];
    BRLS_DefaultB = "DZ_Assault_Pack_EP1";
    /* End Initial Vars */

    _puid = getPlayerUID player;
    PVCDZ_Loadout_Server = [player,_puid];
    publicVariableServer "PVCDZ_Loadout_Server";

    _timeout = time + 30;
    waituntil {(count PVCDZ_Loadout_Client > 1) || (time > _timeout) || PVCDZ_Loadout_Client select 0 == "Default"};
    if (count PVCDZ_Loadout_Client < 1) then {
        PVCDZ_Loadout_Client = ["Default"];
    };

    /* Wipe the character */
    {
        player removeWeapon _x;
    } foreach (weapons player);
    {
        player removeMagazine _x;
    } foreach (magazines player);
    if (unitBackpack player != objNull) then {
        removeBackpack player;
    };
    /* Wipe Complete */

    /* loadout var check */
    _loadout = PVCDZ_Loadout_Client select 0;
    _loadoutstatus = profileNamespace getVariable 'Loadout_Togg';if (isnil '_loadoutstatus') then {profileNamespace setVariable ['Loadout_Togg',false];};
    if (_loadout == "Default" || _loadoutstatus) then {
      
        // default loadout
      
        /*pistol randomization and ammo*/
        if (BRLS_DefaultP == "M9_DZ") then {
            BRLS_DefaultPM = "15Rnd_9x19_M9";
        } else {
            if (BRLS_DefaultP == "M9_SD_DZ") then {
                BRLS_DefaultPM = "15Rnd_9x19_M9SD";
            } else {
                if (BRLS_DefaultP == "G17_DZ") then {
                    BRLS_DefaultPM = "17Rnd_9x19_glock17";
                } else {
                    BRLS_DefaultPM = "17Rnd_9x19_glock17SD";
                };
            };
        };

        BRLS_DefaultWeapons = BRLS_DefaultW + [BRLS_DefaultP];
        BRLS_DefaultMagazines = BRLS_DefaultM + [BRLS_DefaultPM] + [BRLS_DefaultPM] + [BRLS_DefaultPM];
      
      
        [BRLS_DefaultWeapons,BRLS_DefaultMagazines] call player_gearSet;
        player addBackpack BRLS_DefaultB;
      
        dayz_myBackpack =    unitBackpack player;
        dayz_myBackpackMags =    getMagazineCargo dayz_myBackpack;
        dayz_myBackpackWpns =    getWeaponCargo dayz_myBackpack;
      
    } else {
        BRLS_CustomW = PVCDZ_Loadout_Client select 0;
        BRLS_CustomP = PVCDZ_Loadout_Client select 1;
        BRLS_CustomWM = PVCDZ_Loadout_Client select 2;
        BRLS_CustomPM = PVCDZ_Loadout_Client select 3;
        BRLS_CustomB = PVCDZ_Loadout_Client select 4;
        BRLS_CustomBW = PVCDZ_Loadout_Client select 5;
        BRLS_CustomBM = PVCDZ_Loadout_Client select 6;
        BRLS_CustomSk = PVCDZ_Loadout_Client select 7;
      
        if (BRLS_CustomW == "Improved") then {
        BRLS_CustomWeapons = BRLS_CustomTools + [BRLS_CustomP];
        BRLS_CustomMagazines = BRLS_DefaultM + [BRLS_CustomPM] + [BRLS_CustomPM] + [BRLS_CustomPM];
        } else {
            if (BRLS_CustomWM in ["100Rnd_762x51_M240","200Rnd_556x45_M249"]) then {
                BRLS_CustomWeapons = BRLS_CustomTools + [BRLS_CustomP] + [BRLS_CustomW];
                BRLS_CustomMagazines = BRLS_DefaultM + [BRLS_CustomPM] + [BRLS_CustomPM] + [BRLS_CustomPM] + [BRLS_CustomWM] + [BRLS_CustomWM];
            } else {
                BRLS_CustomWeapons = BRLS_CustomTools + [BRLS_CustomP] + [BRLS_CustomW];
                BRLS_CustomMagazines = BRLS_DefaultM + [BRLS_CustomPM] + [BRLS_CustomPM] + [BRLS_CustomPM] + [BRLS_CustomWM] + [BRLS_CustomWM] + [BRLS_CustomWM];
            };
        };
      
        [BRLS_CustomWeapons,BRLS_CustomMagazines] call player_gearSet;
      
        player addBackpack BRLS_CustomB;
        dayz_myBackpack =    unitBackpack player;
        _backpackMagTypes = [];
        _backpackMagQty = [];
        if (count BRLS_CustomBM > 0) then {
            _backpackMagTypes = BRLS_CustomBM select 0;
            _backpackMagQty = BRLS_CustomBM select 1;
        };
        _countr = 0;
      
        //Fill backpack contents
        //Weapons
        _backpackWpnTypes = [];
        _backpackWpnQtys = [];
        if (count BRLS_CustomBW > 0) then {
            _backpackWpnTypes = BRLS_CustomBW select 0;
            _backpackWpnQtys =     BRLS_CustomBW select 1;
        };
        //diag_log format["%1",_backpackWpnTypes];
        //diag_log format["%1",_backpackWpnQtys];
        _countr = 0;
        {
            if (_x == "Crossbow") then { _x = "Crossbow_DZ" };
            if (_x == "DMR") then { _x = "DMR_DZ" };
            //if (_x == "M14_EP1") then { _x = "M14_DZ" };
            if (_x == "SVD") then { _x = "SVD_DZ" };
            if (_x == "SVD_CAMO") then { _x = "SVD_CAMO_DZ" };
            dayz_myBackpack addWeaponCargoGlobal [_x,(_backpackWpnQtys select _countr)];
            _countr = _countr + 1;
        } forEach _backpackWpnTypes;
        //Magazines
        _countr = 0;
        {
            if (_x == "BoltSteel") then { _x = "WoodenArrow" };
            if (_x == "ItemBloodbag") then { _x = "bloodBagONEG" };
            dayz_myBackpack addMagazineCargoGlobal [_x,(_backpackMagQty select _countr)];
            _countr = _countr + 1;
        } forEach _backpackMagTypes;
      
        if (BRLS_CustomSk != "") then {
            [dayz_playerUID,dayz_characterID,BRLS_CustomSk] spawn player_humanityMorph;
        };
    };
      
call player_forceSave;
      
systemchat "BRLS :: Loadout system complete.";

};

Code:
"PVCDZ_Loadout_Server" addPublicVariableEventHandler {
    [(_this select 1) select 0,(_this select 1) select 1] spawn {
    PVCDZ_Loadout_Client = ["Default"]; // if all else fails send default (fail safe client side anyways after 30sec)
    /*
    //improved default
    ["Improved", "M9_SD_DZ", "5Rnd_762x51_M24", "15Rnd_9x19_M9SD", "DZ_Backpack_EP1", [], []];
  
    [weapon/type, pistol, weapon ammo, pistol ammo, backpack, [[backpack weapon],[ammount]], [[backpack mag],[amount]]]
  
    For empty spaces in array use [] only backpack weapon and mag should ever be empty
    */
    _player = _this select 0;
    _puid = _this select 1;
  
    if (_puid in ["XXX"]) then {
        PVCDZ_Loadout_Client = ["M24_DZ", "M9_SD_DZ", "5Rnd_762x51_M24", "15Rnd_9x19_M9SD", "DZ_Backpack_EP1", [],[["Skin_Soldier1_DZ","Skin_Sniper1_DZ","Skin_Camo1_DZ"],[1,1,1]],""];
    };
  
    if (_puid in ["XXX"]) then {
        PVCDZ_Loadout_Client = ["G36A_Camo_DZ","G17_SD_FL_DZ", "30Rnd_556x45_G36", "17Rnd_9x19_glock17SD", "DZ_Backpack_EP1", [["M24_Gh_DZ"],[1]],[["Skin_Sniper1_DZ","Skin_Camo1_DZ","5Rnd_762x51_M24","equip_string"],[1,1,3,3]],""];
    };
  
    //improved coyote
    if (_puid in ["XXX"]) then {
        //                        Improved should skip main weapon ammo so adding random value to make sure nothing errors client side.
        PVCDZ_Loadout_Client = ["Improved","M9_SD_DZ", "5Rnd_762x51_M24", "15Rnd_9x19_M9SD", "DZ_Backpack_EP1", [],[["Skin_Sniper1_DZ","Skin_Camo1_DZ","Skin_Soldier1_DZ"],[1,1,1]],"Sniper1_DZ"];
    };

    diag_log format[":: BRLS :: %1 (%2) Loadout Gear %3",_player,_puid,PVCDZ_Loadout_Client];
  
    (owner _player) publicVariableClient "PVCDZ_Loadout_Client";
    };
};
 
hmm, I 'm familiar with some of the methodology above, but I've only been scripting dayzmod for a year, so of course some is new. Always something to learn!

This code looks familiar
if (count PVCDZ_plr_Login2 > 3) then {

but in my case I set that 4th entry to _humanity in server_playerSetup.sqf like this:
PVCDZ_plr_Login2 = [_worldspace,_state,_Achievements, _humanity];

I don't see you setting it to anything nor do I see you grabbing a value from it.
 
hmm, I 'm familiar with some of the methodology above, but I've only been scripting dayzmod for a year, so of course some is new. Always something to learn!

This code looks familiar
if (count PVCDZ_plr_Login2 > 3) then {

but in my case I set that 4th entry to _humanity in server_playerSetup.sqf like this:
PVCDZ_plr_Login2 = [_worldspace,_state,_Achievements, _humanity];

I don't see you setting it to anything nor do I see you grabbing a value from it.

Now that you say that it does remind me that I made a change to that file for ESSv2 so that may be an issue... I might have to look into it to see how I can make that portion compatible.
 
Back
Top