Jump to content
aeroson

GET/SET Loadout (saves and loads pretty much everything)

Recommended Posts

Just noticed, getloadout.sqf does not check the unit's setface value and therefore does not set it on respawn.

Share this post


Link to post
Share on other sites

I have spent about 3 hours testing various mods trying to find out which one is making my flashlight and laser flicker. Turns out, it is this script! Every time it reads the current loadout there is a brief flicker of the light/laser. (in MP it turns it off outright) Is there a way to work around this?

Share this post


Link to post
Share on other sites

@Beerkan: That is true, if you want to add face saving/loading functionality you may encapsulate set/get loadout functions like this. Beware it is untested.

setLoadoutAndFace = {
_target = _this select 0;
_data = _this select 1;
_flags = _this select 2;

_face = _data select 0;
_loadout = _data select 1;

_target setFace _face;
[_target, _loadout, _flags] call setLoadout;
};


getLoadoutAndFace = {
_target = _this select 0;
_flags = _this select 1;
[
	face _target,
	[_target, _flags] call getLoadout
];
};

@Baddazs: That is what the "repetitive" flag is for.

"repetitive" intended for repetitive use, will not use selectWeapon, means no visible effect on solder, but will not save magazines of assigned items such as laser designator batteries

loadout = [player,["ammo","repetitive"]] call getLoadout;

Share this post


Link to post
Share on other sites

I figured that, I was just wondering if there was a work around. What I've done is just changed the frequency that the script checks the loadout. from 2 seconds to 120 seconds. Keeps the fantastic effect of your script and eliminates the constant flickering! Thanks for this and keep up the great work

Share this post


Link to post
Share on other sites

// Save loadout whenever hit (more efficient than above method)
player addEventHandler ["Hit", {
	respawnLoadout = [player] call getLoadout;
}
];

I replaced what you said, but it won't work for me.

Share this post


Link to post
Share on other sites

if i use getLoadout with "ammo" option, setLoadout will not work. I got a ScriptError on addBackback and the Script stop working.

Share this post


Link to post
Share on other sites

is this script still getting supported?

we are encountering massive rpt spam from fn_set_loadout.

