Jump to content
Cooks Corner

Custom ammo box contents when spawned

Recommended Posts

I have a script for spawning ammo boxes during the mission but id like to change the contents of the boxes spawned but have no idea where to start

 

this is the script im using to spawn the boxes ammo_spawn is the spawners variable this is just something i found on the forums i dont really know how to script 

 

ammo_spawn addAction
[
    "Spawn Ammobox",
    {
        createVehicle ["Box_NATO_Ammo_F",position ammo_spawn, [],10,"NONE"];
    }
]

Share this post


Link to post
Share on other sites
2 hours ago, CuckMe said:

I have a script for spawning ammo boxes during the mission but id like to change the contents of the boxes spawned but have no idea where to start

 

You're best posting your script to get some help.

Share this post


Link to post
Share on other sites

Place the box on the map with the correct contents. Then teleport the box to the destination via a trigger.

Share this post


Link to post
Share on other sites
On 9/19/2022 at 3:24 AM, Maff said:

 

You're best posting your script to get some help.

good point 

Share this post


Link to post
Share on other sites
On 9/19/2022 at 2:10 AM, Cooks Corner said:

I have a script for spawning ammo boxes during the mission but id like to change the contents of the boxes spawned but have no idea where to start

 

 

Do your code works with position ammo_spawn?  What is ammo_spawn? (an object perhaps?, not a marker, not a position)

Once this point cleared, just modify your code like this:

you just have to change the content like this:

 

ammo_spawn addAction
[
    "Spawn Ammobox",
    {
        private _box = createVehicle ["Box_NATO_Ammo_F",position ammo_spawn, [],10,"NONE"];  // _box is the local variable name of your box
        clearMagazineCargoGlobal _box; //  empty the box if you don't need all the vanilla mags (you can't subtract one specific mag)
        {_box addItemCargoGlobal _x} forEach [["30Rnd_45ACP_Mag_SMG_01",50],["3Rnd_HE_Grenade_shell",24],["HandGrenade",6],....]; // Example. Works also for weapons, vests, uniforms but backpacks. Use addBackpackCargoGlobal for backpacks
    }
];

 

Note: you can set any box in editor for easily identifying the content. You can copy it from debug console in preview. Launch the game. As player, point at your custom crate, open debug console (esc) then write:

copyToClipboard str (getMagazineCargo cursorObject + getWeaponCargo cursorObject + getItemCargo cursorObject + getBackpackCargo cursorObject);
You'll obtain something like:

[["30Rnd_65x39_caseless_mag","16Rnd_9x21_Mag","HandGrenade"],[24,6,6],["arifle_CTARS_blk_Pointer_F","arifle_MSBS65_Mark_camo_F","arifle_MX_SW_khk_Pointer_F","launch_O_Vorona_green_F"],[3,3,2,2],["U_I_C_Soldier_Bandit_1_F","H_HelmetSpecO_ghex_F","ItemGPS","FirstAidKit"],[1,2,2,4],["B_AssaultPack_eaf_F"],[2]]

 

Now you can write by hand all stuff in format:

[["30Rnd_65x39_caseless_mag",24],["16Rnd_9x21_Mag",5],["HandGrenade",6],["arifle_CTARS_blk_Pointer_F",3],["arifle_MSBS65_Mark_camo_F",3],...] like I did in example for addItemCargoGlobal.

Note: ["B_AssaultPack_eaf_F",2] will work only with addBackpackCargoGlobal

 

 

 

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

 

Do your code works with position ammo_spawn?  What is ammo_spawn? (an object perhaps?, not a marker, not a position)

Once this point cleared, just modify your code like this:

you just have to change the content like this:

 


ammo_spawn addAction
[
    "Spawn Ammobox",
    {
        private _box = createVehicle ["Box_NATO_Ammo_F",position ammo_spawn, [],10,"NONE"];  // _box is the local variable name of your box
        clearMagazineCargoGlobal _box; //  empty the box if you don't need all the vanilla mags (you can't subtract one specific mag)
        {_box addItemCargoGlobal _x} forEach [["30Rnd_45ACP_Mag_SMG_01",50],["3Rnd_HE_Grenade_shell",24],["HandGrenade",6],....]; // Example. Works also for weapons, vests, uniforms but backpacks. Use addBackpackCargoGlobal for backpacks
    }
];

 

Note: you can set any box in editor for easily identifying the content. You can copy it from debug console in preview. Launch the game. As player, point at your custom crate, open debug console (esc) then write:

copyToClipboard str (getMagazineCargo cursorObject + getWeaponCargo cursorObject + getItemCargo cursorObject + getBackpackCargo cursorObject);
You'll obtain something like:

[["30Rnd_65x39_caseless_mag","16Rnd_9x21_Mag","HandGrenade"],[24,6,6],["arifle_CTARS_blk_Pointer_F","arifle_MSBS65_Mark_camo_F","arifle_MX_SW_khk_Pointer_F","launch_O_Vorona_green_F"],[3,3,2,2],["U_I_C_Soldier_Bandit_1_F","H_HelmetSpecO_ghex_F","ItemGPS","FirstAidKit"],[1,2,2,4],["B_AssaultPack_eaf_F"],[2]]

 

Now you can write by hand all stuff in format:

[["30Rnd_65x39_caseless_mag",24],["16Rnd_9x21_Mag",5],["HandGrenade",6],["arifle_CTARS_blk_Pointer_F",3],["arifle_MSBS65_Mark_camo_F",3],...] like I did in example for addItemCargoGlobal.

Note: ["B_AssaultPack_eaf_F",2] will work only with addBackpackCargoGlobal

 

 

 

 

 

Hi thanks for the reply thats exactly what i was looking for. ammo_spawn is the object im using to scroll and spawn the boxes at my only other question would be do you know how to make them spawn in a pre defined area instead of around the ammo_spawn object?

Share this post


Link to post
Share on other sites
56 minutes ago, Cooks Corner said:

how to make them spawn in a pre defined area

 

The second element of the createVehicle array is the position where the object is to be created. Here, you are telling it to spawn on the position of the ammo_spawn object:

 

56 minutes ago, Cooks Corner said:

private _box = createVehicle ["Box_NATO_Ammo_F", position ammo_spawn, [], 10, "NONE"];

 

 

If you want it to spawn elsewhere, you just need to tell it where. You could give it exact coordinates:

private _box = createVehicle ["Box_NATO_Ammo_F", [123.45, 678.9, 0], [], 10, "NONE"];

or the position of a marker:

private _box = createVehicle ["Box_NATO_Ammo_F", getMarkerPos "nameOfYourSpawnMarker", [], 10, "NONE"];

or the position of a different object:

private _box = createVehicle ["Box_NATO_Ammo_F", position differentObjectVarName, [], 10, "NONE"];

and so on.

 

 

  • Like 2

Share this post


Link to post
Share on other sites
18 minutes ago, Harzach said:

 

The second element of the createVehicle array is the position where the object is to be created. Here, you are telling it to spawn on the position of the ammo_spawn object:

 

 

If you want it to spawn elsewhere, you just need to tell it where. You could give it exact coordinates:


private _box = createVehicle ["Box_NATO_Ammo_F", [123.45, 678.9, 0], [], 10, "NONE"];

or the position of a marker:


private _box = createVehicle ["Box_NATO_Ammo_F", getMarkerPos "nameOfYourSpawnMarker", [], 10, "NONE"];

or the position of a different object:


private _box = createVehicle ["Box_NATO_Ammo_F", position differentObjectVarName, [], 10, "NONE"];

and so on.

 

 

Absolutely perfect thanks again this had made life much easier 

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

×