Humanity Based Loadouts

Draxanoth

Member
Has anyone seen a modification to the custom loadout code that will assign a loadout according to humanity levels? I'd like to solidify the choice between Bandits and Friendlies and I think this might work.
 
just kinda checking in did you ever get this figured out draxanoth?
I haven't had a good chunk of time to dedicate to it yet.

I don't want to hard code the loadouts in the sqf if I can avoid it too, so it's probably not going to be a super quick modification considering I'm attempting to do it. :D
 
I personally have no interest in this however i do agree. I would do it as database loadouts and find how it gives players custom UID loadouts and modify that code to be instead of custom UID be humanity. Of course everything is easier said than done! however, that's what i'd do.

If you need/want any help let me know and i'll do my best to help you with this when i get time in between my own personal coding projects :)
 
I personally have no interest in this however i do agree. I would do it as database loadouts and find how it gives players custom UID loadouts and modify that code to be instead of custom UID be humanity. Of course everything is easier said than done! however, that's what i'd do.

If you need/want any help let me know and i'll do my best to help you with this when i get time in between my own personal coding projects :)
Exactly. I would think that instead of simply reading the field that has a player's static loadout assignment I could modify it to evaluate their humanity, and then pick from a list of loadout codes. Then if you want to modify the loadout you just modify it in the DB instead of tinkering with the sqf again.

I also considered maybe changing someone's loadout on login is the wrong method, possibly having it change their loadout assignment on death instead. Then you could assign loadouts based on all sorts of stats, like if someone manages to murder 20 people without dying maybe they get a different loadout next time they respawn.
 
well if the code is (haven't look at it im just saying basically this is what you'd do) if(playerUID == _UIDforloadout) then { give player loadout (loadout id number).

you'd simply change it from that to if(_humanity >= -2500) then { give player loadout (bandit loadout)

and then another for hero and then keep the default there.
 
I think i know how to do this now thanks to the insight you gave me in the other thread. I haven't tested it yet though. imma pass out for a while cause ive been up WAY to long. i'll test it later tonight and if it works point you in the right direction (i know you want to figure it out so i wont just flat out tell you just hint you back on track :) )
 
I think i know how to do this now thanks to the insight you gave me in the other thread. I haven't tested it yet though. imma pass out for a while cause ive been up WAY to long. i'll test it later tonight and if it works point you in the right direction (i know you want to figure it out so i wont just flat out tell you just hint you back on track :) )
If I still can't figure it out I may want you to flat out tell me anyway. lol
 
ok so i've done a little work with it and it's still a dud. however i am making progress! i'm on the right track i'll keep working at it. basically in the database typing in a humanity value under unique id in custom_loadout_profile. and in the line you found about the server reading this i'm changing it from matching that number (that i've set to a humanity value) to the players UID (currently default) to matching it with the players humanity level.

like i said it doesn't work the way it should jsut yet but im making progress :)
 
ok so i've done a little work with it and it's still a dud. however i am making progress! i'm on the right track i'll keep working at it. basically in the database typing in a humanity value under unique id in custom_loadout_profile. and in the line you found about the server reading this i'm changing it from matching that number (that i've set to a humanity value) to the players UID (currently default) to matching it with the players humanity level.

like i said it doesn't work the way it should jsut yet but im making progress :)
That's exactly the same method I was thinking would work. I tried the same thing, the game loaded fine, but I still got the default loadout instead of the one I wanted.
 
check out this link here: http://opendayz.net/threads/random-premade-starting-gear.6698/

you should be able to edit the code (_humanity > 5000) then { for heros and bandits. If i where you I'd try that out.
I gave that method an attempt blur but humanity is stored on a different table and I'm not sure how to load it. If I could it looks like it would work. Not as elegant as the normal load-out procedure, but it would work if I can pull the humanity value in. That of course has been my entire issue, reading and writing data to the database.
 
Hey, I just wanted to share my solution to this. I have a server from Dayz.st and i was able to create humanity based loadouts.

First i created a table in my database named loadouts with three columns: id, inventory, and backpack. i used the same structure as those columns in the cust_loadout table. i populated the table with 2 rows id 100 and 101.

Then i got my dayz_servr.pbo unpacked into dayz_server folder

in dayz_server folder go into the compiles folder and open the file server_playerLogin.sqf

take the following code:
Code:
//HUMANITY LOADOUTS - ADDED BY RT 1/9/2014

    if (true) then {
        diag_log ("FETCHING HUMANITY...");
        _key = format["CHILD:999:select humanity from `profile` where `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 _data;
                _humanity = _result select 0;
            };
        };
    };
    diag_log ("Humanity:" + str(_humanity));
    _bandit = 100;    //table id for bandit loadout
    _hero = 101;    //table id for hero loadout
    if (_humanity >= 5000) then {
        diag_log ("FETCHING HERO LOADOUT...");
        _key = format["CHILD:999:select replace(`inventory`, '""', '\'') `inventory`, replace(`backpack`, '""', '\'') `backpack` from `loadouts` where `id` = ?:[%1]:",_hero];
        _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 _data;
                _inventory = call compile (_result select 0);
                _backpack = call compile (_result select 1);
            };
        };
    };

    if (_humanity <= -2500) then {
        diag_log ("FETCHING BANDIT LOADOUT...");
        _key = format["CHILD:999:select replace(`inventory`, '""', '\'') `inventory`, replace(`backpack`, '""', '\'') `backpack` from `loadouts` where `id` = ?:[%1]:",_bandit];
        _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 _data;
                _inventory = call compile (_result select 0);
                _backpack = call compile (_result select 1);
            };
        };
    };

//END HUMANITY LOADOUTS BY RT

and place it between:
Code:
    if (true) then {
        _key = format["CHILD:999:select replace(`inventory`, '""', '\'') `inventory`, replace(`backpack`, '""', '\'') `backpack` from `instance` where `id` = ?:[%1]:",dayZ_instance];
        _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 _data;
                _inventory = call compile (_result select 0);
                _backpack = call compile (_result select 1);
            };
        };
    };

//PLACE NEW CODE HERE

    if (true) 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);
            };
        };
    };

then at the very top of the file find line that looks like this:
Code:
private ["_botActive","_doLoop","_hiveVer","_isHiveOk","_playerID","_playerObj","_randomSpot","_primary","_key","_charID","_playerName","_items","_magazines","_weapons","_backpack","_humanity","_hero","_bandit","_worldspace","_direction","_newUnit","_isNew","_inventory","_survival","_state","_model","_config","_mags","_wpns","_bcpk","_medicalStats","_tent","_newPlayer"];

then add "_humanity","_hero","_bandit", after the first [ (or wherever, as long as its in the brackets. i put mine in the middle for some reason)

Then save the file, close it, and pack your dayz_server folder into dayz_server.pbo. Upload to your server. Now new players and respawns will recieve special loadouts if their humanity is above or below the limits (my code has >=5000 for hero loadout; <=-2500 for bandit loadout).

i think that is all i did...try it out and reply if it doesnt work and i will do my best to help out.
 
Last edited:
Back
Top