Jump to content
Sign in to follow this  
bangabob

Multiplayer Addaction on Spawned object

Recommended Posts

This is really annoying espicially as old fixes go out the window with the removal of vehicleinit.

Heres my script

if (!isServer) exitwith {};
private ["_randomisedDistance","_SideRandomPos","_SideObject","_SO1","_SideLandSea","_eosType","_isDestroyObject","_addVehicle","_descriptiontwo"];_SidePosition = markerPos (_this select 0);

//---------------------------------------------------------------SET OBJECTIVE BELOW---------------------------------------------------------------------------------//
			["SecondSide","
Destroy the object","Check your map for the the location of the valuable cargo
											"] call SHK_Taskmaster_add;
_isDestroyObject = true;			//True = Blow up to complete/ False = get within 10 meters
_SideLand = true;				//land = true - Sea = false
_SideObject = "Land_CinderBlocks_F";		//Set object to spawn
_radiusPlacement = 50;				//Set randomisation 	
_globalSideMkrName = "SOMarker";		//In editor Marker name

//------------------------------------------------------------------GO TO BOTTOM----------------------------------------------------------------------------------------//
_sideMkrName = (_this select 0);
_globalSideMkrName setmarkerpos getmarkerpos _sideMkrName;
_globalSideMkrName setMarkerAlpha 1;_globalSideMkrName setMarkerText "Side Mission";
	_SideRandomPos = [_SidePosition, random _radiusPlacement, random 359] call BIS_fnc_relPos; 
	_SO1 = _SideObject createVehicle _SideRandomPos; 
	_SO1 lock true; 

if (_isDestroyObject) then {
	_SO1 addAction ["Plant/Arm C4 Explosive","sides\Sabotage.sqf"];};
	if (_SideLand) then {_eosType = "sides\EOSside.sqf";_addVehicle=True;} else {_eosType = "sides\EOSdivers.sqf";_addVehicle=false;};
		null = [_sideMkrName,true,_addVehicle] execVM _eosType;

if (_isDestroyObject) then {
waituntil {!alive _SO1};
	deletevehicle _SO1;
	_globalSideMkrName setMarkerAlpha 0;
			} else {
				waitUntil { sleep 1; ( {side _x == WEST && (_x distance _SO1) < 10} count allUnits) > 0 };
				_units = []; // all WEST units within 10m of _spwnpos
				{
					if (side _x == WEST && (_x distance _SO1) < 10) then {
   						_units set [count _units, _x];
 							};
						} forEach allUnits;  
	deletevehicle _SO1;
	_globalSideMkrName setMarkerAlpha 0;
	null = [] execVM "sides\sidebonus.sqf";
};
//----------------------------------------------------------------SET NEXT TASK (IMPORTANT)--------------------------------------------------------------------------------//
	["SecondSide","succeeded"] call SHK_Taskmaster_upd;
	SecondSide = true;
	publicVariable "SecondSide";

So basically i have spawned an object named "_SO1" which i am trying to add an action to. Works in editor and when i host my own server. But when played on a dedicated it stops working faster than a chocolate teapot.

I have looked at several fixes. None of which have worked for. Any help is appreciated.

Share this post


Link to post
Share on other sites

im green when it comes to multiplayer, but i wanted to ask: could it be your use of (!isServer) exitWith{}?

should you instead be using isDedicated?

Edit:

Do you know exactly where it is dying? is the object even spawning?

Edited by dr_strangepete

Share this post


Link to post
Share on other sites

addAction is a local command.

Add a quick function before isserver e.g

if (!(isNull player)) then {
fnc_MPaddAction = {
	_this addAction ["Plant/Arm C4 Explosive","sides\Sabotage.sqf"];
};
};

Then replace your addaction with a call to bis_fnc_mp to run that function on all clients. Something like

[_SO1,"fnc_MPaddAction",nil,true] spawn BIS_fnc_MP;

Share this post


Link to post
Share on other sites
addAction is a local command.

Add a quick function before isserver e.g

if (!(isNull player)) then {
fnc_MPaddAction = {
	_this addAction ["Plant/Arm C4 Explosive","sides\Sabotage.sqf"];
};
};

Then replace your addaction with a call to bis_fnc_mp to run that function on all clients. Something like

[_SO1,"fnc_MPaddAction",nil,true] spawn BIS_fnc_MP;

Thanks i will try that out.

Share this post


Link to post
Share on other sites

Once I understood the question, it's a fantastic answer Larrow. And all to a question I didn't even know I needed to ask.

Works a treat.

And thanks to BangaBob for asking it.

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  

×