Browse Source

Ensure stuff only runs on server, entirely

m3ales 4 years ago
parent
commit
93a41d96c1

+ 2 - 2
addons - Copy/RD501_Droid_Dispenser/functions/fnc_droidDispenserInit.sqf

@@ -3,9 +3,9 @@ params ["_target"];
 
 if(!isServer) exitWith
 {	
-	LOG_ERROR("Not Server, Exiting PFH"); 
+	LOG("Not Server, Exiting Dispenser Init"); 
 };
-
+LOG("Server, continuing on");
 LOGF_1("Initialising spawner %1",_target);
 // TODO: Read these vars from config, maybe CfgVehicles to allow placement of vehicles, although may be better to use static object with HP and destroyed mesh rather
 _target setVariable [QGVAR(group), createGroup [opfor, true]]; // group that units will be spawned into

+ 36 - 7
addons - Copy/RD501_Droid_Dispenser/functions/fnc_moduleOrbitalDroidDispenser.sqf

@@ -1,13 +1,42 @@
 #include "function_macros.hpp"
 
-LOG("Triggered Orbital Drop Droid Dispenser");
-//wait for projectile to land and then spawn vehicle
-params["_logic"];
+LOG("Spawned Orbital Drop Droid Dispenser Logic");
 
-if !(local _logic) exitWith {};
+params["_logic", "_units", "_activated"];
 
-_position = position _logic;
+if (isServer) then 
+{
+	LOG("Server, continuing on");
+	_position = position _logic;
+	LOGF_1("Firing Droid Dispenser Artillery at '%1'", _position);
+	if (_activated) then {
+		// fire projectile
+		LOG("Activated");
+		private _fnc_ThenDo = {
+			params["_position"];
+			if(!isServer) exitWith 
+			{
+				LOG("Exiting Client Method Should only run on Server");
+			};
+			LOG("Server, continuing on");
+			_spawner = GVAR(spawnerDefaultObject) createVehicle _position;
+			LOGF_2("Created Droid Dispenser Object '%1' at '%2'", _spawner, _position);
+			[{
+				params["_unit"];
+				LOG("Adding to curators");
+				if(!isServer) exitWith 
+				{
+					LOG("Exiting Client Method Should only run on Server");
+				};
+				[_unit] call FUNC(droidDispenserInit);
+				{
+					_x addCuratorEditableObjects [[_unit], true];
+				} forEach allCurators;
+			}, [_spawner]] call CBA_fnc_execNextFrame;
+		};
+		[_fnc_ThenDo, [+_position], GVAR(fireSupportSpawnDelay)] call CBA_fnc_waitAndExecute;
+	};
+};
 
-[_position] remoteExecCall [QUOTE(FUNC(moduleOrbitalDroidDispenserServer)), 2, false];
-// fire projectile
+LOG("Placing Projectile Module");
 _this call ace_zeus_fnc_bi_moduleProjectile;