Jump to content
Sign in to follow this  
Persian MO

setUnconscious animation on dedicated server

Recommended Posts

Hi.

I have a simple script so when ai get shoot , there is a chance they move to Unconscious state and it working on my pc and also on server, but the Unconscious animation working just on my pc(single player).

In dedicated server Ai unit move to Unconscious state but no animation.

Here is script:

init.sqf

fnc_injured = { 
	_unit = _this select 0;
    _unit removeAllMPEventHandlers "MPHit";
	_unit setUnconscious true;
  	
while {(true)} do {

sleep (30 + random 60);

_ls = lifeState _unit;

if (_ls != "INCAPACITATED") exitWith {};
	
_sound = [
"pain1", "pain2", "pain3", "pain4", "pain5", "pain6", "pain7", "pain8", "pain9", "pain10", "pain11", "pain12", "pain13"
] call BIS_fnc_selectRandom;

_unit say3D [_sound, 100, 1];

sleep (60 + random 60);
	
};
	}; 

initserver.sqf

_null = [] execvm "injured.sqf";

injured.sqf

sleep 1;

{
	if (side _x == east) then {
		
		 if (_x isKindOf "Man") then
            {
				_x removeAllMPEventHandlers "MPHit";
				
		call compile format["
			%1 addMPEventHandler ['MPHit',{
				if (vehicle %1 == %1) then {
					_rand = random 100;
					if (_rand < 35) then {
						[%1] spawn fnc_injured;
					};
				};
			}]
		",[_x] call BIS_fnc_objectVar];
	};
	
	};
	
} forEach allUnits;


any solution for animation?

 

 

on singlePlayer

w1u4jb1n2tardq96g.jpg

 

 

on server

s9igu5b6dkb9oo06g.jpg

Share this post


Link to post
Share on other sites
Guest

You can broadcast the animation yourself with remoteExec and switchMove.

Share this post


Link to post
Share on other sites
Ok, found a solution.
Share a demo mission here if somebody need it
 
 
init.sqf
 
fnc_injured = { 
	_unit = _this select 0;
    _unit removeAllMPEventHandlers "MPHit";
[ _unit ] remoteExec [ "TAG_fnc_setunconscious", 2 ];

	sleep 3;


_anim = [
"UnconsciousReviveArms_A","UnconsciousReviveArms_B","UnconsciousReviveArms_C","UnconsciousReviveBody_A",
"UnconsciousReviveBody_B","UnconsciousReviveDefault_A","UnconsciousReviveDefault_B","UnconsciousReviveHead_A",
"UnconsciousReviveHead_B","UnconsciousReviveHead_C","UnconsciousReviveLegs_A","UnconsciousReviveLegs_B"
 ] call bis_fnc_selectRandom;

[[[_unit,_anim],"animation.sqf"],"BIS_fnc_execVM",true,false] call BIS_fnc_MP;

while {(true)} do {

sleep (30 + random 60);

_ls = lifeState _unit;

if (_ls != "INCAPACITATED") exitWith {};
	
_sound = [
"pain1", "pain2", "pain3", "pain4", "pain5", "pain6", "pain7", "pain8", "pain9", "pain10", "pain11", "pain12", "pain13"
] call BIS_fnc_selectRandom;

_unit say3D [_sound, 100, 1];

sleep (60 + random 60);
	
};
	};

 
initserver.sqf
TAG_fnc_setunconscious = {
params[ "_unit" ];
[ _unit, true ] remoteExec [ "setUnconscious", _unit ];


};

_null = [] execvm "injured.sqf";
 
injured,sqf
sleep 3;


{
    if (side _x == east) then {
        
         if (_x isKindOf "Man") then
           {
                _x removeAllMPEventHandlers "MPHit";
                
        call compile format["
            %1 addMPEventHandler ['MPHit',{
                if (vehicle %1 == %1) then {
                    _rand = random 100;
                    if (_rand < 35) then {
                        [%1] spawn fnc_injured;
                    };
                };
            }]
        ",[_x] call BIS_fnc_objectVar];
    };
    
    };
    
} forEach allUnits;

animation.sqf

_unit = _this select 0;
_anim = _this select 1;

    _unit disableAI "TARGET";
    _unit disableAI "AUTOTARGET";
    _unit disableAI "MOVE";
    _unit disableAI "TEAMSWITCH";
    _unit disableAI "FSM";
    _unit disableAI "AIMINGERROR";
    _unit disableAI "SUPPRESSION";
    _unit disableAI "COVER";
    _unit disableAI "AUTOCOMBAT";
    _unit disableAI "PATH";
	
	
	
while {true} do {
		
_ls = lifeState _unit;
if (_ls != "INCAPACITATED") exitWith {};


_unit playMove _anim;
	

sleep 5;	
	
};



Edited by Persian MO

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  

×