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  
smanuk

Adding Custom Buildings

Recommended Posts

I'm currently working on a modded server for DayZ which I'm going to be adding buildings to the map using "Not A Banana's" two mods BuilderItems and BuilderStatics.

To do this currently I have the init.c setup like this which spawns the building on load just fine.

    //Spawn helper function
void SpawnObject( string type, vector position, vector orientation )
{
    auto obj = GetGame().CreateObject( type, position );
    obj.SetPosition( position );
    obj.SetOrientation( orientation );
    //Force collision update
    vector roll = obj.GetOrientation();
    roll [ 2 ] = roll [ 2 ] - 1;
    obj.SetOrientation( roll );
    roll [ 2 ] = roll [ 2 ] + 1;
    obj.SetOrientation( roll );
}

void main()
{
    //Custom Spawned Objects
    //Belota
    SpawnObject("Land_Mil_ATC_Small", "5068.464844 18.783197 2477.377686", "142.000000 0.000000 0.000000");
    
...

I've been trying to work out but with no luck how I can put the custom spawned object into there own file and include it into this so it's easier to do area's and keep track but all I keep getting is errors saying I'm missing this and that.

Share this post


Link to post
Share on other sites

To be easier i've done it like this:

In my init.c 
 

#include "$CurrentDir:\mpmissions\dayzOffline.chernarusplus\(my mapping file).c"

void SpawnObject( string type, vector position, vector orientation )
{
    auto obj = GetGame().CreateObject( type, position );
    obj.SetPosition( position );
    obj.SetOrientation( orientation );
    //Force collision update
    vector roll = obj.GetOrientation();
    roll [ 2 ] = roll [ 2 ] - 1;
    obj.SetOrientation( roll );
    roll [ 2 ] = roll [ 2 ] + 1;
    obj.SetOrientation( roll );
}

in the void main() (just before the last "}" ) i've added: 

AddMyObjects();

And then in my server folder i've created a file: (my mapping file).c and inside i put all my custom buildings like this:
 

void AddMyObjects()
{
    //Custom Nehr
    //Airfield
    SpawnObject("Land_Airfield_Hangar_Green", "4566.678711 345.704529 10186.797852", "58.000217 0.000000 0.000000");
   ...
   ...
}

Don't forget to replace the (my mapping file).c you just put the name you want.



Like this my init.c stay clear and i have a file were there is all my buildings.

Edited by Nehr

Share this post


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

×