Jump to content
Sign in to follow this  
colonel_paz

Question about SAVE GEAR script. Help needed!

Recommended Posts

Hello guys!

I'm making a mission for multiplayer, and i'm using this script for a save gear or weapons that I found around these forums:

#start
@ (! alive player)
_weapons = weapons player
_magazines = magazines player

@ (alive player)
removeallweapons player

{player addMagazine _x} foreach _magazines
{player addWeapon _x} foreach _weapons
goto "start";

My question is: Can I edit that somehow, so the things a player has inside a ruck he had when he died, respawn as well inside the ruck? or is there another script I can use?

Any help would be appreciated

Thanks!

Share this post


Link to post
Share on other sites

some bits from evolution script that may help

in init.sqf

BIS_EVO_pallammo = ["PipeBomb","Laserbatteries","HandGrenade_East","HandGrenade_East","30Rnd_545x39_AK","30Rnd_545x39_AK","30Rnd_545x39_AK","30Rnd_545x39_AK","8Rnd_9x18_Makarov","8Rnd_9x18_Makarov","8Rnd_9x18_Makarov","8Rnd_9x18_Makarov"];// The players default load out
BIS_EVO_pweapons = ["AKS_74_U","Makarov","Laserdesignator","NVGoggles"]; // The players default load out

in mission.sqm (in sensors)

		class Item34
	{
		position[]={4535.8418,0.2942608,1796.9813};
		repeating=1;
		interruptable=1;
		age="UNKNOWN";
		text="LoadoutRecorder";
		expCond="animationState player == ""amovpercmstpslowwrfldnon_gear"" or animationState player == ""amovpercmstpsraswrfldnon_gear""";
		expActiv="hint""Weapons Saved"";";
		expDesactiv="BIS_EVO_pallammo = magazines player;BIS_EVO_pweapons = weapons player;";
		class Effects
		{
		};
	};

and

	class Item36
	{
		position[]={4350.207,0.18258563,1817.4297};
		repeating=1;
		interruptable=1;
		age="UNKNOWN";
		text="respawn player";
		expCond="alive player and local player";
		expActiv="spawn = player execVM ""data\scripts\spawn.sqf"";";
		class Effects
		{
		};
	};

in spawn.sqf

if (not (local player)) exitwith {};
_player = player;
removeAllWeapons _player;
{player addmagazine _x} forEach BIS_EVO_pallammo;
{player addweapon _x} forEach BIS_EVO_pweapons;
player selectweapon (primaryWeapon player);
player addweapon "ItemCompass";	
player addweapon "ItemGPS";
player addweapon "ItemMap";
player addweapon "ItemRadio";
player addweapon "ItemWatch";

Share this post


Link to post
Share on other sites

He was asking about the ruck though, which honestly I didn't manage to solve very well either because of how weird the ACE ruck system implementation is.

Share this post


Link to post
Share on other sites

ah i misread it - i thought he meant all things other than primary weapon and secondary weapon etc

Share this post


Link to post
Share on other sites

Additionally, if you want to save stuff like GPS, gas mask etc you should also have _items=items player and then removeAllItems player; {player addWeapon _x} forEach _items; when he respawns.

Of course you probably want to save the loadout into a global variable at the crate rather than save it on every death, that way you will start with the full loadout that you saved at the start rather than whatever you were holding when you died.

Share this post


Link to post
Share on other sites

an easy soultion would be to implement Norrins revive script because it gives you the option to respawn with the equipment that you died with, and i also belive that it save the stuff in the ruck as well. i could be wrong though.

Share this post


Link to post
Share on other sites

From my mission - Nightmares ....

take snapshot script - callable via action menu.

//#define DEBUG_MODE_FULL
#include "\x\cba\addons\main\script_macros_common.hpp"

private["_unit", "_weapons", "_magazines", "_ruck_weapons", "_ruck_magazines"];

_unit = player;
hint localize "STR_MISSION_TAKING_SNAPSHOT";

_weapons = weapons _unit;
_magazines = magazines _unit;
_ruck_weapons = [_unit] call ACE_fnc_RuckWeaponsList;
_ruck_magazines = [_unit] call ACE_fnc_RuckMagazinesList;

_unit setVariable["GearSnapshot", [_weapons, _magazines, _ruck_weapons, _ruck_magazines], true];

clear snapshot script - callable via action menu.

//#define DEBUG_MODE_FULL
#include "\x\cba\addons\main\script_macros_common.hpp"

private["_unit"];

_unit = player;
hint localize "STR_MISSION_CLEARING_SNAPSHOT";

_unit setVariable["GearSnapshot", nil, true];

Event handler section in description.ext file.

