Jump to content
Sign in to follow this  
lawndartleo

[QUESTION] Passing an init field to a respawned vehicle

Recommended Posts

So I have a vehicle with an addaction in its init field, which works just fine until that vehicle is destroyed.  That vehicle is synched to a respawn module.  Is there a straight forward way to pass the old vehicle init to the new vehicle?  I have been reading this post (https://forums.bistudio.com/topic/193240-vehicle-respawn-with-addaction-on-dedicated-server/?p=3074690) but it's all  rather arcane to me. There is also the "expression" field in the module but I find no documentation that explains its use on the BIS ArmA wiki.

 

Some direction would be much appreciated.  Thanks!

 

The init for reference...

this addAction ["Push","pushboat.sqf",[],-1,false,true,"","_this distance _target < 8"];

What I think it should be but doesn't work...

I have no idea how to delete this box so just ignore it
if (isServer) then {
      params [["_newVeh", objNull], ["_oldVeh", objNull]];
  
   switch (typeOf _newVeh) do {
  
  case "B_Boat_Transport_01_F": {
        
   [_newVeh, ["Push", {  _this exec "pushboat.sqf",[],-1,false,true,"","_this distance _target < 8";  }]] remoteExec ["addAction", 0, _newVeh];
  };
  
  case "B_SDV_01_F": {
        
   [_newVeh, ["Push", {  _this exec "pushboat.sqf",[],-1,false,true,"","_this distance _target < 8";  }]] remoteExec ["addAction", 0, _newVeh];
  };
  
  case "B_Boat_Armed_01_minigun_F": {
   
   [_newVeh, ["Push", {  _this exec "pushboat.sqf",[],-1,false,true,"","_this distance _target < 8";  }]] remoteExec ["addAction", 0, _newVeh];
  };
  
  default {};
  
   };
};
... this one, too.

Share this post


Link to post
Share on other sites

Well... on a hunch I put all that in the expression box instead of the init box of the respawn module.  I guess that size does not matter.  Little box with lots of text works just fine.

 

Anyhow, it's working but I get a "Error generic error in expression" on this line of the script that is triggered by the addaction...

if (currentWeapon _Soldier == "") then {sleep 1;} else {sleep 2;};

... where there is no error until the boat has been respawned after sinking it.  Everything works... at least locally.  Any advice on the error, though?

 

For reference, the full script being called...

/*
Boat push script - v0.1
Pushes the boat in the direction the player is looking
this addAction ["<t color='#FF9900'>Push</t>","scripts\pushboat.sqf",[],-1,false,true,"","_this distance _target < 8"];
Created by BearBison
*/

if (isDedicated) exitwith {};
private ["_Object","_Soldier","_isWater"];
_Object = _this select 0;
_Soldier = _this select 1;
_isWater = surfaceIsWater position _Soldier; 
if (_isWater) exitwith {titleText ["You can't push from in the water","PLAIN DOWN",1];};
if (_Soldier in _Object) exitwith {titleText ["You can't push from inside the vehicle","PLAIN DOWN",1];};
_Object setOwner (owner _Soldier);
_Soldier playMove "AmovPercMstpSnonWnonDnon_AinvPercMstpSnonWnonDnon_Putdown";
if (currentWeapon _Soldier == "") then {sleep 1;} else {sleep 2;};
_Object setVelocity [(sin(direction _Soldier))*3, (cos(direction _Soldier))*3, 0];  

Share this post


Link to post
Share on other sites

Go try beaching a boat.  Seems it cant be done any more.  So all the effort was for nothing, but it was a good learning experience.

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  

×