Jump to content
G-Virus

Waypoints don't work on dedicated server

Recommended Posts

Hello everyone! I have a problem with scripting for dedicated servers. I have a mission for Multiplayer, but there is an AI bot that should get in a helicopter and fly to some waypoint, land and get out. I used the following script for that and it worked. But I've tried to use it now and it works appropriately only in Eden Editor or hosted server.  Please help me what am I doing wrong. Also I'm trying to move an object (hedgehog) with the scripts presented below, but there is a strange behavior. They are rotating before move and are moving with delay.


I have this code in init.sqf file

Thank you in advance!

 

if (!isServer) then {
    border1 addAction ["<t color='#0000FF'>Lock western way</t>", { [] call moveToWest; }];
    pilot1 addAction ["<t color='#00FF00'>Go!</t>", { [] spawn goToAirport; }];
};

moveToEast = {
    removeAllActions border1;
    border1 addAction ["<t color='#0000FF'>Lock western way</t>", { [] call moveToWest; }];
    if (!isDedicated) exitWith {};
    [30, [], { 
 	border1 setPos [11310.616, 5955.567, 0]; 
	border1 setVectorDir [0.152, 0.764, 0];
    }, {}, "Moving blocks..."] call ace_common_fnc_progressBar;
};

moveToWest = {
    removeAllActions border1;
    border1 addAction ["<t color='#FF0000'>Lock eastern way</t>", { [] call moveToEast; }];
    if (!isDedicated) exitWith {};
    [30, [], {
      	border1 setPos [11280.235, 5917.037, 0];
	    border1 setVectorDir [359.389, 2.748, 285.230];
     }, {}, "Moving blocks..."] call ace_common_fnc_progressBar;
};

goToAirport = {
    removeAllActions pilot1;

    if (!isDedicated) exitWith {};

    pilot1 assignAsDriver helicopter1;
    [pilot1] orderGetIn true;
    waitUntil {pilot1 in helicopter1; };
    sleep 5;
    _grp = group pilot1;
    _wp1 = _grp addWaypoint [getMarkerPos "wmt_west_heli_target", 0];
    _wp1 setWaypointType "MOVE";
    _wp2 = _grp addWaypoint [getMarkerPos "wmt_west_heli_target", 0];
    _wp2 setWaypointType "GETOUT";
};

 

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

if (!isDedicated) exitWith {}; ????

 

I've tried different combinations with isServer, isDedicated. Doesn't work. Previous version that worked has contained only !isServer check, but now it doesn't work too. Could you suggest your variant?

Share this post


Link to post
Share on other sites

addAction runs the code locally on the caller's PC.

if (!isDedicated) exitWith {} literally means, if the player is not on server dedicated (there is no player on dedicated server, never), abort. So, this line is absolutely breaking the addAction. Furthermore, you don't need any version with isServer or isDedicated or else.

 

setPos will work anyway in your code (even locally and remote) because it's an arguments_global.gif  effects_global.gif command.

Same for addWaypoint... assignAsDriver...

 

On the other hand, setVectorDir is not so friendly. arguments_local.gif  effects_global.gif  , So you need to apply it on the local PC owning the object (could be server, could be a player). The best workable way is to remoteExec it on this PC (and this PC only) with, as example :  [border1,[359.389, 2.748, 285.230] ] remoteExec ["setVectorDir",border1] ;

Same for orderGetin, ...

 

I don't have any clue about ACE functions . I never ever use ACE.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

for quick edit:

//init.sqf

[] compile preprocessFileLineNumbers "functions.sqf";

if (hasInterface) then {
    border1 addAction ["<t color='#0000FF'>Lock western way</t>", { 0 = [] remoteExec ["fnc_moveToWest", 0, false]}];
    pilot1 addAction ["<t color='#00FF00'>Go!</t>", {0 = [] remoteExec ["fnc_goToAirport", 0, false]}];
};



//file functions.sqf
fnc_moveToWest = {
	if (hasInterface) then {
    removeAllActions border1;
    border1 addAction ["<t color='#FF0000'>Lock eastern way</t>", { 0 = [] remoteExec ["fnc_moveToEast", 0, false] }];
	};
    if (!isServer) exitWith {};
    [30, [], {
      	border1 setPos [11280.235, 5917.037, 0];
	    border1 setVectorDir [359.389, 2.748, 285.230];
     }, {}, "Moving blocks..."] call ace_common_fnc_progressBar;
};

fnc_moveToEast = {
	if (hasInterface) then {
    removeAllActions border1;
    border1 addAction ["<t color='#0000FF'>Lock western way</t>", { 0 = [] remoteExec ["fnc_moveToWest", 0, false] }];
	};
    if (!isServer) exitWith {};
    [30, [], { 
 	border1 setPos [11310.616, 5955.567, 0]; 
	border1 setVectorDir [0.152, 0.764, 0];
    }, {}, "Moving blocks..."] call ace_common_fnc_progressBar;
};

fnc_goToAirport = {

	if (hasInterface) then {removeAllActions pilot1};
	if (!isServer) exitWith {};

    pilot1 assignAsDriver helicopter1;
    [pilot1] orderGetIn true;
    waitUntil {sleep 1; pilot1 in helicopter1};
    sleep 5;
    _grp = group pilot1;
    _wp1 = _grp addWaypoint [getMarkerPos "wmt_west_heli_target", 0];
    _wp1 setWaypointType "MOVE";
    _wp2 = _grp addWaypoint [getMarkerPos "wmt_west_heli_target", 0];
    _wp2 setWaypointType "GETOUT";
};

it could be cleaner than this, but not today...

  • Like 1

Share this post


