Skin depending of the username (or how to add custom skins for factions ? )

sald41

New Member
Hi guys,

Some friends and me are trying to create a roleplay dayz server. We want to add custom skins, especially for military groups/factions. With rMod, we manage to add custom skins by editing the database ("CharacterData" >> "Model").
Now, we want to do this automatically for new players and for players who change faction. We want to use the username of the player to do this.

I think I have to edit the file "dayz_server" >> "compile" >> "server_playerLogin.sqf" and add something like this :
Code:
if (_playerName -match "^[MyFactionTag]*") {
    _model = "MyModel";
}

Unfortunately, this doesn't work at all (with real tag and real classname for the model). I'm kick from the game with the message "Something went wrong, please logoff and try again blablabla". I also try if(_playerName == "[MyTag] MyName") but it doesn't work too.

Do you know how to do this ?
I usually use Java and PHP so I'm a bit confused with SQF programming...
If you have the answer, I will edit this post so everyone will be able to find the solution here.
 
the skin gets assigned in server_playerlogin, you would have to assign it there, you should not use the name as a varible because then it opens your server to all sorts of issus, use the uuid of the user. If you have a bliss server then use the custom inventory function to assign the skin on login:

Code:
// Check custom inventory for new characters
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]:",_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);
        };
    };
};
 
Sorry for offtopic,but could you give me a link to the topic on the installation of custom skins?And then I have something I can't find,thank you.
 
Thx Xyberviri.

Code:
if(_playerID == "106083910") then { // Vincenzo
    _model = "CDF_Commander";
};

With playerID that's work perfectly. (At each life you need to disconect/reconect)

But there is no way to make that work with username ?

We want to make something like ; My name is Vincenzo im in basic survivor skin, I change my tag IG as [CDF]Vincenzo then im now in CDF soldier skin.

My apologies for my horrible english. :(

@Irbis5631 : http://opendayz.net/index.php?threads/custom-skins-as-drops.7296/
 
Okay so it's working. As Xyberviri suggested, I use the player uuid to add the skin.
This is what I add to "dayz_server" >> "compile" >> "server_playerLogin.sqf :
Code:
if(_playerID == "0000000000") then { // put your uuid instead of the 0
    _model = "Ins_Commander"; 
};

Now I have to modify this file everytime someone wants to change skin, then restart the server. This solution is not the better but I don't find anything else.
Maybe I will make a webpage that can edit this file at every server restart and add automaticaly what players want.
I will also made custom model class so players will have the "normal" DayZ inventory.
 
Can you tell us where you add the code......maybe show the code before you added it and after you added it

and also if you die do you have to disconnect and then reconnect to get the skin?

PLEASE
 
Can you tell us where you add the code......maybe show the code before you added it and after you added it

and also if you die do you have to disconnect and then reconnect to get the skin?

PLEASE

This is what I add to "dayz_server" >> "compile" >> "server_playerLogin.sqf :
Code:
if(_playerID == "0000000000") then { // put your uuid instead of the 0
    _model = "Ins_Commander";
};

With playerID that's work perfectly. (At each life you need to disconect/reconect)
 
I got it to work and STAY without have to disconnect and reconnect, everytime they spawn they'll have custom skin but i lost custom loadout, need to find a way to add it to where the custom loadout stays, if i add your line at the top it doesn't work. This is how i have it:

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 (_playerID == "000000000") then {
_model = "FR_Commander";
};

note: "000000000" are UUID's
 
For those that are still trying this, i have gotten this to work WITH CUSTOM-LOADOUTS,
Here is where and how i put the code:


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);
};
};
};

if (_playerID == "000000000") then {
_model = "USMC_Soldier_Officer";
};

if (_playerID == "000000000") then {
_model = "FR_Commander";
};


Sunstitute your UUID's with the zeros, putting it in this way got my custom models and custom loadouts to work.
 
This'll be useful for when the celle patch comes out (rather updated on DAyz.ST is what i mean).... Give the clans their custom skins
 
