Jump to content
Sign in to follow this  
Johnson11B2P

What's the new setVehicleInit command?

Recommended Posts

Now that setVehicleInit is gone due to security reason, the wiki has told me to use this instead. https://community.bistudio.com/wiki/BIS_fnc_MP

Now check out my code here

///Original Code

_unit_0 = objNull;
if (true) then
{
 _this = _group_0 createUnit ["O_Soldier_AR_F", [6412.8701, 5416.6538], [], 0, "NONE"];
 _unit_0 = _this;
 _this setDir 24.95896;
 _this setVehicleVarName "su";
 su = _this;
 _this setVehicleAmmo 0;
 _this setVehicleInit "this disableAI ""MOVE""; this setunitpos ""MIDDLE"";";
 _this setUnitAbility 0.60000002;
 if (true) then {_group_0 selectLeader _this;};
};
////////////////////////////////////////////////////////////////////////////////

How can the BIS_fnc_MP make this single unit do what is in the vehicleInit?

Edited by [FRL]Myke
CODE tags added ;)

Share this post


Link to post
Share on other sites

Try this in the editor debugger (A3 dev version):

position 1862.41,5762.52, 0.00143862 will spawn the unit infront of the air traffic control building at the airbase

_unit = objNull;
_grp = createGroup east;
       _unit = _grp createUnit ["O_Soldier_AR_F", [1862.41,5762.52,0.00143862], [], 0, "NONE"];
_grp selectLeader _unit;
_unit setUnitAbility 0.60000002;
       _unit setDir 24.95896;
       _unit setVehicleVarName "su";
       _unit setVehicleAmmo 0;
_initinit = format["[{%1 setunitpos '%2'; %1 disableAI '%3';}]", _unit, "MIDDLE", "MOVE"]; 
[call compile format["%1",_initinit],"BIS_fnc_spawn", true, false] spawn BIS_fnc_MP; 
_unit call compile format ["%1=_this; publicvariable '%1'",_unit]; 

If it's for multiplayer on a dedicated you could try it with the new Arma3 netId/objectFromNetId commands, it won't return an id if you test this in the editor (shame):

_unit = objNull;
_grp = createGroup east;
       _unit = _grp createUnit ["O_Soldier_AR_F", [1862.41,5762.52,0.00143862], [], 0, "NONE"];
_grp selectLeader _unit;
       _unitname = "su";
_initinit = format["[{
(objectFromNetId '%1') setVehicleVarName '%4'; 
(objectFromNetId '%1') setunitpos '%2'; 
(objectFromNetId '%1') disableAI '%3';
(objectFromNetId '%1') setVehicleAmmo %5;
(objectFromNetId '%1') setUnitAbility %6;
(objectFromNetId '%1') setDir %7;
}]", (netId _unit), "MIDDLE", "MOVE", _unitname, 0, 0.60000002, 24.95896]; 
[call compile format["%1",_initinit],"BIS_fnc_spawn", true, false] spawn BIS_fnc_MP; 
_unit call compile format ["%1=_this; publicvariable '%1'", _unitname]; 

References:

http://community.bistudio.com/wiki/netId

http://community.bistudio.com/wiki/objectFromNetId

https://community.bistudio.com/wiki/BIS_fnc_MP

http://community.bistudio.com/wiki/publicVariable

Edited by [KH]Jman

Share this post


Link to post
Share on other sites

Jman thanks for the help. The unit spawned!!! but it shot me -__-. Could you explain further on the _initinit code and below. Like what is the %1 and how did you come up with the other %'s.

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  

×