Jump to content

Forums Announcement

Read-Only Mode for Announcements & Changelogs

Dear Survivors, we'd like to inform you that this forum will transition to read-only mode. From now on, it will serve exclusively as a platform for official announcements and changelogs.

For all community discussions, debates, and engagement, we encourage you to join us on our social media platforms: Discord, Twitter/X, Facebook.

Thank you for being a valued part of our community. We look forward to connecting with you on our other channels!

Stay safe out there,
Your DayZ Team

Smokeydapot

Custom loadout Loose ammo

Recommended Posts

So i'm making some custom loadouts in the init.c file but i'm coming up against an issue and that is how to add an ammo stack other than the max rounds you get from a box of ammo.

I have been trying a similar method from the init file that adds a number of Rags E.g.

   itemEnt = itemTop.GetInventory().CreateInInventory("Ammo_308Win");
   if ( Class.CastTo(itemBs, itemEnt ) )
   itemBs.SetQuantity(0.5);

 

To hopefully create a stack of ten 308 rounds but this just creates a full stack of 20, I have also tried:

 itemBs.SetQuantity(10);

But this also creates a full stack of ammo, Does anyone have a solution that creates a stack of loose ammo other than a full box stack of ammo ?

Any help is appreciated.

Edited by Smokeydapot
fixed typo

Share this post


Link to post
Share on other sites

@aussie battler thanks for the reply but I already tried this method also with no success as this also creates a full stack of 20 rounds and not an intended 10 rounds.

Methods tried:

   itemEnt = itemTop.GetInventory().CreateInInventory("Ammo_308Win");
   if ( Class.CastTo(itemBs, itemEnt ) )
   itemBs.SetQuantity(0.5);

------------------------------------------

itemEnt = itemTop.GetInventory().CreateInInventory("Ammo_308Win");
   if ( Class.CastTo(itemBs, itemEnt ) )
   itemBs.SetQuantity(10);

------------------------------------------------------------------------

itemEnt = itemTop.GetInventory().CreateInInventory("Ammo_308Win");
 itemBs = ItemBase.Cast(itemEnt);
 itemBs.SetQuantity(0.5);

----------------------------------------------------------------------------------

itemEnt = itemTop.GetInventory().CreateInInventory("Ammo_308Win");
 itemBs = ItemBase.Cast(itemEnt);
 itemBs.SetQuantity(10);

 

While this works with rags this method doesn't work for ammo stacks sadly, I did consider also setting a negative value to remove an amount of ammo as a positive value may have been ignored but setting a negative value just removes the ammo stack.

 

Methods tried:

   itemEnt = itemTop.GetInventory().CreateInInventory("Ammo_308Win");
   if ( Class.CastTo(itemBs, itemEnt ) )
   itemBs.SetQuantity(-0.5);

------------------------------------------

itemEnt = itemTop.GetInventory().CreateInInventory("Ammo_308Win");
   if ( Class.CastTo(itemBs, itemEnt ) )
   itemBs.SetQuantity(-10);

------------------------------------------------------------------------

itemEnt = itemTop.GetInventory().CreateInInventory("Ammo_308Win");
 itemBs = ItemBase.Cast(itemEnt);
 itemBs.SetQuantity(-0.5);

----------------------------------------------------------------------------------

itemEnt = itemTop.GetInventory().CreateInInventory("Ammo_308Win");
 itemBs = ItemBase.Cast(itemEnt);
 itemBs.SetQuantity(-10);

Edited by Smokeydapot
additional methods tested

Share this post


Link to post
Share on other sites

×