_placeholde>
20:34:19   Error Undefined variable in expression: _loadbeforeadd
20:34:19 File mpmissions\__cur_mp.anim_helvantis_v2\functions\common\fn_set_loadout.sqf, line 312
20:34:19 Error in expression <em "ItemWatch" ;
if(loadVest _target == _loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error position: <_loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error Undefined variable in expression: _loadbeforeadd
20:34:19 File mpmissions\__cur_mp.anim_helvantis_v2\functions\common\fn_set_loadout.sqf, line 312
20:34:19 Error in expression <em "ItemWatch" ;
if(loadVest _target == _loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error position: <_loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error Undefined variable in expression: _loadbeforeadd
20:34:19 File mpmissions\__cur_mp.anim_helvantis_v2\functions\common\fn_set_loadout.sqf, line 312
20:34:19 Error in expression <em "ItemWatch" ;
if(loadVest _target == _loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error position: <_loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error Undefined variable in expression: _loadbeforeadd
20:34:19 File mpmissions\__cur_mp.anim_helvantis_v2\functions\common\fn_set_loadout.sqf, line 312
20:34:19 Error in expression <em "ItemWatch" ;
if(loadVest _target == _loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error position: <_loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error Undefined variable in expression: _loadbeforeadd
20:34:19 File mpmissions\__cur_mp.anim_helvantis_v2\functions\common\fn_set_loadout.sqf, line 312
20:34:19 Error in expression <em "ItemWatch" ;
if(loadVest _target == _loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error position: <_loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error Undefined variable in expression: _loadbeforeadd
20:34:19 File mpmissions\__cur_mp.anim_helvantis_v2\functions\common\fn_set_loadout.sqf, line 312
20:34:19 Error in expression <em "ItemWatch" ;
if(loadVest _target == _loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error position: <_loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error Undefined variable in expression: _loadbeforeadd
20:34:19 File mpmissions\__cur_mp.anim_helvantis_v2\functions\common\fn_set_loadout.sqf, line 312
20:34:19 Error in expression <em "ItemWatch" ;
if(loadVest _target == _loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error position: <_loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error Undefined variable in expression: _loadbeforeadd
20:34:19 File mpmissions\__cur_mp.anim_helvantis_v2\functions\common\fn_set_loadout.sqf, line 312
20:34:19 Error in expression <em "ItemWatch" ;
if(loadVest _target == _loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error position: <_loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error Undefined variable in expression: _loadbeforeadd
20:34:19 File mpmissions\__cur_mp.anim_helvantis_v2\functions\common\fn_set_loadout.sqf, line 312
20:34:19 Error in expression <em "ItemWatch" ;
if(loadVest _target == _loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error position: <_loadBeforeAdd) exitWith {};
_placeholde>
20:34:19   Error Undefined variable in expression: _loadbeforeadd
20:34:19 File mpmissions\__cur_mp.anim_helvantis_v2\functions\common\fn_set_loadout.sqf, line 312
20:34:19 Error in expression <em "ItemWatch" ;
if(loadVest _target == _loadBeforeAdd) exitWith {};

after a few hours, this amounted to a 1gb RPT file. it will keep spamming for as long as the server is on.

Share this post


Link to post
Share on other sites

Does this work with User ID possibly? Looks awesome, need such a script for MSO mission :D

Share this post


Link to post
Share on other sites

This is great. I've had a lot of success using this loadout saver but I'm wondering if there's a way to integrate it into the Respawn menu at all in MP missions?

I'm looking to use the RespawnInventory section: https://community.bistudio.com/wiki/Arma_3_Respawn#Respawn_Templates

I'd like the saved loadouts to be available there so a player can respawn with a loadout that they have already saved. This would be good for respawning on "INSTANT" in the battle, you could pick your gear and then spawn there.

I've messed around a bit but had no luck. Has anyone tried to implement this at all?

Share this post


Link to post
Share on other sites

Great work aeroson,

however i need some help please to get it working in my campaign. Let's start with the player named "player", what do i need to do to get his loadout transferred from one to the next mission ? All i understand is that the load/set scripts need to be in and that i need to start those via the mission's init.sqf. But doi need to edit/adjust their code ?

thanks !

Share this post


Link to post
Share on other sites

Hi aeroson,

Thanks for all the hard work in the past, I'm sad to see this script no longer being supported, but I get it. It's a big time investment to keep these scripts up to date with the vanilla game. Hope someone else will pick this script up and keep it alive because it seriously rocks!

Edited by JamesClarke

Share this post


Link to post
Share on other sites

Too bad it's not supported anymore, seemed like a really great script!

I tried to see if it would work anyways, but unfortuantely it looks like it's running into a problem with loading the players loadout.

Does anyone know of any comparable scripts or mods that we could use to load inventories? Or have an updated version of this that works with the current arma version?

Share this post


Link to post
Share on other sites

I have very minimal knowlege of how to implement these. Could anyone help by explaining where/how I implement the get/set loadouts? I am trying to use the end game revive while saving the gear I had equipped when I died.

Share this post


Link to post
Share on other sites

I have very minimal knowlege of how to implement these. Could anyone help by explaining where/how I implement the get/set loadouts? I am trying to use the end game revive while saving the gear I had equipped when I died.

 

Use getUnitLoadout setUnitLoadout commands

  • Like 1

Share this post


Link to post
Share on other sites

Use getUnitLoadout setUnitLoadout commands

I should have clarified...in what capacity do I use these? Do these go in the description.ext file or something else?

Share this post


Link to post
Share on other sites

onPlayerKilled.sqf

player setVariable ["Saved_Loadout",getUnitLoadout player];

onPlayerRespawn.sqf

player setUnitLoadout (player getVariable ["Saved_Loadout",[]]);

Create both files and put them into your mission folder.

  • Like 1

Share this post


Link to post
Share on other sites

Here is a template with a custom loadout using getUnitLoadout and setUnitLoadout

 

Added a custom face for East player

 

 

In initPlayerLocal.sqf, you can alternate between loadout modes:

 

Respawn with a current loadout or reset with the same loadout than at start mission

Start with loadout role unit or custom loadout

// if true player respawns with all stuffs he gets on him else player respawns with the loadout he get at mission start
loadoutAtStart = false;
// if true, give a custom loadout to the player else player will get all stuffs according to the role of the unit
customloadout = true;

regards

 

 

Download:

 

(7z)https://drive.google.com/open?id=0B0sUgrRIipRhZzRBQmRiOTIydlU

 

(new version  07/13)

  • Like 1

Share this post


Link to post
Share on other sites

Use getUnitLoadout setUnitLoadout commands

 

Is that "This command is not final and might be changed in a near future." remark on the wiki still valid? It kept me from using it so far.

Share this post


Link to post
Share on other sites

Is that "This command is not final and might be changed in a near future." remark on the wiki still valid? It kept me from using it so far.

 

Have been using it since it came out and haven't had any problems.

Share this post


Link to post
Share on other sites

Is that "This command is not final and might be changed in a near future." remark on the wiki still valid? It kept me from using it so far.

Yes, this is still valid however, the syntax should be final or at least, the one which is mentioned will remain valid.

Share this post


Link to post
Share on other sites

Alright, thanks for clearing that up, guys!

Share this post


Link to post
Share on other sites

how can I do this to cargo? I want to save/load all stuff in vehicle / box, How can easy count  ammo in each magazine and give it to cargo?

Share this post


Link to post
Share on other sites

onPlayerKilled.sqf

player setVariable ["Saved_Loadout",getUnitLoadout player];

onPlayerRespawn.sqf

player setUnitLoadout (player getVariable ["Saved_Loadout",[]]);

Create both files and put them into your mission folder.

 

Pretending this still works despite R3vo have removed it from his 3den enhanced mod (not sure if he used exactly this way but...)  if the player has spent magazines before respawning, he won't get his "starting" gear since it only saves upon death what he has. A possible workaround to this using the modern arsenal method, since there's no arsenalOpenEventHandler by default, along with the addAction (openArsenal) a 2 minute sleep could be put following the save snippet, sort of...

(Pseudocodish)

ammoBox addAction (virtualArsenal; sleep 120; execVM saveLoadout.sqf);

This way it would give time for the player to equip himself or load a loadout.

This is a very rough concept and I haven't actually get my hands dirty to try it out. I don't know what will happen if the player still has arsenal open when he attempts to save, or what if he closes and reopens the arsenal, will it save twice or will he be able to reopen at all given the sleep is attached to the addAction?

Or could one perhaps handcraft an eventHandler for the arsenal closing?

Perhaps a simplier idea is to put a trigger around the arsenal boxes and upon player exits the trigger area it saves the loadout.

Just brainstorming some ideas since I'm interested in using something like this.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×