Jump to content

Recommended Posts

When I put the arsenal call function in the init field of a vehicle (a truck for example), the arsenal functions normally...

...up until the point where the vehicle is destroyed.

 

Is there a way I can be able to have the arsenal script automatically placed onto the example truck after it is destroyed and respawns?

Share this post


Link to post
Share on other sites

There should be an init expression field in the vehicle respawn module that gets executed when the vehicle respawns. you use "this" or "_this" (cant remember which one) to reference the vehicle that is spawning.

Share this post


Link to post
Share on other sites

Putting   0 = ["AmmoboxInit",[this,true]] spawn BIS_fnc_arsenal;   in the Init of the truck and the respawn module doesn't respawn the arsenal when the truck comes back.  Tried both.

Share this post


Link to post
Share on other sites

When you use the expression field of the Respawn Module, you should name your vehicle.

 

init of vehicle named veh01

0 = ["AmmoboxInit",[this,true]] spawn BIS_fnc_arsenal;

Expression field of the Vehicle Respawn Module

0 = ["AmmoboxInit",[veh01,true]] spawn BIS_fnc_arsenal;

Share this post


Link to post
Share on other sites

You need to define the respawned veh first.

The expression should be executed only once (on server)

it means you need to remoteexec arsenal to players

Share this post


Link to post
Share on other sites

How do I adjust this to include more than one vehicle/ojbect?  I tried   0 = ["AmmoboxInit",[[vic1,vic2],true]] spawn BIS_fnc_arsenal;   and it didn't work.  Thanks.

Share this post


Link to post
Share on other sites


0 = ["AmmoboxInit",[vic1,true]] spawn BIS_fnc_arsenal;0 = ["AmmoboxInit",[vic2,true]] spawn BIS_fnc_arsenal;

Share this post


Link to post
Share on other sites

0 = {["AmmoboxInit",[_x,true]] spawn BIS_fnc_arsenal} foreach [veh01,veh02,veh03];

Share this post


Link to post
Share on other sites

0 = {["AmmoboxInit",[_x,true]] spawn BIS_fnc_arsenal} foreach [veh01,veh02,veh03];

Works perfectly, thank you!

Share this post


Link to post
Share on other sites

Works perfectly, thank you!

Best practice is to use the expression field of vehicle respawn:

["AmmoboxInit",[(_this select 0),true,{true}]] spawn BIS_fnc_arsenal;

(_this select 0) refers to the new vehicle that is being respawned. the method you are praising may lead to issues down the road.

Share this post


Link to post
Share on other sites

Question(s): What about for his use with multiple vehicles? What sort of issues?

 

Best practice is to use the expression field of vehicle respawn:

["AmmoboxInit",[veh01(_this select 1)]] spawn BIS_fnc_arsenal;

(_this select 1) refers to the new vehicle that is being respawned. the method you are praising may lead to issues down the road.

Share this post


Link to post
Share on other sites

benargee, yes please elaborate.  And can this be used for multiple vehicles/objects?  Thanks.

Share this post


Link to post
Share on other sites

Yes, sorry. I made a few corrections to my post, syntax was off. For use with multiple vehicles, it works and it does so automatically. The expression field in the vehicle respawn module gets called every time it respawns a vehicle that it was synced to. _this  select 0 refers to the vehicle that was created by the respawn to replace the old destroyed or abandoned one. It passes [<new vehicle>, <old vehicle>] to the expression field.
Since the expression field gets called every time each vehicle respawns, including all vehicles in the call can create issues. In this case it doesn't because arsenal can only be initialized once. The reason this is bad is because it will create a bad practice to use that method for other script to be called. You will end up calling code more than it needs to be. Say you want to add a certain amount of weapons to the newly respawned vehicles cargo. As soon as another vehicle is respawn, all vehicles will have that weapon cargo added AGAIN and will go above the limit you intended them to have. This is only one example. It's not horrible but it's unintended behavior and might just cause users to ask more questions without understanding why this is happening. I'm just trying to address this before it becomes a problem for many people.

 

For even greater flexibility and automation, add this to the init field

{
 ["AmmoboxInit",[(_x),true,{true}]] spawn BIS_fnc_arsenal;
} forEach synchronizedObjects this;

This will automatically add arsenal to all objects that were synced from the start. You wont have to add code to every vehicle's init field manually any more. This is useful since "Expression" only gets called after a vehicle is respawned and not on the original. "this" refers to the vehicle respawn module. "synchronizedObjects this" refers to all objects that were synced to it for respawn.

 

Ja2rHD2.pngyW0r7Dv.png

dcYK6Bl.png

 

Hope that explains it

Share this post


Link to post
Share on other sites

Can someone help me? I tried all the ways from when my spawn vehicle returned with the arsenal. I can not do it. please help me

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

×