DUWS-R-Team / DUWS-R

ArmA 3 Dynamic Universal War System - Rebirth
42 stars 18 forks source link

Save/Load gear after respawn #86

Open rlex opened 9 years ago

rlex commented 9 years ago

BIS arsenal doesn't support load on respawn. This can be very frustrating.

Here is some code i digged and modified a bit to support save/load...

save gear:

waitUntil {!isNull player};

vUniform = uniform player;
vVest = vest player;
vHeadgear = headgear player;
vGoggles = goggles player;
vItems = items player;
vAssignedItems = assignedItems player;
vBackpack = backpack player;
vBackpackItems = backpackItems player;

vPriAmmo = primaryWeaponMagazine player;
vSecAmmo = secondaryWeaponMagazine player;
vHandAmmo = handgunMagazine player;

vPriItems = primaryWeaponItems player;
vSecItems = secondaryWeaponItems player;
vHandItems = handgunItems player;

vMagazines = magazines player;
vWeapons = weapons player;

vGearSaved = true;
systemChat "Gear saved.";

load gear:

waitUntil {!isNull player};

removeAllPrimaryWeaponItems player;
removeAllHandgunItems player;
removeAllWeapons player;
removeGoggles player;
removeHeadgear player;
removeAllAssignedItems player;
removeAllItems player;
{ player removeMagazine _x } forEach magazines player;
clearAllItemsFromBackpack player;
removeBackpack player;
removeUniform player;
removeVest player;

player ForceAddUniform vUniform;
player addVest vVest;
player addBackpack vBackpack;
player addHeadgear vHeadgear;
player addGoggles vGoggles;
{ player addItem _x } forEach vItems;
{ player linkItem _x } forEach vAssignedItems;
{ player addMagazine _x } forEach vPriAmmo;
{ player addMagazine _x } forEach vSecAmmo;
{ player addMagazine _x } forEach vHandAmmo;
{ player addWeapon _x } forEach vWeapons;
{ player addMagazine _x } forEach vMagazines;
{ player addPrimaryWeaponItem _x } forEach vPriItems;
{ player addSecondaryWeaponItem _x } forEach vSecItems;
{ player addHandgunItem _x } forEach vHandItems;

Notice "forceadduniform" - this is for mods and other factions gear. Also

vGearSaved = false;

should be placed in init.sqf to prevent warning.

Can't recall where i got that scripts, thought...