Jump to content
celludriel

AddAction on vehicle not working on dededicated server setup

Recommended Posts

I had my entire mission working on a local server, but this dedicated server crap is being the death of me really, wth did bohemia had to make those two server instances so different ???  Ok here goes, I have two vehicles in my mission for the sake of argument they are called MHQ1 and MHQ2

 

Now I have following scripts

 

mhq_init.sqf

diag_log format ["Executing mhq_init.sqf with %1", _this];

if(isServer) then {
    diag_log format ["Setting up MHQ on server"];
    mhqList = _this select 0;
    if(isnil("mhqList")) exitWith {diag_log format ["ERROR: No mhq list given"]};

    {
        _x execVM "scripts\mhq\mhq_respawn_init.sqf";
    }forEach mhqList;
};

diag_log format ["Completed mhq_init.sqf with %1", _this];

mhq_respawn_init.sqf

_this setVariable ["MhqDeployed", false, true];
_this addAction ["Deploy", {[[[_this select 0, _this select 2], "scripts\mhq\mhq_deploy_action.sqf"], "BIS_fnc_execVM", true, true] call BIS_fnc_MP;},nil,1.5,true,true,"","{alive _x} count crew _target == 0"] spawn BIS_fnc_MP;
_this addMPEventHandler ["MPKilled", { _respawnId = (_this select 0) getVariable "RespawnId";
                                       _respawnId call BIS_fnc_removeRespawnPosition;}];
_this addMPEventHandler ["MPRespawn", {_this addAction ["Deploy", "scripts\mhq\mhq_deploy_action.sqf"];}];

mhq_init.sqf gets called in initserver.sqf with : _handle = [[MHQ1,MHQ2]] execVM "scripts\mhq\mhq_init.sqf";

 

Now I know add action is a local command so I added spawn BIS_fnc_MP, but when I startup my dedicated server and join it the deploy action is not on the vehicles.  When I start a local server ... it's there and working as it should.  What am I missing here ?

Share this post


Link to post
Share on other sites

This is a sample code i'm using for addaction when it run on server.

 

init.sqf

fnc_addaction_rescue_hostage = {
_target = (_this select 0);
_target addaction ["<t color='#E61616'>Secure Hostage</t>", "Human_resourceF\rescue_hostage\mps_unit_join.sqf",[0],1,false,true,"","((_target distance _this)<5)"]
};

and call it with this

[[_hostage],"fnc_addaction_rescue_hostage", true,true] call BIS_fnc_MP;

 

  • Like 1

Share this post


Link to post
Share on other sites

 

This is a sample code i'm using for addaction when it run on server.

 

init.sqf

fnc_addaction_rescue_hostage = {
_target = (_this select 0);
_target addaction ["<t color='#E61616'>Secure Hostage</t>", "Human_resourceF\rescue_hostage\mps_unit_join.sqf",[0],1,false,true,"","((_target distance _this)<5)"]
};

and call it with this

[[_hostage],"fnc_addaction_rescue_hostage", true,true] call BIS_fnc_MP;

Thanks I'll give it a shot !

Share this post


Link to post
Share on other sites

Your setup doesn't work, because you never execute addAction on a non-server. I can tell you that it doesn't work on local-host either. No client will have have that action.

 

 

mhq_init.sqf

diag_log format ["Executing mhq_init.sqf with %1", _this];

mhqList = _this select 0;

if(isnil("mhqList")) exitWith {diag_log format ["ERROR: No mhq list given"]};

{
    _x call compile preprocessFileLineNumbers "scripts\mhq\mhq_respawn_init.sqf";
}forEach mhqList;

diag_log format ["Completed mhq_init.sqf with %1", _this];

mhq_respawn_init.sqf

_this setVariable ["MhqDeployed", false];
_this addAction ["Deploy", {[_this select 0, _this select 2] call compile preprocessFileLineNumbers "scripts\mhq\mhq_deploy_action.sqf"},nil,1.5,true,true,"","{alive _x} count crew _target == 0"];
_this addEventHandler ["Killed", { _respawnId = (_this select 0) getVariable "RespawnId";
                                       _respawnId call BIS_fnc_removeRespawnPosition;}];
_this addEventHandler ["Respawn", {_this addAction ["Deploy", "scripts\mhq\mhq_deploy_action.sqf"];}];

There is no reason to do any remote execution commands (like MPKilled, setVariable public) when you simply remove the redundant isServer check.

  • Like 1

Share this post


Link to post
Share on other sites

Unfourtunatly it didn't work :(

 

I refactored the code to

diag_log format ["Executing mhq_init.sqf with %1", _this];

if(isServer) then {
    diag_log format ["Setting up MHQ on server"];
    call compileFinal preprocessFileLineNumbers "scripts\mhq\mhq_respawn_init.sqf";

mhqList = _this select 0;
    if(isnil("mhqList")) exitWith {diag_log format ["ERROR: No mhq list given"]};

    {
	[[_x],"mhqRespawnInit", true,true] call BIS_fnc_MP;
    }forEach mhqList;
};

diag_log format ["Completed mhq_init.sqf with %1", _this];
mhqRespawnInit = {
	diag_log format ["Calling mhqRespawnInit, with %1", _this];

	_vehicle = _this select 0;
	_vehicle setVariable ["MhqDeployed", false, true];
	_vehicle addAction ["Deploy", {[[[_this select 0, _this select 2], "scripts\mhq\mhq_deploy_action.sqf"], "BIS_fnc_execVM", true, true] call BIS_fnc_MP;},nil,1.5,true,true,"","{alive _x} count crew _target == 0"];
	_vehicle addMPEventHandler ["MPKilled", { _respawnId = (_this select 0) getVariable "RespawnId";
	                                       _respawnId call BIS_fnc_removeRespawnPosition;}];
	_vehicle addMPEventHandler ["MPRespawn", {_this addAction ["Deploy", "scripts\mhq\mhq_deploy_action.sqf"];}];
};

