Jump to content
Dj Rolnik

Civilian interaction in multiplayer

Recommended Posts

Hello,

 

I am in need of your guys's help when it comes to calling some functions or simply executing scripts for each player individually within Multiplayer.

With the help of some friendly folk from the BI Forums I managed to come up with the below script.

 

However, long story short is:

I wanted to make a "civilian interaction" script which would allow all players to order civilians to "Get Down!" as well as "Get Out!". It is supposed to work after player respawn as well, so that's also worth pointing out.

The script works fine until the point we connect to MP. From there it works only for my character (the civilian gets down and leaves the area when issued), but it does not work for other players on the server. They just play gestures and screm the voicelines I put there, but the civs do not react.

 

I dare to believe it is due to how the script is called, where it is placed and probably something with the locality of the script and the civs called by it, if you may.

I have tried calling functions, placing it in initPlayerLocal.sqf, but for the love of me, I cannot figure it out...

 

This is how it looks currently:

initPlayerLocal.sqf

if (side player == blufor) then {
	player addAction ["Na ziemię!", {cursortarget call CivDown}];
	player addAction ["Wynocha!", {cursortarget call CivGoAway}];
};

acim_fnc_playActionNow = {
_unit = _this select 0;
_gesture = _this select 1;
_unit playActionNow _gesture;
};

CivDown = {
_civ =_this;
_side = side _this;

if (( _side == Civilian) && (_civ isKindOf "Man") && (alive _civ)) then {
	_random = 6;
	_randomResult = floor(random _random);
	switch (_randomResult) do
		{
			case 0: {[player, "get_down_on_the_ground"] call CBA_fnc_globalSay3d;};
			case 1: {[player, "get_down"] call CBA_fnc_globalSay3d;};
			case 2: {[player, "freeze"] call CBA_fnc_globalSay3d;};
			case 3: {[player, "freeze_2"] call CBA_fnc_globalSay3d;};
			case 4: {[player, "stop"] call CBA_fnc_globalSay3d;};
			case 5: {[player, "stop_right_there"] call CBA_fnc_globalSay3d;};
		};
		[player, "gestureGo"] call acim_fnc_playActionNow;
		sleep 1;
		if (player distance _civ < 40) then {
			_civ disableAI "MOVE";
			sleep 0.3;
			_civ setUnitPos "DOWN";
			_civ setBehaviour "CARELESS";}
		};
};

CivGoAway = {
_civ =_this;
_side = side _this;

if (( _side == Civilian) && (_civ isKindOf "Man") && (alive _civ)) then {
	_random = 6;
	_randomResult = floor(random _random);
	switch (_randomResult) do
		{
			case 0: {[player, "move_it"] call CBA_fnc_globalSay3d;};
			case 1: {[player, "go"] call CBA_fnc_globalSay3d;};
			case 2: {[player, "move"] call CBA_fnc_globalSay3d;};
			case 3: {[player, "get_the_hell_outta_here"] call CBA_fnc_globalSay3d;};
			case 4: {[player, "move_your_ass"] call CBA_fnc_globalSay3d;};
			case 5: {[player, "off_you_go"] call CBA_fnc_globalSay3d;};
		};
		[player, "gestureGo"] call acim_fnc_playActionNow;
		sleep 1;
		if (player distance _civ < 40) then {
			_civ enableAI "MOVE";
			sleep 0.3;
			_civ setUnitPos "UP";
			_civ setBehaviour "COMBAT";
			_civ move (waypoint_trigger call BIS_fnc_randomPosTrigger);}
		};
};

 

I have also created a onPlayerRespawn.sqf which looks basically the same in case the action gets lost, so since the current state requires the script to work after respawns, it leads me to believe that all of it should not be placed in initPalyerLocal in the first place.

 

I will be extremely grateful for someone helping me out with making the script work for all players and allowing them to order civilians to move.

 

Thank you!

Adam

 

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

×