Jump to content
Sign in to follow this  
behemeth

Scripts on Dedicated Server don't work properly

Recommended Posts

I'm currently trying to port my mission to COOP on a dedicated server. While doing this I encounter that the scripts I wrote for SP oder COOP on a non-dedicated server are not working for the dedicated server.

One example:

I'm trying to do a HALO insertion and use an addAction to the airplane my group is in with the following script attached:

if(!isDedicated) then
{
player action [ "eject", vehicle player];
sleep 0.1;
player setdir 0;
[player] exec "ca\air2\halo\data\Scripts\HALO_getout.sqs";
player setvelocity [120*0.8,0,0];
}

The "sleep 0.1" is mandatory otherwise I fall without a parachute. The setdir and setvelocity have no influence for the dedicated server (which is kinda annoying). When scripting for a non-dedicated server the single line [player, 1950] exec "ca\air2\halo\data\Scripts

\HALO_init.sqs"; suffices instead of ejecting and HALO_getout.

While this is strange enough, until now I was not able to convert the following script to a format that is working for a dedicated server

Version 1:
[code]
waitUntil {getPosATL player select 2 < 25};
if(isServer) then
{
_scatterHeight = -20;
{
if(!(isPlayer _x)) then
{
	// stupid AI drifts off several kms if not done
	_x addEventHandler ["HandleDamage", {false}]; 
	unassignvehicle _x;
	_x setpos [ (getMarkerPos "mrkrInsertion" select 0) + (random 40) - 20, (getMarkerPos "mrkrInsertion" select 1) + (random 40) - 20, 100 - _scatterHeight];
	_x flyinheight (100 - _scatterPos);
	_x setvelocity [(random 6)-3,(random 6)-3,0]; 
	[_x, (100 - _scatterHeight)] exec "ca\air2\halo\data\Scripts\HALO_init.sqs";
	_scatterHeight = _scatterHeight + 10;
}
} forEach units playerGroup;
}

Version 2:

if(isServer) then
{
        _scatterHeight = -20;
{
	if(!(isPlayer _x)) then
	{
		// stupid AI drifts off several kms if not done
		_x addEventHandler ["HandleDamage", {false}]; 
		unassignVehicle _x;
		sleep 1;
		_xChute = createVehicle ["Parachute_US_EP1", [(getMarkerPos "mrkrInsertion" select 0) + (random 40) - 20, (getMarkerPos "mrkrInsertion" select 1) + (random 40) - 20, 50 - _scatterHeight], [], 0, "FLY"];
		_xChute setPos [(getPos _xChute select 0), (getPos _xChute select 1),  50 - _scatterHeight];
		_xChute setDir (random 360);
		_x setPos [(getPos _xChute select 0), (getPos _xChute select 1),  50 - _scatterHeight];
		_x moveInDriver _xChute;
		_scatterHeight = _scatterHeight + 10;
	}
} forEach units playerGroup;
}

The goal of that script is to drop the AIs of the group near the landing place. Both works well for non-dedicated. For dedicated the chutes drop empty (in Version 2) and the AIs are falling of the airplane wherever the current location of that is.

I'd really appreciate some help in converting the second part to a dedicated server compatible format.

I'd also love to get some insight why the scripts for the dedicated server have to differ - is there a point of view making this reasonable?

Edited by Behemeth

Share this post


Link to post
Share on other sites

if using from addaction - change player in the script - make it a different variable

_dude = _this select 0;

remove (!is dedi) no need in this case - if again using from addaction

Share this post


Link to post
Share on other sites

Hello Mikie boy,

if using from addaction - change player in the script - make it a different variable

_dude = _this select 0;

remove (!is dedi) no need in this case - if again using from addaction

thank you. Since the action is attached to the aircraft I need to use _dude = _this select 1 as far as I understood; The first part works with your changes. Yet it didn't yield any improvement: the simple version with the HALO_init.sqf which works on non-dedicated server doesn't work with _dude = _this 1 either, and setVelocity/setDir is still being ignored.

Any idea on that - and of course on the second part where I place the AI?

(The second part is not executed via the Action, but when the aircraft activates a trigger by its position)

Edited by Behemeth

Share this post


Link to post
Share on other sites

setDir and setVelocity must be local to the unit that you're performing it on. If the player is the leader of a group, the AI is local to him and thus the server cannot do setDir and setVelocity commands on them. What you need to do is make sure that the player runs the script and not the server.

Share this post


Link to post
Share on other sites
setDir and setVelocity must be local to the unit that you're performing it on. If the player is the leader of a group, the AI is local to him and thus the server cannot do setDir and setVelocity commands on them. What you need to do is make sure that the player runs the script and not the server.

Hello cuel,

Is this also valid for setPos? This would explain why AI placing didn't work.

But for setDir and setVelocity: 1) I made sure it's not the dedicated server executing the script. 2) since it gets called by the player (it's an action) the server shouldn't execute it anyway.

Did I understand something wrong?

Share this post


Link to post
Share on other sites

No, setPos does not have to be local to the object you're performing it on.

If you're talking about the first script, it should work. Have you tried adding a simple hint to see if it actually runs?

The second script has an if (isServer) then {}; statement.

You're saying that setDir and setVelocity has no "influence" for the dedicated server, - I'm not quite following.

Share this post


Link to post
Share on other sites
Have you tried adding a simple hint to see if it actually runs?

I can confirm that both scripts run.

The second script has an if (isServer) then {}

I added this to have the AI ejection and placement only executed once. Especially for version 2 I would otherwise execute the script for every player and therefore create too many parachutes

If you're talking about the first script, it should work (...) You're saying that setDir and setVelocity has no "influence" for the dedicated server, - I'm not quite following.

The first script does work for SP or non-dedicated server:

- ejecting, halo, setDir and setVelocity

for dedicated server

- ejecting and halo works but I'm always looking in the same direction and having no velocity in x,y no matter what i set the setDir, setVelocity

The second script (both versions) for SP or non-dedicated server:

- ejecting, setPos, halo, setVelocity, setDir (all works perfect)

for dedicated server

- setPos doesn't work for AI's, they simply eject from the airplane and fall down where they ejected

Thanks for the help

Edited by Behemeth

Share this post


Link to post
Share on other sites

Maybe try this script. It's not ideal but should work and you should be able to combine it with an addAction.

Share this post


Link to post
Share on other sites

OK guys... the first mystery is "solved". It seems that the dedicated server is a rather slow-paced guy.

_requestingUnit = _this select 1;

_requestingUnit action [ "eject", vehicle _requestingUnit];
sleep 0.1;
_requestingUnit spawn bis_fnc_halo;
sleep 0.1;
_requestingUnit setvelocity [0,120*0.8,0];
_requestingUnit setdir 0;

With those sleeps all works as it should. The question why this sleep is needed is open though - and the question whether the script will now work an any dedicated server or if it may happen that some other dedi is slower than mine and would need a longer sleep.

Summing up it's not a very convenient solution. But better than none.

Maybe try this script. It's not ideal but should work and you should be able to combine it with an addAction.

Sadly that's not what I'm trying to do - this script will just eject the AIs, but I want to use setPos on them in order to avoid broad scattering of the group.

I will try to add sleeps randomly for the second problem now and see if I reach a constellation for which it works... :depressed:

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  

×