Jump to content
Frenki

Script for spawning wounded AI not working on Dedicatet

Recommended Posts

I am working on new Baisic Training for my community and we were looking for interesting way to learn people how to treat wounded soliders with ACE medical system. I was searching over internet and found script created by Tiberius. Its consisted of two .sqf files:

TiB_Medical.sqf

if (isServer) then 
{
_spawnpos = _this select 0;
_distance = _this select 1;
_mode = _this select 2;
_dir = (getDir _spawnpos) - 180;
_counter = 0;
_woundcount = 0;

	_Grp = createGroup civilian;
	"rhssaf_army_m10_digital_officer" createUnit [_spawnpos, _Grp,"victim0 = this"];
	victim0 setDir _dir;
	victim0 disableai "move";
	
	null = [victim0, _spawnpos, _distance, _mode] execVM "Tib_practicePatient\Tib_Check.sqf";	
	
};

and 
 

TiB_Check.sqf

 

if (isServer) then 
{
_victim = _this select 0;
_spawnpos = _this select 1;
_distance = _this select 2;
_mode = _this select 3;
_counter = 0;
_woundcount = 0;

	_victim disableai "move";
	if (_mode == 1) then {_woundcount = 1 + round random 1;};
	if (_mode == 2) then {_woundcount = 1 + round random 4;};
	
	if (_mode <3) then 
	{
		while {_counter <= _woundcount} do
		{
			_bodypart = ["head", "body", "hand_l", "hand_l", "hand_r", "leg_l", "leg_r"] call BIS_fnc_selectRandom;
			_Size = 0.2 + random 0.6;
			//_amount = 1 + round random 4;
			_WoundType = ["bullet", "grenade", "explosive", "shell", "vehiclecrash", "backblast", "stab", "punch", "falling", "unknown"] call BIS_fnc_selectRandom;	
			[_victim, _Size, _bodypart, _WoundType] call ace_medical_fnc_addDamageToUnit;
			[_victim] call ace_medical_fnc_setCardiacArrest;
			
			_counter = _counter + 1;	
		};
	
	} else
		{
			[_victim] call ace_medical_fnc_setCardiacArrest;
		};
	
	waituntil {(_victim distance _spawnpos > _distance || !alive _victim)};	
	
	waituntil {(getPos _victim select 2 <= 0.3 && speed (vehicle _victim)  == 0)};
	
	sleep 5;
	deletevehicle _victim;

};

I am calling this to execute trough addAction on laptop with

 this addAction ["Постави Пацијента", "Pacijent.sqf"];

and Pacijent.sqf is

 

null = [spawnPos, 10, 1] execVM "Tib_practicePatient\Tib_medical.sqf";

Wich is basicly spawning wounded AI on helipad named "spawnPos" and in SP in editor it worksh as it should but when i put it on my dedicated nothing happens, does anyone know why?
 

Share this post


Link to post
Share on other sites

When i call it trough console on server with code 

null = [spawnPos, 3, 2] execVM "Tib_practicePatient\Tib_medical.sqf";

and it works with both global and server exec.

Share this post


Link to post
Share on other sites

@Frenki

You aren't the server on dedicated server. You have isServer and the action calls it (you are selecting it). That being said, it should create the unit and some other stuff. Does any of it work at all? Please provide an example mission so I can check it myself, if you want. Unless the action is local then it won't.

Share this post


Link to post
Share on other sites

Your addAction code is local. So, if your execVM a code with if (isServer) then {...}, that can't work (on dedicated). You can make it work on hosted server only: server + local.

 

instead of:

null = [spawnPos, 3, 2] execVM "Tib_practicePatient\Tib_medical.sqf";

try:

 {[spawnPos, 3, 2] execVM "Tib_practicePatient\Tib_medical.sqf"} remoteExec ["bis_fnc_call",2];

or

create your unit locally (erase all the isServer condition). The unit is created globally, anyway. The good question is for the ACE functions. Not familiar with them but this should work if all clients have loaded this addon.

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
22 hours ago, pierremgi said:

 {[spawnPos, 3, 2] execVM "Tib_practicePatient\Tib_medical.sqf"} remoteExec ["bis_fnc_call",2];

@pierremgi

 

This one worked just fine, thanks for help!

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

×