Jump to content

Photo
- - - - -

Script Breaking on Mission Restart


  • Please log in to reply
1 reply to this topic
Thread Starter
Ghost113
Ghost113

    Private First Class

  • Members
  • 30 posts

#1

Posted 30 March 2012 - 19:49

Hey everyone,

I wrote a quick little script for my squad so we could do some custom load outs so we didn't have to go to the boxes at the start of every mission. It works great except for the fact that if we die and restart it won't load the loadouts anymore. To get it to work we have to restart the entire server for it to finally work again.

Is there something I need to add in order for it to wait? I'm not really sure what's going on with it, but below is the script. Any help would be greatly appreciated.

The load out is done through the init line of the player.

//Defining variables DO NOT TOUCH
//
_unit = _this select 0;
_loadout = _this select 1;

//Remove weapons and items for every unit
//
removeAllWeapons _unit; //no need to put into the case, removes weapons and items automatically
removeAllitems _unit;
removebackpack _unit;
ace_sys_wounds_no_medical_gear = true;

//Place loadouts inbetween {} for each unit
//
switch (_loadout) do
{
case "s2":
	{
//Gear
	_unit addmagazine "IR_Strobe_Target";
	_unit addmagazine "ACE_Knicklicht_IR";
	_unit addweapon "NVGoggles";
	_unit addweapon "ACE_MAP";
	_unit addweapon "ACE_DAGR";
	_unit addweapon "acre_prc148";
	_unit addweapon "ItemCompass";
	_unit addweapon "Binocular";
	_unit addweapon "ACE_Earplugs";
//Ruck
	_unit addweapon "ACE_Rucksack_MOLLE_Green_Medic";
	[_unit, "ACE_30Rnd_556x45_S_Stanag", 6] call ACE_fnc_PackMagazine;
	[_unit, "ACE_WireCutter", 1] call ACE_fnc_PackWeapon;
	[_unit, "ACE_KeyCuffs", 1] call ACE_fnc_PackWeapon;	
	[_unit, "ACE_Medkit", 12] call ACE_fnc_PackMagazine;
	[_unit, "ACE_Bandage", 12] call ACE_fnc_PackMagazine;
	[_unit, "ACE_Epinephrine", 15] call ACE_fnc_PackMagazine;
	[_unit, "ACE_Morphine", 15] call ACE_fnc_PackMagazine;
	[_unit, "ACE_LargeBandage", 12] call ACE_fnc_PackMagazine;
	[_unit, "SmokeShellYellow", 1] call ACE_fnc_PackMagazine;
//WEAPONS
	_unit addWeapon "ACE_SOC_M4A1_GL_EOTECH";
	_unit setVariable ["ACE_weapononback", "ACE_M4SPR_SD"];
	{_unit addMagazine "ACE_1Rnd_HE_M203"} forEach [1,2,3,4,5,6];
	{_unit addMagazine "ACE_30Rnd_556x45_S_Stanag"} forEach [1,2,3,4,5,6,7,8,9,10,11];
	};
	
case "s1":
	{
//Gear
	_unit addmagazine "IR_Strobe_Target";
	_unit addmagazine "ACE_Knicklicht_IR";
	_unit addweapon "NVGoggles";
	_unit addweapon "ACE_MAP";
	_unit addweapon "ACE_DAGR";
	_unit addweapon "acre_prc148";
	_unit addweapon "ItemCompass";
	_unit addweapon "ACE_Earplugs";
//Ruck
	_unit addweapon "ACE_Backpack_US";
	[_unit, "ACE_30Rnd_556x45_S_Stanag", 5] call ACE_fnc_PackMagazine;
	[_unit, "ACE_20Rnd_762x51_S_M110", 5] call ACE_fnc_PackMagazine;
	[_unit, "ACE_KeyCuffs", 1] call ACE_fnc_PackWeapon;
	[_unit, "100Rnd_762x51_M240", 2] call ACE_fnc_PackMagazine;
	[_unit, "ACE_Medkit", 2] call ACE_fnc_PackMagazine;
	[_unit, "ACE_Bandage", 2] call ACE_fnc_PackMagazine;
	[_unit, "ACE_Epinephrine", 2] call ACE_fnc_PackMagazine;
	[_unit, "ACE_Morphine", 2] call ACE_fnc_PackMagazine;
	[_unit, "SmokeShell", 2] call ACE_fnc_PackMagazine;
	[_unit, "SmokeShellYellow", 1] call ACE_fnc_PackMagazine;
	[_unit, "Pipebomb", 2] call ACE_fnc_PackMagazine;
//WEAPONS
	_unit addWeapon "SCAR_L_CQC_Holo";
	{_unit addMagazine "ACE_30Rnd_556x45_S_Stanag"} forEach [1,2,3,4,5];
	_unit setVariable ["ACE_weapononback", "M110_NVG_EP1"];
	{_unit addMagazine "ACE_20Rnd_762x51_S_M110"} forEach [1,2,3,4,5];
	};


gammadust
gammadust

    Master Gunnery Sergeant

  • Members
  • 1056 posts

#2

Posted 30 March 2012 - 21:26

I would start looking into MPRespawn and addMPEventHandler (requires OA 1.55)