Jump to content

Recommended Posts

I've been trying to get some basic set up stuff working on some units and objects but I've forgotten most of what I knew about ARMA/OFP scripting.

 

Problem 1

I want to add an alive tablet and some ACE earplugs to each player slot in my mission. I had put

this addItemToUniform "ACE_EarPlugs";this additem "alive_tablet";

in each of the unit's init's but while this works for a mission tested from editor or hosted from my ARMA instance, when run from a dedicated server I get multiples of the gear added. Clearly some sort of locality issue but how do I solve it.

 

Problem 2

I want to add some prefilled rucksacks and bags into some vehicles. This had mixed results in the first place, while I could see the bags I couldn't actually pick them up from the vehicles, except for one vehicle in particular. In dedicated MP now I can't see anything at all.

 

this addBackpackCargo ["rhs_medic_bag",5];this addBackpackCargo ["rhsusf_assault_eagleaiii_ocp",3];
{ if (typeof _x == "rhs_medic_bag") then {_x addItemCargo ["ACE_fieldDressing",20]; _x addItemCargo ["ACE_bloodIV",2]; _x addItemCargo ["ACE_epinephrine",5]; _x addItemCargo ["ACE_morphine",5]}; 
if (typeof _x == "rhsusf_assault_eagleaiii_ocp") then {_x addItemCargo ["ACE_Clacker",1];_x addItemCargo ["ACE_M26_Clacker",1];_x addItemCargo ["ACE_DefusalKit",1];_x addItemCargo ["DemoCharge_Remote_Mag",2];_x addItemCargo ["ClaymoreDirectionalMine_Remote_Mag",2]}; 
} forEach (everyBackpack this);";

 

Share this post


Link to post
Share on other sites

Thanks.

 

Problem 1

So I move the code from the init box to initPlayerLocal.sqf ? What relevance does naming the units have? Did something change in ARMA 3 from previous titles then, because I'm sure this used to work?

 

Problem 2

Thanks. I hadn't seen that there was a different command. However, this is still an init based script, won't the same thing as Problem 1 occur, that the vehicles will get a bunch of bags be added everytime someone joins the server?

 

Share this post


Link to post
Share on other sites
3 hours ago, charliereddog said:

Problem 1

So I move the code from the init box to initPlayerLocal.sqf ? What relevance does naming the units have? Did something change in ARMA 3 from previous titles then, because I'm sure this used to work?

No need to name them as initPlayerLocal gets passed the players unit in its params

//initPlayerLocal.sqf

params[ "_player", "_didJIP" ];

Then use _player to refer to the unit

 

3 hours ago, charliereddog said:

Problem 2

Thanks. I hadn't seen that there was a different command. However, this is still an init based script, won't the same thing as Problem 1 occur, that the vehicles will get a bunch of bags be added everytime someone joins the server?

Yes it will suffer from the same problem. Just rap it all in a if ( isServer ) check so that only the server adds the cargo globally at mission start.

Share this post


Link to post
Share on other sites

Thanks,

 

So my initPlayerLocal.sqf is saved in the mission folder, contains the two commands

_player addItemToUniform "ACE_Earplugs";
_player addItem "alive_tablet";

And that's all I need to do to solve problem one, having removed everything from the units init field in the editor?

 

Problem 2 is solved by making each vehicles init box contain this

if (isServer)
{
this addBackpackCargoGlobal ["rhs_medic_bag",5];
this addBackpackCargoGlobal ["rhsusf_assault_eagleaiii_ocp",3];
{ 
 if (typeof _x == "rhs_medic_bag") then {_x addItemCargo ["ACE_fieldDressing",20]; _x addItemCargo ["ACE_bloodIV",6]; _x addItemCargo ["ACE_epinephrine",5]; _x addItemCargo ["ACE_morphine",10]}; 
 
 if (typeof _x == "rhsusf_assault_eagleaiii_ocp") then {_x addItemCargo ["ACE_Clacker",1];_x addItemCargo ["ACE_M26_Clacker",1];_x addItemCargo ["ACE_DefusalKit",1];_x addItemCargo ["DemoCharge_Remote_Mag",2];_x addItemCargo ["ClaymoreDirectionalMine_Remote_Mag",2]}; 
 } forEach (everyBackpack this);
}

 

 

I'm off to test this now. Thanks for the help

Share this post


Link to post
Share on other sites

Yeah sorry no need to name the units, I was half awake. But you had it sorted, I wouldnt use an isServer check, just run that code in initServer.sqf - Less chance of a mix up, sorry about the half assed initial response lol.

Share this post


Link to post
Share on other sites

No worries - we've all been there! :)

 

I think problem 2 is sorted, but problem 1 persists. I'm not getting either the earplugs or the alive tablet. I've tried _player, player, _player=this select 0; None appear to work.

Share this post


Link to post
Share on other sites

initPlayerLocal.sqf

params[ "_player", "_didJIP" ]; //OR _player = _this select 0;

_player addItemToUniform "ACE_Earplugs";
_player addItem "alive_tablet";

 

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

×