Has anyone been able to get this to work with just using player names with [TAG]. The process above is an admins nightmare with having to keep adding ids in.
 
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);
};
};
};

if (_playerID == "000000000") then {
_model = "USMC_Soldier_Officer";
};

if (_playerID == "000000000") then {
_model = "FR_Commander";
};

I put that in and selected the bandit skin but it does not load the skin. i am invisable... what am i missing?
 
Some of the skins i have tried have done the same thing, i assumed it was because maybe it was a banned skin (in the ban list or whatever) just tried another one.

Yes it can be a nightmare but i tell all my guys it's a one time thing, if you don't like the one you chose to bad.....lol

ALSO make sure you have no error in the syntax (, " =) having a mistake will cause it to do funky shit as well
 
Code:
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;

Do we have to do anything with this part?
 
no you don't have to do anything with that part

I just included that stuff to give everyone an idea where i added my part of the code.

I just added this part:

if (_playerID == "000000000") then {
_model = "FR_Commander";
};
 
Code:
} else {
    _model =        _primary select 3;
    _hiveVer =        _primary select 4;
    if (isNil "_model") then {
        _model = "Survivor2_DZ";
    } else {
        if (_model == "") then {
            _model = "Survivor2_DZ";
        };
    };

Sorry for my noobishness - But this right below it has no impact?
And if I did alter ths to a different skin - would that result in everyone else spawning with that skin?

Edit: And I was looking into a loadout lottery (that I used to have working a while back)

Would it be possible to have the lottery chances incorporate a skin per loadout w/o it being a skin that i'd just put in their inventory?

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);
            };
        };
    };
 
if (_playerID == "0000") then {
_model = "HazmatVest_Black_DZC";  // A players name
};
if (_playerID == "400000") then {
_model = "HazmatVest_Black_DZC"; // A players name
};
if (_playerID == "1000002") then {
_model = "Clan_UN_Helmet_DZC";  // A players name
};
if (_playerID == "00000966") then {
_model = "Clan_UN_Helmet_DZC"; // A players name
};
 
if (_playerID == "000") then {
_model = "Clan_UN_Helmet_DZC"; // A players name
};
 
if (_playerID == "0000") then {
_model = "Clan_UN_Helmet_DZC"; // A players name
};
 
if (_playerID == "0000") then {
_model = "Clan_UN_Helmet_DZC";  // A players name
};
 
if (_playerID == "000") then {
_model = "Clan_UN_Helmet_DZC"; // A players name
};
 
if (_playerID == "000") then {
_model = "PrivateSec1_DZC"; // A players name
};
 
if (_playerID == "0000") then {
_model = "PrivateSec1_DZC";  // A players name
};
 
if (_playerID == "00000000000000") then {
_model = "PrivateSec1_DZC"; // A players name
};
 
//    if (!(_model in ["SurvivorW2_DZ","Survivor2_DZ","Sniper1_DZ","Soldier1_DZ","Camo1_DZ","BanditW1_DZ","Bandit1_DZ","SurvivorW2_DZ"])) then {
//        _model = "Survivor2_DZ";
//    };
} 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";
 
The skin has to be listed in there otherwise it won't show at all and i haven't thought about the lottery type thing.....let me know if it works though, might be interested in something like that.
 
// if (!(_model in ["SurvivorW2_DZ","Survivor2_DZ","Sniper1_DZ","Soldier1_DZ","Camo1_DZ","BanditW1_DZ","Bandit1_DZ","SurvivorW2_DZ"])) then {
// _model = "Survivor2_DZ";
// };

This part should not be commented out....remove the // and they will work
 
i also implemented this on my server:

_model = ["Ins_Lopotev","Ins_Bardak","Ins_Soldier_AR","Ins_Soldier_Pilot","Ins_Soldier_1","Ins_Soldier_Crew","Ins_Soldier_Sapper"] select floor random 7;

and it will assign a random skin to anyone that joins my server
 
Back
Top