Jump to content
Sign in to follow this  
Romeo_Delta

Respawn with same gear you start with

Recommended Posts

Yes, I searched for this. I found a couple scripts that are supposed to do this, but they didn't work for me. Basically what I want is just a script that gives players the same gear they started the mission with. I asked around and someone told me I would want a script that checks if the player is dead, waits until they're alive, then executes a script I have that issues their gear. Here's what I've got:

gear.sqf being executed from Init.sqf

if !(isDedicated) then
	{
		if !(alive player) then
		{
			while {!alive player} do {sleep 0.05;};

			while {alive player} do {execVM "krauseOrbat\MarineRiflekitout.sqf";};
		};


	};

It doesn't work. I'm pretty sure it's just the syntax being wrong, but I'm terrible with scripting so I could be totally way off. Anyone mind helping me out here?

Share this post


Link to post
Share on other sites

A while loop, which you're using, is used to continously loop until the while condition, alive player, is broken. So you're disarming and rearming that unit every half a second until he's dead. So that won't work. Also, init.sqf is generally only executed once unless you make it execute yourself. In this case you really don't want that.

So let me ask you this. Respawn aside, are you changing a unit's gear before the mission "starts"? As in, in the editor or in other scripts you are removing everything that unit has then replacing it with something else? How's this being done?

This is what I use and implemented into revive.

refill.sqf

{player addMagazine _x;} forEach BIS_EVO_pallammo;

{player addWeapon _x;} forEach BIS_EVO_pweapons;

_primary = primaryWeapon player;
if (_primary != "") then {
player selectWeapon _primary;
// Grenade launcher Fix
_muzzles = getArray(configFile>>"cfgWeapons" >> _primary >> "muzzles");
player selectWeapon (_muzzles select 0);
};

And in a trigger I have this:

Activation: Repeatadly
Condition: 
animationState player == "amovpercmstpslowwrfldnon_gear" or animationState player == "amovpercmstpsraswrfldnon_gear"
OnDea.: BIS_EVO_pallammo = magazines player;BIS_EVO_pweapons = weapons player; hintSilent "Gear Saved";

Yes, OnAct is supposed to be empty. What this does is every time a unit kneels down to open up the gear menu, then closes it, there ammo and weapons are saved. This is then called once they respawn. So on respawn just execute refill.sqf and you're set. Do this via MPEventHandler or a properly placed execVM.

Share this post


Link to post
Share on other sites

Gear is being changed via MarineRiflekitout.sqf prior to mission start. The script you posted is one of the ones I found. The reason I don't want to use it is because of the fact that it saves every time someone checks their gear. Say someone checks their gear after expending a couple magazines and grenades, then they get killed. Wouldn't they respawn missing those items?

Share this post


Link to post
Share on other sites

Yes, you're right. So assuming MarineRiflekitout.sqf does the gear properly, just throw this in your init.sqf

_unit addMPEventHandler ["MPRespawn",{(_this select 0) execVM "MarineRiflekitout.sqf";}];

Where _unit is whatever unit you are. Or do a

_units = ["unit1", "unit2", "unitetc"];
{
_x addMPEventHandler ["MPRespawn",{(_this select 0) execVM "MarineRiflekitout.sqf";}];
} forEach _units;

That last one was just a guess though.

Share this post


Link to post
Share on other sites

Thanks for the help so far. I tried what you said and am getting an RPT error:

Error in expression < "u40", "u41", "u42", "u43"];

