Jump to content
Sign in to follow this  
cds1984

local vehicle move problem from addaction in sqf

Recommended Posts

I have been attempting to get this to work for a couple of days and while I can get it to work on the editor preview and testing from multiplayer on the same machine, on a dedicated server it refuses to work...

That being said here is what I have.

an addaction on an object that calls a script which moves a vehicle to another position.

//Marker named "THERE" placed.

//init on object.
this addaction ["TRANSPORT","chopper.sqf",[this,"THERE"],1,false,true,"","true"];

//chopper.sqf
_from = getMarkerPos format["%1",(_this select 3) select 0];
_to = getMarkerPos format ["%1",(_this select 3) select 1];
//Named vehicle
_veh = CHOPPER1;

if (alive _veh) then
{
 _veh move _to;
};

The result being I can hear the chopper pilot saying "move to coordinates ..." but the chopper doesn't start it's engines.

I did try setting the engines to always be on and the result is the chopper figits about like it is being held in place by an invisible tether.

I can see that the problem is the move command is not 'local' to the object because the source of the command is the MP client and I'm having a hard time making the ownership get moved from remote to local, from the addaction.

Any help would be great! no ... fantastic!

Share this post


Link to post
Share on other sites

I should have mentioned that the end product also includes

_veh land "LAND";

using addwaypoint moves it but for some reason it introduces the problem of it not landing and stopping without using the 'getout' waypoint aswell.

So if i use "getout" and land it on top of a building my crew gets out and walks off the side to it's death! Which is a lot of fun but not really what I was after.

Share this post


Link to post
Share on other sites

Worked out a way around it... a bit funky but here it is.

Have a listener which runs on the server waiting for the publicvariable to change from a default state and when it does push the value of the variable to the script which then does the work.

Very convoluted but it works on MP dedicated.

Here is the example.

init.sqf

nul = execVM "listener.sqf";

listener.sqf

TRANSPORT = "READY";
while {isServer && alive CHOPPER1} do
{
 if (TRANSPORT != "READY") then
 {
   [TRANSPORT] execVM "go.sqf";
 };
 TRANSPORT = "READY";
 sleep 2;
};

go.sqf

_destination = getMarkerPos format ["%1",_this select 0];
_veh = CHOPPER1;
_veh move _destination;

while {!unitReady _veh} do
{
 sleep 1;
};
_veh land "LAND";
TRANSPORT = "READY";
publicVariable "TRANSPORT";

call.sqf

_args = (_this select 3) select 0;
TRANSPORT = _args;
publicVariable "TRANSPORT";

object initialisation.

this addaction ["TRANSPORT","call.sqf",["HERE"]];

destination marker name = "HERE"

Edited by cds1984

Share this post


Link to post
Share on other sites

You only need that some units move to some position if you use the action? If yes, I don't understand whats your problem

//Marker named "THERE" placed.

//init on object.

this addaction ["TRANSPORT","chopper.sqf",[this,"THERE"],1,false,true,"","true"];

//chopper.sqf

_from = getMarkerPos format["%1",(_this select 3) select 0];

_to = getMarkerPos format ["%1",(_this select 3) select 1];

//Named vehicle

_veh = CHOPPER1;

if (alive _veh) then

{

_veh move _to;

};

this addaction ["TRANSPORT","chopper.sqf",[this,"THERE"],1,false,true,"","true"];

in script it would be:

_Who = (_this select 3) select 0;

_Pos = (_this select 3) select 1;

_Who move getMarkerPos _Pos;

Share this post


Link to post
Share on other sites

purpose is for a client to move a helicopter to a point using an addaction.

basically addaction is on a satellite phone which has the options of sending a helicopter to a range of markers and if you are not at the marker with the helicopter already at it, it will come to you, land and then go to the marker you chose and land again.

The problem is move is a localised function.

So if it is called by a remote host it is not executed on the local host where the local object is, unless they are the same physical machine and not a dedicated server.

If i create a trigger on the server to run the same script it will succeed but an addaction pushing from a remote host will not, on a dedicated server.

Edited by cds1984
clarification

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  

×