Random Premade Starting Gear

Alright nm it works just fine.

["New Player"] has to be in both the inventory and the backpack not just the inventory. (At least this is the case for me on Dayz.ST)
 
Code:
diag_log("Check");
diag_log("Inventory Count: " + str(count _inventory));
if (count _inventory == 1) then {
diag_log("Inventory Select 0: " + str((_inventory select 0)));
if ( (_inventory select 0) == "New Player" ) then {
_chance = round(random 100);
diag_log ("Random chance " + str(_chance));
 
switch (true) do {
case (_chance <= 5):
{
// Huntsman 5%
_inventory = [["ItemCompass","ItemKnife","ItemFlashlight"], ["ItemPainkiller","ItemBandage"]];
_backpack = ["CZ_VestPouch_EP1",[[],[]],[["FoodSteakCooked","ItemSodaCoke"],[1,1]]];
};
case (_chance <= 10):
{
// Police Officer 5%
_inventory = [["M9","ItemFlashlightRed"], ["15Rnd_9x19_M9","15Rnd_9x19_M9","15Rnd_9x19_M9","ItemPainkiller","ItemBandage"]];
_backpack = ["",[[],[]],[[],[]]];
};
 
case (_chance <= 15):
{
// Miltary 5%
_inventory = [["MP5A5","ItemFlashlightRed","ItemGPS"], ["30Rnd_9x19_MP5","30Rnd_9x19_MP5","30Rnd_9x19_MP5","ItemPainkiller","ItemBandage"]];
_backpack = ["DZ_Assault_Pack_EP1",[[],[]],[["FoodCanFrankBeans","ItemSodaCoke"],[1,1]]];
};
 
case (_chance <= 25):
{
// Camper Loadout 10%
_inventory = [["ItemMatchbox","ItemCompass","ItemMap","ItemWatch","ItemFlashlight"], ["ItemTent","ItemPainkiller","ItemBandage"]];
_backpack = ["DZ_CivilBackpack_EP1",[[],[]],[["FoodCanFrankBeans","ItemSodaCoke"],[1,1]]];
};
 
case (_chance <= 35):
{
// Woodsman 10%
_inventory = [["MeleeHatchet"], ["ItemBandage","ItemCompass","ItemPainkiller","ItemBandage","ItemFlashlight"]];
_backpack = ["DZ_Patrol_Pack_EP1",[[],[]],[["ItemHeatPack","ItemSodaCoke"],[1,1]]];
};
 
default
{
_inventory = [["ItemFlashlight","ItemMap"], ["ItemBandage","ItemPainkiller","ItemBandage"]];
_backpack = ["DZ_CivilBackpack_EP1",[[],[]],[["FoodCanFrankBeans","ItemSodaCoke"],[1,1]]];
};
};
};
};
Think you could tell me step by step where to put all the files plz.


This is the part of the server_playerLogin.sqf that controls the randomness. Read Torndeco's post.

basically you can edit this as you see fit Random 100 at the top so its selecting a number, and the rest you can alter the %chances... so like 1-5, then 5-10, 10-11, etc etc... you can make things have as large or as little a chance as you want... I've never played with decimal points, don't think that works .. although if anyone knows how to do that i'd be interested... I would like to create some VERY rare starting loadouts
 
Ok I know how to edit the sqf file so do I just unpack my mission file and place it in there? Do I need to add a line to the init file or will it auto read the sqf that I added?
 
Well the server_playerLogin.sqf is in your server.pbo in the compiles folder. Let me give you an example of the whole thing intact:

Code:
private["_botActive","_int","_newModel","_doLoop","_wait","_hiveVer","_isHiveOk","_playerID","_playerObj","_randomSpot","_publishTo","_primary","_secondary","_key","_result","_charID","_playerObj","_playerName","_finished","_spawnPos","_spawnDir","_items","_counter","_magazines","_weapons","_group","_backpack","_worldspace","_direction","_newUnit","_score","_position","_isNew","_inventory","_backpack","_medical","_survival","_stats","_state"];
//Set Variables
 
diag_log ("STARTING LOGIN: " + str(_this));
 
_playerID = _this select 0;
_playerObj = _this select 1;
_playerName = name _playerObj;
_worldspace = [];
 
if (_playerName == '__SERVER__' || _playerID == '' || local player) exitWith {};
 
if (count _this > 2) then {
    dayz_players = dayz_players - [_this select 2];
};
 
//Variables
_inventory =    [];
_backpack =    [];
_items =        [];
_magazines =    [];
_weapons =        [];
_medicalStats =    [];
_survival =        [0,0,0];
_tent =            [];
_state =        [];
_direction =    0;
_model =        "";
_newUnit =        objNull;
_botActive = false;
 
if (_playerID == "") then {
    _playerID = getPlayerUID _playerObj;
};
 
if ((_playerID == "") or (isNil "_playerID")) exitWith {
    diag_log ("LOGIN FAILED: Player [" + _playerName + "] has no login ID");
};
 
//??? endLoadingScreen;
diag_log ("LOGIN ATTEMPT: " + str(_playerID) + " " + _playerName);
 