_unit addMPEventHandler ["MPRespawn",{(_this s>
 Error position: <addMPEventHandler ["MPRespawn",{(_this s>
 Error addmpeventhandler: Type Array, expected Object

Here's what I have in my init.sqf:

_unit = ["u1", "u2", "u3", "u4", "u5", "u6", "u7", "u8", "u9", "u10", "u11", "u12", "u13", "u14", "u15", "u16", 

"u17", "u18", "u19", "u20", "u21", "u22", "u23", "u24", "u25", "u26", "u27", "u28", "u29", "u30", "u31", "u32", 

"u33", "u34", "u35", "u36", "u37", "u38", "u39", "u40", "u41", "u42", "u43"];

_unit addMPEventHandler ["MPRespawn",{(_this select 0) execVM "krauseOrbat\MarineRiflekitout.sqf";}];

MarineRiflekitout.sqf:

private ["_type", "_unit"];

_type = _this select 0;
_unit = _this select 1;


_unit addWeapon "ACE_EARPLUGS"; 
_unit addMagazine "ACE_BANDAGE"; 
_unit addMagazine "ACE_BANDAGE";
_unit addMagazine "ACE_MORPHINE";
_unit addMagazine "ACE_Epinephrine";
_unit addWeapon "ItemMap";
_unit addWeapon "ItemCompass";
_unit addWeapon "ItemWatch";
_unit addWeapon "ACRE_PRC343";
_unit addWeapon "NVGoggles";
_unit addWeapon "ACE_KeyCuffs";
_unit addWeapon "ACE_GlassesLHD_glasses";
_unit addWeapon "ACE_GlassesBalaklava";

switch (_type) do
{
	case "PL":
	{
		_unit addWeapon "ACE_M16A4_ACG_GL_UP";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "ACE_30Rnd_556x45_T_Stanag";
		_unit addMagazine "SmokeShell";
		_unit addMagazine "SmokeShell";
		_unit addMagazine "HandGrenade_West";
		_unit addMagazine "HandGrenade_West";
		_unit addWeapon "ACRE_PRC148";
		_unit addWeapon "Binocular";
		_unit setVariable ["ace_weaponOnBack", "ACE_CharliePack_WMARPAT"];
		_unit setVariable ["ACE_RuckMagContents", [["30Rnd_556x45_Stanag",7], ["SmokeShellGreen",2], ["SmokeShellRed",1], ["Handgrenade_west",2], ["1Rnd_SmokeGreen_M203",5], ["1Rnd_SmokeRed_M203",5], ["1Rnd_SmokeYellow_M203",5], ["ACE_Knicklicht_B",10], ["ACE_Knicklicht_G",10], ["ACE_Knicklicht_R",10] ]];
		_unit addWeapon "ItemGPS";
	};	

		case "SL":
	{
		_unit addWeapon "ACE_M16A4_ACG_GL_UP";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "ACE_30Rnd_556x45_T_Stanag";
		_unit addMagazine "SmokeShell";
		_unit addMagazine "SmokeShell";
		_unit addMagazine "HandGrenade_West";
		_unit addMagazine "ACE_1Rnd_HE_M203";
		_unit addMagazine "ACE_1Rnd_HE_M203";
		_unit addMagazine "ACE_1Rnd_HE_M203";
		_unit addMagazine "ACE_1Rnd_HE_M203";
		_unit addMagazine "ACE_1Rnd_HE_M203";
		_unit addWeapon "ACE_HuntIR_monitor";
		_unit addWeapon "ACRE_PRC117F";
		_unit setVariable ["ace_weaponOnBack", "ACE_CharliePack_WMARPAT"];
		_unit setVariable ["ACE_RuckMagContents", [["30Rnd_556x45_Stanag",7], ["SmokeShellGreen",2], ["ACE_1Rnd_HE_M203",5], ["1Rnd_SmokeGreen_M203",5], ["ACE_HuntIR_M203",6], ["1Rnd_SmokeRed_M203",5], ["1Rnd_SmokeYellow_M203",5], ["SmokeShellRed",1], ["Handgrenade_west",2]]];
		_unit addWeapon "ItemGPS";
		_unit addWeapon "ACE_Rangefinder_OD";
		_unit addMagazine "ACE_Battery_Rangefinder";
	};

		case "TL":
	{
		_unit addWeapon "m16a4_acg";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "ACE_30Rnd_556x45_T_Stanag";
		_unit addMagazine "SmokeShell";
		_unit addMagazine "SmokeShell";
		_unit addMagazine "HandGrenade_West";
		_unit addMagazine "HandGrenade_West";
		_unit setVariable ["ace_weaponOnBack", "ACE_CharliePack_WMARPAT"];
		_unit setVariable ["ACE_RuckMagContents", [["30Rnd_556x45_Stanag",7], ["Handgrenade_west",2]]];
		_unit addWeapon "Binocular";
	};

		case "corpsman":
	{
		_unit addWeapon "m16a4";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "SmokeShell";
		_unit addMagazine "SmokeShell";
		_unit addMagazine "HandGrenade_West";
		_unit addMagazine "HandGrenade_West";
		_unit addMagazine "ACE_Epinephrine";
		_unit addMagazine "ACE_Epinephrine";
		_unit addMagazine "ACE_Morphine";
		_unit addMagazine "ACE_Morphine";
		_unit setVariable ["ace_weaponOnBack", "ACE_CharliePack_WMARPAT"];
		_unit setVariable ["ACE_RuckMagContents", [["ACE_Medkit",10], ["ACE_Epinephrine", 10], ["ACE_BANDAGE", 10], ["ACE_MORPHINE", 10]]];
	};		

		case "rifle":
	{
		_unit addWeapon "m16a4";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "SmokeShell";
		_unit addMagazine "ACE_30Rnd_556x45_T_Stanag";
		_unit addMagazine "HandGrenade_West";
		_unit addMagazine "HandGrenade_West";
		_unit addWeapon "ACE_M136_CSRS";
		_unit setVariable ["ace_weaponOnBack", "ACE_CharliePack_WMARPAT"];
		_unit setVariable ["ACE_RuckMagContents", [["30Rnd_556x45_Stanag",10], ["Handgrenade_west",2]]];
	};	

		case "rTL":
	{
		_unit addWeapon "M16A4_ACG_GL";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "ACE_1Rnd_HE_M203";
		_unit addMagazine "ACE_1Rnd_HE_M203";
		_unit addMagazine "ACE_1Rnd_HE_M203";
		_unit addMagazine "ACE_1Rnd_HE_M203";
		_unit addMagazine "ACE_1Rnd_HE_M203";
		_unit addMagazine "1Rnd_Smoke_M203";
		_unit addMagazine "ACE_30Rnd_556x45_T_Stanag";
		_unit addMagazine "SmokeShell";
		_unit addMagazine "HandGrenade_West";
		_unit addMagazine "HandGrenade_West";			
		_unit addWeapon "ACE_CharliePack_WMARPAT"; 
		_unit setVariable ["ACE_RuckMagContents", [["30Rnd_556x45_Stanag",7], ["1Rnd_Smoke_M203",5], ["Handgrenade_west",2], ["1Rnd_SmokeGreen_M203",5], ["1Rnd_SmokeRed_M203",5], ["1Rnd_SmokeYellow_M203",5], ["ACE_1Rnd_HE_M203",10]]];
		_unit addWeapon "Binocular";
	};

		case "AR":
	{
		_unit addWeapon "M249";
		_unit addMagazine "200Rnd_556x45_M249";
		_unit addMagazine "200Rnd_556x45_M249";
		_unit addMagazine "200Rnd_556x45_M249";
		_unit addMagazine "200Rnd_556x45_M249";
		_unit addMagazine "SmokeShell";
		_unit addMagazine "HandGrenade_West";
		_unit addMagazine "HandGrenade_West";
		_unit setVariable ["ace_weaponOnBack", "ACE_CharliePack_WMARPAT"];
		_unit setVariable ["ACE_RuckMagContents", [["Handgrenade_west",2]]];
	};	

		case "AAR":
	{
		_unit addWeapon "m16a4";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "30Rnd_556x45_Stanag";
		_unit addMagazine "200Rnd_556x45_M249";
		_unit addMagazine "200Rnd_556x45_M249";			
		_unit addMagazine "ACE_30Rnd_556x45_T_Stanag";
		_unit addMagazine "HandGrenade_West";
		_unit addMagazine "HandGrenade_West";
		_unit addMagazine "SmokeShell";
		_unit addWeapon "ACE_M72A2";
		_unit setVariable ["ace_weaponOnBack", "ACE_CharliePack_WMARPAT"];
		_unit setVariable ["ACE_RuckMagContents", [["30Rnd_556x45_Stanag",5], ["Handgrenade_west",2]]];
		_unit addWeapon "Binocular";
	};			

};

Typical unit init (ID is different depending on the unit):

removeallitems this; removeallweapons this; id = ["AR", this] call compile preprocessFileLineNumbers "krauseOrbat\MarineRiflekitout.sqf";

Edited by Romeo_Delta

Share this post


Link to post
Share on other sites

If you're using ACE simply put down the "Respawn with weapons" module and be done with it. You'll respawn with the weapons you had when you died.

Share this post


Link to post
Share on other sites

That's odd, but OK, just run the script you ran at the start again. Grime's MPRespawn thing should work for that.

Share this post


Link to post
Share on other sites

I tried, but I'm getting RPT errors.

When I do this I get no errors, but the gear doesn't respawn with me:

_units = ["u1", "u2", "u3", "u4", "u5", "u6", "u7", "u8", "u9", "u10", "u11", "u12", "u13", "u14", "u15", "u16", 

"u17", "u18", "u19", "u20", "u21", "u22", "u23", "u24", "u25", "u26", "u27", "u28", "u29", "u30", "u31", "u32", 

"u33", "u34", "u35", "u36", "u37", "u38", "u39", "u40", "u41", "u42", "u43"];

{
_units addMPEventHandler ["MPRespawn",{(_this select 0) execVM "krauseOrbat\MarineRiflekitout.sqf";}];
};

When I change the bit of code in red...


{
[color="Red"]_x[/color] addMPEventHandler ["MPRespawn",{(_this select 0) execVM "krauseOrbat\MarineRiflekitout.sqf";}];
} [color="red"]forEach _units;[/color]

...I get this RPT error:

Error in expression <39", "u40", "u41", "u42", "u43"];
{
_x addMPEventHandler ["MPRespawn",{(_this s>
 Error position: <addMPEventHandler ["MPRespawn",{(_this s>
 Error addmpeventhandler: Type String, expected Object

Edited by Romeo_Delta

Share this post


Link to post
Share on other sites

Use this script, very simple, wont get errors, youll respawn with same weapons you started with:

Universal Weapons Respawn Script

http://www.armaholic.com/page.php?id=1554&highlight=UNIVERSAL+WEAPONS+RESPAWN+SCRIPT

just put this code in your playable character's init line, give the character a name:

["[b]joebloggs[/b]",0] exec "weapons_respawn.sqs"

the bolded name in the code is the character's name just name your playable character something simple like A1 and put the

name in the code and then put the script in the mission folder, and all you need to do.

I use this script all the time and it works with np with any mod.

Edited by Gnter Severloh

Share this post


Link to post
Share on other sites
Use this script, very simple, wont get errors, youll respawn with same weapons you started with:

Universal Weapons Respawn Script

http://www.armaholic.com/page.php?id=1554&highlight=UNIVERSAL+WEAPONS+RESPAWN+SCRIPT

just put this code in your playable character's init line, give the character a name:

["[b]joebloggs[/b]",0] exec "weapons_respawn.sqs"

the bolded name in the code is the character's name just name your playable character something simple like A1 and put the

name in the code and then put the script in the mission folder, and all you need to do.

I use this script all the time and it works with np with any mod.

UWR is a very good script, but old (sqs usage). Works with Arma2 and OA, but, no support to backpack vanilla and ACE2. No Universal here.

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  

×