Jump to content
aeroson

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

Recommended Posts

Is anyone else having problems when used with the new arma3server.exe for Alpha Stable ?

The saving of the loadouts and selection process seems very unstable after the 0.58 update.

Of course, the dedicated arma3server.exe is very iffy at best so I'm not surprised at having

problems with the GET/SET features.

Everything works perfectly in MP when hosted and played on and by the same machine.

But not if the machine runs it with the new dedicated server.

Edited by tomturner

Share this post


Link to post
Share on other sites

Updated / Fixed (sorry, took me a while)

Was looking through Tonic's VAS, seems like he found a way to get currently loaded magazines. Improved it a bit and added into my scripts ^.^

This will make you respawn with same gear as well as same number of bullets in magazines you had when you died.

waitUntil { !isNull player }; // Wait for player to initialize

// Compile scripts
getLoadout = compile preprocessFileLineNumbers 'fnc_get_loadout.sqf';
setLoadout = compile preprocessFileLineNumbers 'fnc_set_loadout.sqf';

// Save loadout (including ammo count) every 2 seconds
[] spawn {
while{true} do {
	if(alive player) then {
		loadout = [player,["ammo"]] call getLoadout;
	};
sleep 2;  
};
};

// Load saved loadout (including ammo count) on respawn
player addEventHandler ["Respawn", {
	[player,loadout,["ammo"]] spawn setLoadout;
}
];

Regarding the IRLaser, there is an action for it but it doesn't work.

@tomturner No idea. set/get functions are (should be) executed locally, server shouldn't matter, but its Arma...

fnc_get_loadout.sqf v2.7

- Added: Option to save magazines ammo count

- Fixed: Gunlight is turned on again

fnc_set_loadout.sqf v3.7

- Added: Option to load magazines ammo count

Edited by aeroson

Share this post


Link to post
Share on other sites

HI, thx, i will try this new version on our server. As i see for the first test, it looks like working but i need to do some more test.

Share this post


Link to post
Share on other sites

I always use this script in my missions and I'm just wondering, since the script already runs constantly, would it be possible to squeeze in some code to set an actual respawn limit for the players instead of having to run it in a separate script?

Share this post


Link to post
Share on other sites

Hi,

great set of scripts but I have some questions.

I set a custom loadout that units starts with at mission start.

I set an ammobox with save and load actions and it works great. When you save a loadout, you respawn with it.

But how can I respawn with loadout that I set prior to mission start without saving the loadout at ammobox?

I used

player addEventHandler ["Respawn", {
       [player,loadout] spawn setLoadout;
   }
];

to have the loadout you save at ammobox after respawn.

If I use

loadout = [player] call getLoadout;

I respawn with default unit loadout not the one I set. Without this code I respawn in underwear.

Is there any solution?

Share this post


Link to post
Share on other sites

@Banky: Everything is possible, but it would then turn into clumsy limited respawns save/load loadout scripts. Which would defeat the purpose of being universal. You can edit it yourself and put everything into one script.

If you want simple limited respawns replace:

player addEventHandler ["Respawn", {
       [player,loadout] spawn setLoadout;
   }
];

with

outOfRespawns = {
systemChat "You have no respawns left";
hint "You have no respawns left";
hideObject player;
player enableSimulation false;
player setPos [0,0,9999];
player allowDamage false; 
while{ alive player && numberOfRespawnsLeft<=0 } do {
	[] exec 'camera.sqs';
	sleep 1;
};
};
if(isNil{playersOutOfRespawns}) then {
playersOutOfRespawns = [];
publicVariable "playersOutOfRespawns";
};
if((getPlayerUID player) in playersOutOfRespawns) then {
numberOfRespawnsLeft = 0;
[] spawn outOfRespawns;
} else {
numberOfRespawnsLeft = 5; // set your respawns count here
};
player addEventHandler ["Respawn", {
   	numberOfRespawnsLeft  = numberOfRespawnsLeft - 1;
   	if(numberOfRespawnsLeft>0) then {
   		systemChat format["You have %1 respawn(s) left",numberOfRespawnsLeft];
   		hint format["You have %1 respawn(s) left",numberOfRespawnsLeft];
       	[player,loadout] spawn setLoadout;
       } else {
       	if((getPlayerUID player) in playersOutOfRespawns) then {
        	playersOutOfRespawns set[count playersOutOfRespawns, getPlayerUID player];
			publicVariable "playersOutOfRespawns";
		};
		[] spawn outOfRespawns;        	
       };
   }
];  