Link to post
Share on other sites
On ‎12‎.‎11‎.‎2018 at 11:22 PM, pierremgi said:

addAction runs the code locally on the caller's PC.

if (!isDedicated) exitWith {} literally means, if the player is not on server dedicated (there is no player on dedicated server, never), abort. So, this line is absolutely breaking the addAction. Furthermore, you don't need any version with isServer or isDedicated or else.

 

setPos will work anyway in your code (even locally and remote) because it's an arguments_global.gif  effects_global.gif command.

Same for addWaypoint... assignAsDriver...

 

On the other hand, setVectorDir is not so friendly. arguments_local.gif  effects_global.gif  , So you need to apply it on the local PC owning the object (could be server, could be a player). The best workable way is to remoteExec it on this PC (and this PC only) with, as example :  [border1,[359.389, 2.748, 285.230] ] remoteExec ["setVectorDir",border1] ;

Same for orderGetin, ...

 

I don't have any clue about ACE functions . I never ever use ACE.

 

 

 

Thank you for theory, it really helped! But I still have problem with the pilot - he is just ignoring orderGetIn call and futher code in the function. I've tried to replace it with one more waypoint "GETIN", but the pilot ignores it too and goes next waypoint :(
With hedgehog there is one  strange thing - now it works good with remoteExec, but it moves after some time when progress bar is finished, not immediately. And as I noticed it depends on count of players on server, probably...

And it still works perfect in editor, the problems only with dedicated server :(

here is my new code
 

if (hasInterface) then {
    border1 addAction ["<t color='#0000FF'>Lock western way</t>", { [] call fnc_moveToWest }];
    pilot1 addAction ["<t color='#00FF00'>Go!</t>", { [] call fnc_goToAirport }];
};

fnc_goToAirport = {
    if (hasInterface) then {removeAllActions pilot1};

    pilot1 assignAsDriver helicopter1;
    /*[[pilot1], true] remoteExec ["orderGetIn", pilot1];
    waitUntil {sleep 1; pilot1 in helicopter1};
    sleep 5;*/
    _grp = group pilot1;
    _wp1 = _grp addWaypoint [getMarkerPos "wmt_west_heli_base", 0];
    _wp1 setWaypointType "GETIN";
    _wp2 = _grp addWaypoint [getMarkerPos "wmt_west_heli_target", 0];
    _wp2 setWaypointType "MOVE";
    _wp3 = _grp addWaypoint [getMarkerPos "wmt_west_heli_target", 0];
    _wp3 setWaypointType "GETOUT";
};

fnc_moveToEast = {
    if (hasInterface) then {
        removeAllActions border1;
        border1 addAction ["<t color='#0000FF'>Lock western way</t>", { [] call fnc_moveToWest }];
    };

    [30, [], { 
 	border1 setPos [11310.616, 5955.567, 0]; 
	[border1, [0.152, 0.764, 0]] remoteExec ["setVectorDir", border1];
    }, {}, "Moving blocks..."] call ace_common_fnc_progressBar;
};

fnc_moveToWest = {
    if (hasInterface) then {
        removeAllActions border1;
        border1 addAction ["<t color='#FF0000'>Lock eastern way</t>", { [] call fnc_moveToEast }];
    };

    [30, [], {
      	border1 setPos [11280.235, 5917.037, 0];
	[border1, [359.389, 2.748, 285.230]] remoteExec ["setVectorDir",border1]; 
     }, {}, "Moving blocks..."] call ace_common_fnc_progressBar;
};

 

Share this post


Link to post
Share on other sites
On ‎12‎.‎11‎.‎2018 at 11:25 PM, davidoss said:

it could be cleaner than this, but not today...

 

Sorry, but your code doesn't work at all :(

Share this post


Link to post
Share on other sites
Just now, G-Virus said:

but it moves after some time when progress bar is finished,

As per the function you are using, code passed in param 2 is run once progress has completed.

Quote

/*

* Author: commy2, Glowbal, PabstMirror

* Draw progress bar and execute given function if succesful.

* Finish/Failure/Conditional are all passed [_args, _elapsedTime, _totalTime, _errorCode]

*

* Arguments:

* 0: Total Time (in game "time" seconds) <NUMBER>

* 1: Arguments, passed to condition, fail and finish <ARRAY>

* 2: On Finish: Code called or STRING raised as event. <CODE, STRING>

* 3: On Failure: Code called or STRING raised as event. <CODE, STRING>

 

Here is a test mission making your actions MP dedicated and JIP compatible. I have left your original positions/vector directions for border1, so in the test mission border1 is underground but should work properly if copied over to your mission.

  • Thanks 1

Share this post


Link to post
Share on other sites
54 minutes ago, Larrow said:

Here is a test mission making your actions MP dedicated and JIP compatible. I have left your original positions/vector directions for border1, so in the test mission border1 is underground but should work properly if copied over to your mission.

 Thank you very much for your time, your code finally works! Finally this fucking bot is getting in helicopter and goes right way :)  But it still moves blocks not properly - it moves that first and then runs progress bar with empty body, therefore it moves immediately and then runs progress bar with dummy action :) and in this case a player can't cancel the action. I've put the code that moves blocks into progress bar's handler of success, and it works very good on host, but still has this weird delay between commands execution and physical movement on dedicated server. Do you know what is happening?

Share this post


Link to post
Share on other sites
Just now, G-Virus said:

up

Twice? Don't!

If you have a personal question about a specific script (test mission), please ask the author in PM. "Up" are no added value for readers here. If your question is related to your post, so refresh the code at least.

In other words, let this thread understandable if you want an answer. If no answer, don't push it up.

  • Like 1

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

×