Jump to content
Sign in to follow this  
mikie boy

MP animation problems and publicvariables

Recommended Posts

Sorry chaps for the below waffle, but spent the last week going round in circles, just cant figure this out...

Problem im having is that the server (tried on Dedi and Host) creates an object with an addaction - this is a task which when complete creates 8 terrorits at a marker.

These 8 terrorists have an addaction created - which when interrorgated - they perfom the surrender action/animation and then they are deleted.

when i join the server and initiate the creation of the 8 terrorists and then interrorgate the terrorists - they do carryout the surrender action. However, if i leave say 6 of the 8 alone (amount left does not have any bearing on this), then leave my server and then join again, when i go to interrorgate them this time they do not play the surrender action, but the interrogation is complete and the hint appears as it would if they performed the animation.

The actions i can see or cannot see are the same for any client who is stood next to me...

code is as below....

Init.sqf


if (isServer) then 
{
"terrorsurrender" addPublicVariableEventHandler 
{
	((_this select 1) select 0) playActionNow ((_this select 1) select 1);
};
};

execvm "tasks\waterinit.sqf";

Init.sqf calls the below waterinit.sqf

if (isserver) then 
{

//creates a load of wells and give them all addactions using the MP RE... cant think of any otherway other than using CBA. 

_watercomplete = [nil, _waterfill, "per", rADDACTION, "Assist Locals - Fill reservoir","tasks\watertask.sqf","Land_Barrel_water",1,false,true,"","(_target distance _this) < 3"] call RE;  //possible desync probs
};

watertask.sqf...


//(isserver commands not used here)
//once watertask is complete spawn the terrorists 
[]spawn terrorists;     //terrorists.sqf

terrorists.sqf


createterrorsuspects = 

{

sleep 2;  
for "_i" from 0 to 7 do    
{
		_terrormantype = ["TK_CIV_Takistani01_EP1", "TK_CIV_Takistani02_EP1", "TK_CIV_Takistani03_EP1", "TK_CIV_Takistani04_EP1", "TK_CIV_Takistani05_EP1", "TK_CIV_Takistani06_EP1"] call BIS_fnc_selectRandom;
	_distances = [10,20,30] call BIS_fnc_selectRandom;
	_ang = random 360;  	
	_dis = _distances; 
	_dx = sin(_ang)*_dis; 
	_dy = cos(_ang)*_dis; 
	_loc = [((getmarkerpos "terrorHelpers") select 0) + _dx, ((getmarkerpos "terrorHelpers") select 1) + _dy, 0];
	terrorsuspects = createAgent [_terrormantype, _loc, [], 0, "FORM"];		
	_terrorprobability = [false, true] call BIS_fnc_selectRandom;
	_terrorsearch = [nil, terrorsuspects, "per", rADDACTION, "Interrogate","interror.sqf",[_terrorprobability],6,false,true,"","(_target distance _this) < 3"] call RE;  //using MP RE - 
	terrorarraycontrol = terrorarraycontrol + 1; publicVariable "terrorarraycontrol"; 

};

};


if (isServer) then 
			{
			[nil,nil,rHINT,"1-Location of believed Terrorist supporters updated - Check Map!"] call RE;			
			_marker = createMarker [_markname, position _preplacedmkr];
			"terrorHelpers" setMarkerShape "ELLIPSE";
			"terrorHelpers" setMarkerType "DOT";
			"terrorHelpers" setMarkerSize [75, 75];
			} 	
			else 
				{			
				[nil,nil,rHINT,"2-Location of believed Terrorist supporters updated - Check Map!"] call RE;	
				objmkr = [_markname, _preplacedmkr]; publicVariable "objmkr";				
				};

			[] spawn createterrorsuspects;

Above script creates 8 terrorists with addaction to call interror.sqf.

interror.sqf


//if conditions meet that of terrorist then do below...

_movement = "Surrender";
if (isServer) then 
{
	terrorsurrender = [_civil, _movement]; publicVariable "terrorsurrender";
//		_civil playActionNow _movement; // for hosted environment
}
else
	{
	_civil playActionNow _movement;	
//		terrorsurrender = [_civil, _movement]; publicVariable "terrorsurrender";
	};

Ive swapped the above interror.sqf arround - when im first on the server and initially call the terrorists to spawn there is no surrender action. when i leave and then join, there is a surrender action.

anyone know why this is happening - mix of isservers and locality? (bane of my life lol)

Share this post


Link to post
Share on other sites

Anyone have any idea -

The animation works one initial join and then rejoin if i use MP Remote execution

[nil,_civil,rplayActionnow,"Surrender"] call RE;

Share this post


Link to post
Share on other sites

You'll have to re-do some stuff to get this working correctly, but then it will most likely work:

1. Add the action on all machines (I assume you already got that part done).

2. When the action is performed, signal the server to create the terrorists with a server-only script, rather than create them with the action itself on the client.

3. When the units are created, signal clients to add an action to interrogate/arrest them.

4. The interrogate/arrest action should then run a script that signals the server to play the "surrender" animation.

That should make it disconnect/reconnect-proof, as the server does everything and the only thing that the client does is singal the server to do something, and the server never gets disconnected.

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  

×