Jump to content
Reeveli

Code effects duplicating on dedicated server

Recommended Posts

Hello people, me and my friends have been trying to solve this issue for a while now so any help would be appreciated. Here is a quick rundown of whats happening:

We are trying to a create a whole family of scripts (functions) that use the same framework to create ammunition, supplies and troop reinforcements dropped by parachute. In the example mission (link at the end of the post) only a single uncompiled script is included as an example. This script creates a helicopter that flies over the script originator (in this case a laptop on a table). What is supposed to happen is that two ammunition crates are created and attached to parachute to fall into the ground. This works as intended. However when this is done on a dedicated server four crates are created with their parachutes and smoke signals. We have no idea why this is and we are also unable to duplicate this bug in locally hosted environment. And before anyone asks we have tried remote execution but the bug persists.

 

To anyone that cannot test this on a dedicated server but would still be willing to look at the script the script is under the spoiler.

Here is the link to the unmodded example mission: https://drive.google.com/drive/folders/1Zgkji7v7ncYdD1iaHpPy46i95Caoq7m1

 

Spoiler

_target = _this select 0;

 

_end_position = getPos _target;

 

_starting_pos = [_end_position select 0, (_end_position select 1) + 700];

_middle_pos = [_end_position select 0, (_end_position select 1) + 20];

_jump_pos = [_end_position select 0, (_end_position select 1) - 20];

_del_pos = [_end_position select 0, (_end_position select 1) - 300];


 

_reinforcement_plane = CreateGroup [West, true];

_ju52 = createVehicle ["B_Heli_Transport_01_F", _starting_pos, [], 0, "FLY"];

_reinforcement_plane setFormDir 180;

_ju52 setDir 180;

 

_vel = velocity _ju52;

_ju52 setVelocity [

    (sin 180 * 120),

    (cos 180 * 120),

    (_vel select 2)

];


 

_JuPilot = _reinforcement_plane createUnit ["B_Helipilot_F", [0,0,1], [], 0, "CAN_COLLIDE"];

_JuPilot moveInDriver _ju52;

_JuPilot setDir 180;

_JuPilot2 = _reinforcement_plane createUnit ["B_Helipilot_F", [0,0,1], [], 0, "CAN_COLLIDE"];

_JuPilot2 moveInGunner _ju52;

_JuPilot2 setDir 180;


 

_reinforcement_plane setcombatmode "BLUE";

_reinforcement_plane setBehaviour "CARELESS";

_JuPilot disableAI "TARGET";

_JuPilot disableAI "AUTOTARGET";

_JuPilot2 disableAI "TARGET";

_JuPilot2 disableAI "AUTOTARGET";

_reinforcement_plane allowFleeing 0;

 

_wp1 = _reinforcement_plane addWaypoint [_middle_pos, 0];

_wp1 setWaypointType "MOVE";

_wp1 setWayPointBehaviour "AWARE";

_wp1 setWaypointSpeed "NORMAL";

_wp1 setWaypointStatements ["true",

"

[vehicle leader this] spawn {

    _pos = getpos param [0];

    _para = createVehicle ['Steerable_Parachute_F', _pos,[],0,'Fly'];

    _vel = velocity _para;

    _box = 'Box_AAF_Equip_F' createVehicle [0,0,0];

    _box attachto [_para,[0,0,-1]];

    _para setVelocity [

    (_vel select 0),

    (_vel select 1),

    20

    ];

    _box allowdamage false;

    _smoke1 = 'SmokeShellBlue' createVehicle [0,0,0];

    _smoke1 attachto [_box,[0,0,0]];

    waitUntil {!alive _smoke1};

    _smoke2 = 'SmokeShellBlue' createVehicle [0,0,0];

    _smoke2 attachto [_box,[0,0,0]];

    waitUntil {(getPos _box) select 2 < 3};

    detach _box;

    deleteVehicle _smoke2;

    _smoke3 = 'SmokeShellBlue' createVehicle [0,0,0];

    _smoke3 attachto [_box,[0,0,0]];

};

"];

 

_wp2 = _reinforcement_plane addWaypoint [_jump_pos, 1];

_wp2 setWaypointType "MOVE";

_wp2 setWayPointBehaviour "AWARE";

_wp2 setWaypointSpeed "NORMAL";

_wp2 setWaypointStatements ["true",

"

[vehicle leader this] spawn {

    _pos2 = getpos param [0];

    _para2 = createVehicle ['Steerable_Parachute_F', _pos2,[],0,'Fly'];

    _vel = velocity _para2;

    _box2 = 'Box_AAF_Equip_F' createVehicle [0,0,0];

    _box2 attachto [_para2,[0,0,-1]];

    _para2 setVelocity [

    (_vel select 0),

    (_vel select 1),

    15

    ];

    _box2 allowdamage false;

    _smoke4 = 'SmokeShellBlue' createVehicle [0,0,0];

    _smoke4 attachto [_box2,[0,0,0]];

    waitUntil {!alive _smoke4};

    _smoke5 = 'SmokeShellBlue' createVehicle [0,0,0];

    _smoke5 attachto [_box2,[0,0,0]];

    waitUntil {(getPos _box2) select 2 < 3};

    detach _box2;

    deleteVehicle _smoke5;

    _smoke6 = 'SmokeShellBlue' createVehicle [0,0,0];

    _smoke6 attachto [_box2,[0,0,0]];

};

"];

 

_wp3 = _reinforcement_plane addWaypoint [_del_pos, 2];

_wp3 setWaypointType "MOVE";

_wp3 setWayPointBehaviour "AWARE";

_wp3 setWaypointSpeed "NORMAL";

_wp3 setWaypointStatements ["true", "_cleanUpveh = vehicle leader this; {deleteVehicle _x} forEach crew _cleanUpveh + [_cleanUpveh];"];

 

 

Share this post


Link to post
Share on other sites

Waypoints are created globally, when you add waypoint statements this is also added globally. When the vehicle reaches the waypoint the statement is executed on all machines( dedicated = server and the player, hosted = server and player are same machine so you only see the two crates, Add more players to dedicated and you will see 2 crates * (sever + number of players) ).

Wrap your waypoint statement code in...

if ( local this ) then {
	//do stuff
};

ie

Spoiler

_wp1 setWaypointStatements ["true", "
	if ( local this ) then {
		
		[vehicle leader this] spawn {
		    _pos = getpos param [0];
		    
		    _para = createVehicle ['Steerable_Parachute_F', _pos,[],0,'Fly'];
		    _vel = velocity _para;
		    
		    _box = 'Box_AAF_Equip_F' createVehicle [0,0,0];
		    _box allowdamage false;
		    _box attachto [_para,[0,0,-1]];
		    
		    _para setVelocity [
			    (_vel select 0),
			    (_vel select 1),
			    20
		    ];
		    	
		    _smoke1 = 'SmokeShellBlue' createVehicle [0,0,0];
		    _smoke1 attachto [_box,[0,0,0]];
		    
		    waitUntil {!alive _smoke1};
		    
		    _smoke2 = 'SmokeShellBlue' createVehicle [0,0,0];
		    _smoke2 attachto [_box,[0,0,0]];
		    
		    waitUntil {(getPos _box) select 2 < 3};
		    
		    detach _box;
		    deleteVehicle _smoke2;
		    
		    _smoke3 = 'SmokeShellBlue' createVehicle [0,0,0];
		    _smoke3 attachto [_box,[0,0,0]];
		};
	};
"]; 

 

 

  • Like 3

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

×