gruppe-adler / grad-persistence

Save/Load mission progress in server's profileNamespace
26 stars 13 forks source link

Ability to manually load one player's loadout onto another? #42

Closed RaidenKoizuma closed 3 years ago

RaidenKoizuma commented 3 years ago

I've had a strange issue of certain players not having their loadouts load after they've edited their profile (mainly name). Probably a stretch, but would there be a way or possibly a new feature to apply the loadout of one player to another? Everything saves just fine, vehicles, containers, and most players but there's always one or two players that seemingly lose their loadouts each op. Here is my config, if there's something obviously wrong with it.

class CfgGradPersistence {
    missionTag = "game";
    loadOnMissionStart = 1;
    missionWaitCondition = "true";
    playerWaitCondition = "true";

    saveUnits = 3;
    saveVehicles = 3;
    saveContainers = 3;
    saveStatics = 0;
    saveMarkers = 0;
    saveTasks = 0;
    saveTriggers = 0;
    saveTimeAndDate = 0;

    savePlayerInventory = 1;
    savePlayerDamage = 0;
    savePlayerPosition = 0;
    savePlayerMoney = 1;

    saveTeamAccounts = 1;

    blacklist[] = {
        "B_Truck_01_mover_F",
        "MapBoard_seismic_F"
    };

    class customVariables {
        class var1 {
            varName = "HALs_money_funds";
            varNamespace = "player";
            public = 1;
        };
        class var2 {
            varName = "grad_moneymenu_myBankBalance";
            varNamespace = "unit";
            public = 1;
        };
    };
};
McDiod commented 3 years ago

If both players are already in the game, you can just do this:

// Copies loadout from player_1 and applies it to player_2
// execute on server

player_2 setUnitLoadout (getUnitLoadout player_1);

If you want to do this during mission intialization (so before player_1 has had his loadout applied (or maybe even if he is not connected to the server)), you can do this:

// Applies grad-persistence saved loadout of player_1 to player_2
// execute on server

// EXAMPLE ONLY, ENTER THE ACTUAL UID HERE
private _player1UID = "862321357687233";

private _playersTag = ([] call grad_persistence_fnc_getMissionTag) + "_players";
private _playersDataHash = [_playersTag,true,false] call grad_persistence_fnc_getSaveData;
private _unitDataHash = [_playersDataHash,_player1UID] call CBA_fnc_hashGet;
private _unitLoadout = [_unitDataHash,"inventory"] call CBA_fnc_hashGet;
if !(_unitLoadout isEqualType false) then {
    player_2 setUnitLoadout [_unitLoadout,false];
};

Here's how to get a player's UID.