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

Sign in to follow this  
kmiles1990

Spawning new objects

Recommended Posts

How can I create like a crate at a certain location and add food to that crate, or something large that I can put lots of food in that will always spawn there? Can someone show me an example?

Share this post


Link to post
Share on other sites

PlayerBase boxf_target;
                if(count == 2) {
                    boxf_target = GetPlayer(tokens[1]);
                    if(boxf_target == NULL) {
                        SendMessageToPlayer(player, "[boxf] Can't find player called: '"+tokens[1]+"'");
                    } else {
                        SendMessageToPlayer(player, "[boxf] You boxf " + boxf_target.GetIdentity().GetName());
                    }
                } else {
                    boxf_target = player;
                    SendMessageToPlayer(player, "[boxf] You boxf yourself");
                }
                if(boxf_target != NULL) { 
                    ItemBase boxf_fnx; 
                    EntityAI boxf;               
                    boxf = EntityAI.Cast(GetGame().CreateObject( "AmmoBox", boxf_target.GetPosition(), false, true ));        

                    EntityAI ttaka = boxf.GetInventory().CreateInInventory("FNX45");
                    ttaka.GetInventory().CreateAttachment("PistolSuppressor");
                    ttaka.GetInventory().CreateAttachment("FNP45_MRDSOptic");
                    ttaka.GetInventory().CreateAttachment("UniversalLight");

                    boxf.GetInventory().CreateInInventory("AmmoBox_45ACP_25rnd");
                    boxf.GetInventory().CreateInInventory("AmmoBox_45ACP_25rnd");
                    boxf.GetInventory().CreateInInventory("AmmoBox_762x54_20Rnd");
                    boxf.GetInventory().CreateInInventory("AmmoBox_762x54_20Rnd");
                    boxf.GetInventory().CreateInInventory("Mag_FNX45_15Rnd");
                    boxf.GetInventory().CreateInInventory("Mag_FNX45_15Rnd");
                    boxf.GetInventory().CreateInInventory("Mag_SVD_10Rnd");
                    boxf.GetInventory().CreateInInventory("Mag_SVD_10Rnd");
                    boxf.GetInventory().CreateInInventory("Mag_SVD_10Rnd");
                    boxf.GetInventory().CreateInInventory("Mag_SVD_10Rnd");    
                    boxf_fnx = ItemBase.Cast(boxf);    
                }

Share this post


Link to post
Share on other sites
Sign in to follow this  

×