Once you run out of respawns you go to camera mode, you can't cheat it by respawning or rejoining.

@Janez: Instead of

loadout = [player] call getLoadout;

use this

if(!isDedicated) then {
[] spawn {
	waitUntil {!isNull player};
	sleep 5;
	loadout = [player] call getLoadout;
};
};

Edited by aeroson

Share this post


Link to post
Share on other sites

Thanks a ton my friend! I figured there would be a way to put the respawn limit in there somewhere, but i wasn't brave enough to go messing around with it. Probably doesn't make a huge difference, i just like to keep the number of different scripts running at once as low as possible. Thanks again.

Share this post


Link to post
Share on other sites
@Janez: Instead of

loadout = [player] call getLoadout;

use this

if(!isDedicated) then {
[] spawn {
	waitUntil {!isNull player};
	sleep 5;
	loadout = [player] call getLoadout;
};
};

Thanks, works great.

Share this post


Link to post
Share on other sites

fnc_set_loadout.sqf is having an issue with the latest dev build... line 133

:)

-Raps

edit: actually, you may want to load up the example mission, as it is showing errors too.. this all started after the last dev build this morning... we played last night without issue... :)

Also, wanted to say... I absolutely love this set/get system you have... awesome >> trying to get somewhere... :D

-Raps

Here is a more detailed view... :)

fnc_set_loadout.sqf, line 142
Error in expression <         
{ 
if(_x!="") then { 
_target removeItemFromPrimaryWeapon _x 
}; 
} fo>
 Error position: <removeItemFromPrimaryWeapon _x 
}; 
} fo>
 Error Missing ;

Edited by VRCRaptor

Share this post


Link to post
Share on other sites
fnc_set_loadout.sqf is having an issue with the latest dev build... line 133

:)

-Raps

edit: actually, you may want to load up the example mission, as it is showing errors too.. this all started after the last dev build this morning... we played last night without issue... :)

Also, wanted to say... I absolutely love this set/get system you have... awesome >> trying to get somewhere... :D

-Raps

Here is a more detailed view... :)

fnc_set_loadout.sqf, line 142
Error in expression <         
{ 
if(_x!="") then { 
_target removeItemFromPrimaryWeapon _x 
}; 
} fo>
 Error position: <removeItemFromPrimaryWeapon _x 
}; 
} fo>
 Error Missing ;

I am getting the above error with also a VAS error too

Error in expression <s player) select 2 != "") then
{
player removeItemFromPrimaryWeapon ((primaryWea>
 Error position: <removeItemFromPrimaryWeapon ((primaryWea>
 Error Missing ;
File C:\Users\NDK0\Documents\Arma 3 Alpha - Other Profiles\Kadin\mpmissions\HUNT_Begun_PH.Stratis\VAS\functions\fn_handleItem.sqf, line 254
Error in expression <s player) select 2 != "") then
{
player removeItemFromPrimaryWeapon ((primaryWea>
 Error position: <removeItemFromPrimaryWeapon ((primaryWea>
 Error Missing ;
File C:\Users\NDK0\Documents\Arma 3 Alpha - Other Profiles\Kadin\mpmissions\HUNT_Begun_PH.Stratis\VAS\functions\fn_handleItem.sqf, line 254

Share this post


Link to post
Share on other sites

rgr that. Thanks

Excellent...no more errors in either scripts. Much obliged, again :)

Edited by KadinX

Share this post


Link to post
Share on other sites
removeItemFromPrimaryWeapon was renamed to: removePrimaryWeaponItem so you need to replace all of them !

awesomeness... :)

Share this post


Link to post
Share on other sites

hi,

With this new version sometime i respawn without no ammo in my RPG, sometime i loose my nades... any idea ?

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

×