class Extended_Killed_Eventhandlers {
class Man {
	mission_kia = "ok = _this execVM ""kia.sqf""";
};
};

And KIA handler that respawns the gear.

//#define DEBUG_MODE_FULL
#include "\x\cba\addons\main\script_macros_common.hpp"

PARAMS_2(_unit,_killer);
private[
"_gear_snap",
"_player",
"_primary",
"_weapons",
"_magazines",
"_ruck_weapons",
"_ruck_magazines"
];

_player = player;
ISNILS(KIALag,0);

if ( _unit == _player ) then {
_gear_snap = _unit getVariable "GearSnapshot";
};

if ( ! isNil "_gear_snap" ) then {
EXPLODE_4(_gear_snap,_weapons,_magazines,_ruck_weapons,_ruck_magazines);

waitUntil {alive player};

_player = player;

if ( KIALag > 0 ) then {
	sleep KIALag;
};

removeAllWeapons _player;
removeAllItems _player;

{
	_player addMagazine _x;
} forEach _magazines;

{
	_player addWeapon _x;
} forEach _weapons;

{
	ok = [_player, _x select 0, _x select 1] call ACE_fnc_PackMagazine;
} forEach _ruck_magazines;

{
	ok = [_player, _x select 0, _x select 1] call ACE_fnc_PackWeapon;
} forEach _ruck_weapons;

_primary = primaryWeapon _player;

if ( _primary != "" ) then {
	_player selectWeapon _primary;
	_player selectWeapon ( getArray(configFile>>"cfgWeapons" >> _primary >> "muzzles") select 0 );
};
};

sleep 10;

hideBody _unit;

Note there is a global variable in this script used to adjust delay in respawning gear. This is to avoid a race condition in some event handlers.

Share this post


Link to post
Share on other sites

Weapon Respawn with Rucksack Content:

// ACE Weapon Respawn by Cyborg11

private ["_ace", "_unit", "_weapons", "_items", "_magazines", "_currweap", "_hasruck", "_ruckMags", "_ruckWeaps", "_weaponback", "_success", "_muzzles", "_debug"];

_ace = isClass (configFile>>"cfgWeapons" >> "ACE_B61BombLauncher");		// Check if ACE is installed
_unit = _this select 0;
If (count _this > 1) then {_debug = _this select 1} else {_debug = false};
If (!(isPlayer _unit) || !(local player)) exitWith{};
_weapons = (weapons _unit) - (items _unit);	// weapons of the old unit
_items = items _unit;		// items of old unit
_magazines = magazines _unit;	// magazines of the old unit
_currweap = currentWeapon _unit;	// currentWeapon of the old unit

If (_ace) then {
_hasruck = player call ACE_Sys_Ruck_fnc_hasRuck;
If (_hasruck) then {
	//_ruck = _unit call ACE_Sys_Ruck_fnc_FindRuck;
	_ruckMags = [_unit] call ACE_fnc_RuckMagazinesList;
	_ruckWeaps = [_unit] call ACE_fnc_RuckWeaponsList;
};
_weaponback = _unit getvariable "ACE_weapononback";
If (_debug) then {player globalchat format ["%1",_weaponback]};
};

If (_debug) then {hint format ["Unit: %1\nWeapons: %2\nMagazines: %3", _unit,_weapons,_magazines]};

WaitUntil {alive player};
_unit = player;

removeAllWeapons _unit;
{_unit addMagazine _x} forEach _magazines;
{_unit addWeapon _x} forEach _weapons;
{_unit addWeapon _x} forEach _items;
If (_ace) then {
If (_hasruck) then {
	{
		_success = [_unit, _x select 0, _x select 1] call ACE_fnc_PackWeapon;
	} forEach _ruckWeaps;

	{
		_success = [_unit, _x select 0, _x select 1] call ACE_fnc_PackMagazine;
	} forEach _ruckMags;	
};
If (_weaponback != "") then {
	_unit addWeapon _weaponback;
	[_unit, _weaponback] call ACE_fnc_PutWeaponOnBack;
};
};	

// Select the primaryWeapon	
_unit selectWeapon _currweap;
// Fix for weapons with grenade launcher
_muzzles = getArray(configFile>>"cfgWeapons" >> _currweap >> "muzzles");
_unit selectWeapon (_muzzles select 0);

Use a Killed EventHandler :)

Share this post


Link to post
Share on other sites

sorry for the noob question but what is a killed event handler. basically what im asking is how do i get the game to call that script that cyborg posted.

Share this post


Link to post
Share on other sites

Can't seem to get this to work, the saveloadout.sqf works, but when I'm dying none of the gear is coming back. I put the event handler in the init line, and made the weaponrespawn.sqf but to no avail.

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
Sign in to follow this  

×