//Do Connection Attempt
_doLoop = 0;
while {_doLoop < 5} do {
    _key = format["CHILD:101:%1:%2:%3:",_playerID,dayZ_instance,_playerName];
    _primary = _key call server_hiveReadWrite;
    if (count _primary > 0) then {
        if ((_primary select 0) != "ERROR") then {
            _doLoop = 9;
        };
    };
    _doLoop = _doLoop + 1;
};
 
if (isNull _playerObj or !isPlayer _playerObj) exitWith {
    diag_log ("LOGIN RESULT: Exiting, player object null: " + str(_playerObj));
};
 
if ((_primary select 0) == "ERROR") exitWith {   
    diag_log format ["LOGIN RESULT: Exiting, failed to load _primary: %1 for player: %2 ",_primary,_playerID];
};
 
//Process request
_newPlayer =    _primary select 1;
_isNew =        count _primary < 6; //_result select 1;
_charID =        _primary select 2;
_randomSpot = false;
 
//diag_log ("LOGIN RESULT: " + str(_primary));
 
/* PROCESS */
_hiveVer = 0;
 
if (!_isNew) then {
    //RETURNING CHARACTER       
    _inventory =    _primary select 4;
    _backpack =    _primary select 5;
    _survival =        _primary select 6;
    _model =        _primary select 7;
    _hiveVer =        _primary select 8;
   
    if (_model == "") then {
        _key = format["CHILD:999:select replace(cl.`inventory`, '""', '""""') inventory, replace(cl.`backpack`, '""', '""""') backpack, replace(coalesce(cl.`model`, 'Survivor2_DZ'), '""', '""""') model from `cust_loadout` cl join `cust_loadout_profile` clp on clp.`cust_loadout_id` = cl.`id` where clp.`unique_id` = '?':[%1]:",str(_playerID)];
        _data = "HiveEXT" callExtension _key;
        //Process result
        _result = call compile format ["%1", _data];
        _status = _result select 0;
        if (_status == "CustomStreamStart") then {
            if ((_result select 1) > 0) then {
                _data = "HiveEXT" callExtension _key;
                _result = call compile format ["%1", _data];
                _inventory = call compile (_result select 0);
                _backpack = call compile (_result select 1);
                _model = call compile (_result select 2);
            };
        };
    };
//====================== NOT BELOW HERE ==== CHECK THIS STUFF OUT IN ANOTHER THREAD
if (_playerID == "0000000000") then {
_model = "HazmatVest_Black_DZC";  // Manatee
};
if (_playerID == "0000000000000") then {
_model = "HazmatVest_Black_DZC"; // Banished
};
if (_playerID == "00000000000") then {
_model = "Clan_UN_Helmet_DZC";  // UN GRIMM
};
if (_playerID == "000000000000000") then {
_model = "Clan_UN_Helmet_DZC"; // UN A Widdle Wabbit
};
 
if (_playerID == "000000000000") then {
_model = "Clan_UN_Helmet_DZC"; // UN An Orange Peanut
};
 
if (_playerID == "000000000") then {
_model = "Clan_UN_Helmet_DZC"; // UN Steve Jobs
};
 
if (_playerID == "000000000000000000") then {
_model = "Clan_UN_Helmet_DZC";  // UN General Jam
};
 
if (_playerID == "00000000000000") then {
_model = "Clan_UN_Helmet_DZC"; // UN Splashier Jam
};
 
if (_playerID == "000000000000000") then {
_model = "PrivateSec1_DZC"; // CQF Sandy
};
 
if (_playerID == "00000000") then {
_model = "PrivateSec1_DZC";  // CQF Cheww
};
 
if (_playerID == "0000000000000000") then {
_model = "PrivateSec1_DZC"; // CQF Conrad
};
//================= Not above this ==========
 
//====== This small section don't copy directly=== use ur default====
    if (!(_model in ["SurvivorW2_DZ","Survivor2_DZ","Sniper1_DZ","Soldier1_DZ","Camo1_DZ","BanditW1_DZ","Bandit1_DZ","SurvivorW2_DZ","PrivateSec1_DZC","Clan_UN_Helmet_DZC","HazmatVest_Black_DZC","Storm_Trooper3_DZC","CDF_Soldier_Light","Soldier3_SL_DZC","Soldier2_SL_DZC","Soldier1_SL_DZC","US_Soldier_Light_EP1","CZ_Soldier_Light_DES_EP1","SBE_CZ_Soldier_Light_WLD_EP1","SBE_CZ_Soldier_Light_DES_EP1"])) then {
        _model = ["Storm_Trooper3_DZC","CDF_Soldier_Light","Soldier3_SL_DZC","Soldier2_SL_DZC","Soldier1_SL_DZC","US_Soldier_Light_EP1","CZ_Soldier_Light_DES_EP1","SBE_CZ_Soldier_Light_WLD_EP1","SBE_CZ_Soldier_Light_DES_EP1"] select floor random 9;
    };
//========== Read above ==== Don't copy this=== learn more about this in a diff thread =========
} else {
    _model =        _primary select 3;
    _hiveVer =        _primary select 4;
    if (isNil "_model") then {
        _model = "Survivor2_DZ";
    } else {
        if (_model == "") then {
            _model = "Survivor2_DZ";
        };
    };
 
    //Record initial inventory
    _config = (configFile >> "CfgSurvival" >> "Inventory" >> "Default");
    _mags = getArray (_config >> "magazines");
    _wpns = getArray (_config >> "weapons");
    _bcpk = getText (_config >> "backpack");
    _randomSpot = true;
   
    //Wait for HIVE to be free
    _key = format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
    _key call server_hiveWrite;
   
};
diag_log ("LOGIN LOADED: " + str(_playerObj) + " Type: " + (typeOf _playerObj));
 
_isHiveOk = false;    //EDITED
if (_hiveVer >= dayz_hiveVersionNo) then {
    _isHiveOk = true;
};
 
diag_log("Check");
diag_log("Inventory Count: " + str(count _inventory));
if (count _inventory == 1) then {
    diag_log("Inventory Select 0: " + str((_inventory select 0)));
    if ( (_inventory select 0) == "New Player" ) then {
        _chance = round(random 100);
        diag_log ("Random chance " + str(_chance));
 
        switch (true) do {
            case (_chance <= 10):
            {
                // Huntsman 5%
                _inventory = [["ItemCompass","ItemKnife","ItemFlashlight"], ["ItemPainkiller","ItemBandage"]];
                _backpack = ["CZ_VestPouch_EP1",[[],[]],[["FoodSteakCooked","ItemSodaCoke"],[1,1]]];
            };
            case (_chance <= 20):
            {
                // Police Officer 5%
                _inventory = [["M9","ItemFlashlightRed"], ["15Rnd_9x19_M9","15Rnd_9x19_M9","15Rnd_9x19_M9","ItemPainkiller","ItemBandage"]];
                _backpack = ["",[[],[]],[[],[]]];
            };
           
            case (_chance <= 30):
            {
                // Miltary 5%
                _inventory = [["MP5A5","ItemFlashlightRed","ItemGPS"], ["30Rnd_9x19_MP5","30Rnd_9x19_MP5","30Rnd_9x19_MP5","ItemPainkiller","ItemBandage"]];
                _backpack = ["DZ_Assault_Pack_EP1",[[],[]],[["FoodCanFrankBeans","ItemSodaCoke"],[1,1]]];
            };
           
            case (_chance <= 40):
            {
                // Camper Loadout 10%
                _inventory = [["ItemMatchbox","ItemCompass","ItemMap","ItemWatch","ItemFlashlight"], ["ItemTent","ItemPainkiller","ItemBandage"]];
                _backpack = ["DZ_CivilBackpack_EP1",[[],[]],[["FoodCanFrankBeans","ItemSodaCoke"],[1,1]]];
            };
 
            case (_chance <= 50):
            {
                // Woodsman 10%
                _inventory = [["MeleeHatchet"], ["ItemBandage","ItemCompass","ItemPainkiller","ItemBandage","ItemFlashlight"]];
                _backpack = ["DZ_Patrol_Pack_EP1",[[],[]],[["ItemHeatPack","ItemSodaCoke"],[1,1]]];
            };
 
 
            default
            {
                _inventory = [["ItemFlashlight","ItemMap"], ["ItemBandage","ItemPainkiller","ItemBandage"]];
                _backpack = ["DZ_CivilBackpack_EP1",[[],[]],[["FoodCanFrankBeans","ItemSodaCoke"],[1,1]]];
            };
        };
    };
};
 
//diag_log ("SERVER RESULT: " + str("X") + " " + str(dayz_hiveVersionNo));
 
//Server publishes variable to clients and WAITS
//_playerObj setVariable ["publish",[_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer],true];
 
dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer];
(owner _playerObj) publicVariableClient "dayzPlayerLogin";
 
Hey I am seeing mention in this code about models but I am unsure how to use it.

I would like to make each one spawn with a different predetermined skin. Would this be possible with the current setup or no? If so please explain.
 
Hey I am seeing mention in this code about models but I am unsure how to use it.

I would like to make each one spawn with a different predetermined skin. Would this be possible with the current setup or no? If so please explain.

I would also like each loadout to have the person spawn in with that skin, but I don't know how to do that bit.
 
well i do this via a little c# sql program i made , it just goes randomly through an array of loadouts and updates one to the instance table inventory every few minutes , this was before i started playing with lua but it works a treat :)
 
I would also like each loadout to have the person spawn in with that skin, but I don't know how to do that bit.
Perhaps In my newbishness I run the belief we could treat the code like the database and do something like this

{
// Huntsman 5%
_inventory = [["ItemCompass","ItemKnife","ItemFlashlight"], ["ItemPainkiller","ItemBandage"]];
_backpack = ["CZ_VestPouch_EP1",[[],[]],[["FoodSteakCooked","ItemSodaCoke"],[1,1]]];

_model =

};

Or am I thinking incorrectly?
 
this crap dont work I keep getting errors, I have DayZ.ST server and have followed the setup fully and nothing works ......
 
Hate ta necro an old thread,but was curious if this is possible to get working with epoch?

Would love to get this implimented on there if possible :D
 
Last edited:
Back
Top