Jump to content
Sign in to follow this  
nedley

Add/Remove Optics Working on Respawn

Recommended Posts

I am trying to create a script or trigger that removes all optics from each player (multiplayer player vs player scenario) and replaces it with a certain scope, which remains after respawn.

I have tried 3 methods, all have failed:

Method 1

Init.sqf

_index = player addMPEventHandler ["mprespawn", {Null = _this execVM "loadout.sqf";}]; 

loadout.sqf

if (side player == east) then {
_unit = _this select 0;
if (!local _unit) exitWith {};
player removeItemFromPrimaryWeapon "optic_Arco";
player removeItemFromPrimaryWeapon "optic_Aco";
player removeItemFromPrimaryWeapon "optic_Hamr";
player removeItemFromPrimaryWeapon "optic_holosight";
player addprimaryweaponitem "optic_Aco_grn";
};

if (side player == west) then {
_unit = _this select 0;
if (!local _unit) exitWith {};
player removeItemFromPrimaryWeapon "optic_Arco";
player removeItemFromPrimaryWeapon "optic_Hamr";
player removeItemFromPrimaryWeapon "optic_holosight";
player removeItemFromPrimaryWeapon "optic_Aco_grn";
player addprimaryweaponitem "optic_Aco";
};

This method does not work as when in Multiplayer, those who are killed and subsequently respawn have the standard optics loadout.

Method 2

'Triggers' placed in the spawn area, activated by the class that spawns there

From mission.sqm:

class Item1
	{
		position[]={5242.6787,163.64134,5972.6284};
		a=35;
		b=35;
		angle=153;
		rectangular=1;
		activationBy="EAST";
		repeating=1;
		interruptable=1;
		age="UNKNOWN";
		name="triggeropfor";
		expActiv="player removeItemFromPrimaryWeapon ""optic_Arco"";  player removeItemFromPrimaryWeapon ""optic_Aco"";  player removeItemFromPrimaryWeapon ""optic_Hamr"";  player removeItemFromPrimaryWeapon ""optic_holosight"";  player addprimaryweaponitem ""optic_Aco_grn"";";
		class Effects
		{
		};

I thought this had worked, and in a working MP server with 40 people it seems to be going well, though after a few kills, I observed people with standard optics again.

Method 3

init line of player(s)

_handle = [] execVM "SWRepsawn_SRU.sqf"

SWRepsawn_SRU.sqf

while {true} do {
   waitUntil {!alive player};
   _weapons = weapons player;
   _magazines = magazines player;
   waitUntil {alive player};
   _p = player;
   removeAllItems _p;
   removeAllWeapons _p;
   {_p addMagazine _x} forEach _magazines;
   {_p addWeapon _x} forEach _weapons;
   _primw = primaryWeapon _p;
   if (_primw != "") then {
       _p selectWeapon _primw;
       // for Grenades Launchers 
       _muzzles = getArray(configFile>>"cfgWeapons" >> _primw >> "muzzles");
       _p selectWeapon (_muzzles select 0);
   };
};

I don't think this script takes into account optics, and i don't have the expertise to add it.

Thoroughly %$^$%ing worn out with trying to achieve 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
Sign in to follow this  

×