Jump to content

Recommended Posts

Hey, I'm very new to scripting and am having trouble with something. I am making a multiplayer pvp/pve mission, and I want players to be able to call in an arsenal on their position when they need it. So I've used the base game "Supply drop support" to accomplish this, with the "crate init" field using this:

["AmmoboxInit",[_this,true]] call BIS_fnc_arsenal; 0 spawn {   sleep 30; };

Now the arsenal bit works perfectly, but I also want the crate to be deleted/destroyed after a set amount of time, to prevent them being everywhere, and also limit players ability to exploit having an arsenal beside them. I've tried a few different methods to do this, and looked online quite a bit, but can't figure it out. Im certain its something small I'm messing it up, but either way i cant figure it out. i've tried putting things like "deleteVehicle _this" and using a "_this setDamage 1" to break or delete the crate, with no luck. the error messages also dont make much sense to me, so any help is appreciated.

(In the "sleep" area is where ive been putting the delete commands)

 

As a side note, if anyone could help me easily delete the normal contents of the crate via scripting that would also be appreciated

Share this post


Link to post
Share on other sites
["AmmoboxInit",[_this,true]] call BIS_fnc_arsenal; _this spawn {sleep 30; deleteVehicle _this};

 

  • Like 3

Share this post


Link to post
Share on other sites
12 hours ago, Mr.clean132 said:

As a side note, if anyone could help me easily delete the normal contents of the crate via scripting that would also be appreciated

 

clearItemCargoGlobal _this; clearWeaponCargoGlobal _this; clearMagazineCargoGlobal _this; clearBackpackCargoGlobal _this;

 

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, pierremgi said:

clearItemCargoGlobal _this; clearWeaponCargoGlobal _this; clearMagazineCargoGlobal _this; clearBackpackCargoGlobal _this;

 

This is perfect, thanks for the help!

 

10 hours ago, POLPOX said:

["AmmoboxInit",[_this,true]] call BIS_fnc_arsenal; _this spawn {sleep 30; deleteVehicle _this};

 

This also works perfectly, thank you! i was trying almost this exact thing earlier but i may have mistyped something or misplaced a ";", either way, that fixed it. thank you

Share this post


Link to post
Share on other sites
1 hour ago, Mr.clean132 said:

i was trying almost this exact thing earlier

 

The syntax for spawn is 

Quote

arguments spawn code

 

Your code:

0 spawn {sleep 30;};

POLPOX's code:

_this spawn {sleep 30; deleteVehicle _this};

The problem is in the arguments. POLPOX passed the argument "_this", which when used in the supply drop module's crate init field refers to the crate itself (seen in the module's tooltips). This allows the spawned code to also refer to the crate through its own internal "_this." 

You passed "0," aka nothing, so the spawned code has no passed arguments and so can't access the crate through "_this."

 

I hope that's sort of clear?

  • Like 1

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

×