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  
MarioTorlandino

Spawned cars despawning when far from players

Recommended Posts

Hi everyone!

I'm working at server mod that should spawn and mainpulate and then despawn some game objects. I can't understand why cars disappearing after some time far from player.

For example, I'm creating  "Land_Container_1Mo" and "OffroadHatchback" at same location with same function, I can see them appearing and disappearing in game and everything works fine if I'm near.

If objects is created and I'm going far from them then only "Land_Container_1Mo" stays in place and car is disappearing. I tried spawning cars in line and teleporting player further and further from them via VPPAdmin and far cars from line is disappearing. Looks like some garbage collector checking objects every dozen of seconds and deleting if no player detected near.

How should I spawn cars and "fix" them in world? Script is saving spawned objects in array to despawn it later. So I need this objects to be despawned automaticaly only if server is restarting etc. without script finishing properly.

Thanks!

 

Spawning code example is below:

// P:\@MyMod\Addons\MyMod\scripts\4_World\SomeScript.c

ref SomeWorkingClass GlobalSomeWorkingClass = new ref SomeWorkingClass; // Main object that creates at start and rules others

class SomeWorkingClass {
	ref array<Object> SpawnedObjects = new array<Object>;
	//array<SomeOtherClass> CarList ... list of cars and their attachments
	
	void SpawnCarObjects() {
		for (int i=0;i<CarList.Count();i++) {
	
			Object CarObject = GetGame().CreateObjectEx(CarList[i].ObjType,CarList[i].Pos, ECE_PLACE_ON_SURFACE); // Creating
			CarObject.SetOrientation(CarList[i].Rot); // Rotating
			
			...
			
			if (CarObject.CanAffectPathgraph()) {
				CarObject.SetAffectPathgraph(true, false);
				GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(GetGame().UpdatePathgraphRegionByObject, 100, false, CarObject);
			}

			...
				
			SpawnedObjects.Insert(CarObject); // Go in array for later manipulating
		}
	}
}

 

Edited by MarioTorlandino

Share this post


Link to post
Share on other sites

Problem solved. It was lifetime parameter of cars in types.xml

Set it to maximum and everything works perfect.

<lifetime>2592000</lifetime>

 

Share this post


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

×