But the result remained the same the Deploy action is not on the vehicle when I join my server :(  I'm wondering if my objects are actually know in the initserver.sqf stage of the initialitation of the mission ???

Share this post


Link to post
Share on other sites

Your setup doesn't work, because you never execute addAction on a non-server. I can tell you that it doesn't work on local-host either. No client will have have that action.

 

There is no reason to do any remote execution commands (like MPKilled, setVariable public) when you simply remove the redundant isServer check.

 

I see so when I tested it with a local server it just worked because I was the only one there , if anyone would have joined he wouldn't have had the deploy action.  Thanks I'll try to understand your corrections so I don't make that mistake in future scripts

Share this post


Link to post
Share on other sites

K small follow up I removed my Respawn eventhandler since I realised the script I was using respawning vehicles deletes the old one and creates a new one, ofcourse respawn eventhandling will not work then.  So I moved the respawn to the init of the vehicle in the editor.  However now the game is complaining about a missing ] while I counted them and they are all there ...  So unless I can't count anymore .. WTH ... ???

		class Item0
		{
			position[]={2110.2554,6.254447,5716.4766};
			azimut=107;
			special="NONE";
			id=2;
			side="EMPTY";
			vehicle="B_MRAP_01_hmg_F";
			skill=0.60000002;
			text="MHQ1";
			init="veh = [this, 30, 0, 0, FALSE, ""[[_this, ""scripts\mhq\mhq_respawn_init.sqf""], ""BIS_fnc_execVM"", true, true] call BIS_fnc_MP""] execVM ""scripts\vehicle_respawns.sqf""";
		};

10:48:42 Error in expression < = [this, 30, 0, 0, FALSE, "[[[_this], "scripts\mhq\mhq_respawn_init.sqf"], "BIS>
10:48:42   Error position: <scripts\mhq\mhq_respawn_init.sqf"], "BIS>
10:48:42   Error Missing ]

Share this post


Link to post
Share on other sites

Try use LARROW'S NSLVR vehicle respawn script. it works  with addaction and JIP in MP.

 

I'll keep that under advisement since on a local server the respawn script I was using was working fine.  It's just now that I start thinkering with letting it work on a dedicated it's all going tits up.  In principle my code line should work fine, but he keeps on bitching about a missing ]  ...  There is no missing ] if you read the line :(

 

Ok update:

 

it had to do with escaping I suppose since when I got in the editor itself instead of just the file I noticed the unescaped "

 

init="veh = [this, 30, 0, 0, FALSE, ""[[_this, """"scripts\mhq\mhq_respawn_init.sqf""""], """"BIS_fnc_execVM"""", true, true] call BIS_fnc_MP""] execVM ""scripts\vehicle_respawns.sqf""";

 

so I changed it to this, and now it starts up and all but he starts complaining about script not found grrrrrrrr and he doesn't even say what script and all the scripts are THERE ! this dedicated server crap is really really REALLY getting under my skin

 

Seems the error is in the following executing code

fnc_setVehicleInit = {
        private ["_netID","_unit","_unitinit"];

        _netID    = _this select 0;
        _unit     = objectFromNetID _netID;
        _unitinit = _this select 1;
        diag_log format ["_unitInit with %1", _unitinit];

        _unit call compile format ["%1",_unitinit];
};

12:14:34 "_unitInit with [[_this, "scripts\mhq\mhq_respawn_init.sqf"], "BIS_fnc_execVM", true, true] call BIS_fnc_MP"
12:14:34 Warning Message: Script  not found

Share this post


Link to post
Share on other sites

It seams to be little too complicated, i  mean the remote execute script as params for another one.

 

Try this maybe will work

[[[[this,[ 30, 0, 0, FALSE, _this]], "scripts\mhq\mhq_respawn_init.sqf"], "BIS_fnc_execVM", true, true] call BIS_fnc_MP;] execVM "scripts\vehicle_respawns.sqf";

Share this post


Link to post
Share on other sites

Sadly that didn't get it going either ...  Maybe I have to escape stuff even more because I go deeper and deeper in functions with the String I'm really surprised I couldn't get this working yet.

fnc_setVehicleInit = {
        private ["_netID","_unit","_unitinit"];

        _netID    = _this select 0;
        _unit     = objectFromNetID _netID;
        _unitinit = _this select 1;
        diag_log format ["_unitInit with %1", _unitinit];

        _unit call compile format ["%1",_unitinit];
};

12:14:34 "_unitInit with [[_this, "scripts\mhq\mhq_respawn_init.sqf"], "BIS_fnc_execVM", true, true] call BIS_fnc_MP"
12:14:34 Warning Message: Script  not found

I can guarantee the script is in that location, maybe I'll need to use single quotes or something ... I'll try again when I get home today from work , but this is aaaaaaaargh nerve wrecking, especially if you know this all worked on my local server setup :(

Share this post


Link to post
Share on other sites

I finally found it !!!

[[[_this], "scripts\mhq\mhq_respawn_init.sqf"], "BIS_fnc_execVM", true] call BIS_fnc_MP

You always have to call the script with the parameters in an array, even if you just have one parameter.  Took me a while and a lot of server restartups to find this little gem out ...

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

×