Jump to content
Sign in to follow this  
scheintot2

SetPos is delayed

Recommended Posts

Hello guys! I hope I get some help here.

 

Currently im testing a script on Multiplayer. When I enter a room a trigger gets activated and executes a script called "room1.sqf".

You can see room1.sqf below. Then room1 executes another sqf called "prepareRoom.sqf";

Somewhere at the edge of the map some popup targets are placed. These get moved into the room via "prepareRoom.sqf".

Everything works fine in SP or as the host (you enter the room and all targets are there) but as soon as I am activating the script as the client, the popup targets are moved into the room one by one, realy slowly with a delay.

 

Also the HitPart EventHandler does not realy work good. I want all targets STAY down for everyone after it gets hit once. 

 

Help would be appreciated. :)

 

Here the code:

 

 

// room1.sqf

room1 = true;
publicVariable "room1";

_hostiles = [t1,t2,t3,t4,t5];
_hostages = [h1,h2,h3,h4];
_positions = [rs1, rs1_1, rs1_2,rs1_3,rs1_4];
_all = _hostages + _hostiles;

if (hasInterface) then {
	
	{
	  _x addEventHandler ["HitPart", {(_this select 0) select 0 setDamage 1; (_this select 0) select 0 animate ["terc", 1];}];
	} forEach _all;
};


if (isServer) then {
	[_hostiles, _hostages, _positions] execVM "scripts\room1\prepareRoom.sqf";
};
// prepareRoom.sqf

_hostiles = _this select 0;
_hostages = _this select 1;
_positions = _this select 2;

for "_i" from 0 to count _positions -1 do {
	_random = random [0,5,10];
	_hostile = selectRandom _hostiles;
	_hostage = selectRandom _hostages;
	_position = selectRandom _positions;
	_dir = getDir _position;
	
	if (_random > 5) then {
		_hostage setPos (getPos _position);
		_hostage setDir _dir;
		_hostage setDamage 0; _hostage animate["terc", 0];
		_hostages deleteAt (_hostages find _hostage);
	
	} else {
		_hostile setPos (getPos _position);
		_hostile setDir _dir;
		_hostile setDamage 0; _hostile animate["terc", 0];
		_hostiles deleteAt (_hostiles find _hostile);
	};

	_positions deleteAt (_positions find _position);
};

 

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  

×