Page MenuHomeFeedback Tracker

Vehicles Lifetime is 0 when spawned by CE (Events.xml)
Reviewed, NormalPublic

Description

I made several tests and GetLifetime() always return 0 when a Vehicle spawned in by CE (Events.xml) making them stay forever with a unlimited lifetime.

GetEconomyProfile().GetLifetime()

returns the correct lifetime which is set in types.xml

GetLifetime()

returns 0 (only when spawned by events.xml) and that's the issue.

When spawning in via Admin Tools, both return the correct and set lifetime of the types.xml.

Methods i used including prints:

For CE spawned Vehicles:

	override void EEOnCECreate()
	{
		super.EEOnCECreate();

		if ( GetGame().IsServer() )
		{
			Print( "Vehicle " + this + " pos= " + this.GetPosition() + " CE Lifetime default: " + GetEconomyProfile().GetLifetime() );
			Print( "Vehicle " + this + " pos= " + this.GetPosition() + " CE Lifetime remaining: " + GetLifetime() );
			
			this.SetLifetime( GetEconomyProfile().GetLifetime() );
			
			Print( "Vehicle " + this + " pos= " + this.GetPosition() + " CE Lifetime default: " + GetEconomyProfile().GetLifetime() );
			Print( "Vehicle " + this + " pos= " + this.GetPosition() + " CE Lifetime remaining: " + GetLifetime() );
		}
	}

And here the Print:

SCRIPT       : Vehicle Truck_01_Covered<204971b0> pos= <4131.822266, 182.380753, 13122.184570> CE Lifetime default: 1.2096e+06
SCRIPT       : Vehicle Truck_01_Covered<204971b0> pos= <4131.822266, 182.380753, 13122.184570> CE Lifetime remaining: 0
SCRIPT       : Vehicle Truck_01_Covered<204971b0> pos= <4131.822266, 182.380753, 13122.184570> CE Lifetime default: 1.2096e+06
SCRIPT       : Vehicle Truck_01_Covered<204971b0> pos= <4131.822266, 182.380753, 13122.184570> CE Lifetime remaining: 1.2096e+06

SCRIPT       : Vehicle Sedan_02_Grey<204a11f0> pos= <14139.214844, 2.756193, 13050.478516> CE Lifetime default: 1.2096e+06
SCRIPT       : Vehicle Sedan_02_Grey<204a11f0> pos= <14139.214844, 2.756193, 13050.478516> CE Lifetime remaining: 0
SCRIPT       : Vehicle Sedan_02_Grey<204a11f0> pos= <14139.214844, 2.756193, 13050.478516> CE Lifetime default: 1.2096e+06
SCRIPT       : Vehicle Sedan_02_Grey<204a11f0> pos= <14139.214844, 2.756193, 13050.478516> CE Lifetime remaining: 1.2096e+06

SCRIPT       : Vehicle OffroadHatchback<2046f0b0> pos= <11683.120117, 75.346802, 6677.020508> CE Lifetime default: 1.2096e+06
SCRIPT       : Vehicle OffroadHatchback<2046f0b0> pos= <11683.120117, 75.346802, 6677.020508> CE Lifetime remaining: 0
SCRIPT       : Vehicle OffroadHatchback<2046f0b0> pos= <11683.120117, 75.346802, 6677.020508> CE Lifetime default: 1.2096e+06
SCRIPT       : Vehicle OffroadHatchback<2046f0b0> pos= <11683.120117, 75.346802, 6677.020508> CE Lifetime remaining: 1.2096e+06

SCRIPT       : Vehicle Old_Bike<1ed15ff0> pos= <10279.299805, 6.318300, 2184.189941> CE Lifetime default: 1800
SCRIPT       : Vehicle Old_Bike<1ed15ff0> pos= <10279.299805, 6.318300, 2184.189941> CE Lifetime remaining: 0
SCRIPT       : Vehicle Old_Bike<1ed15ff0> pos= <10279.299805, 6.318300, 2184.189941> CE Lifetime default: 1800
SCRIPT       : Vehicle Old_Bike<1ed15ff0> pos= <10279.299805, 6.318300, 2184.189941> CE Lifetime remaining: 1800

For Admin Tool spawned Vehicle:

	override void EEInit()
	{
		super.EEInit();
		
		if ( GetGame().IsServer() )
		{
			Print( "Vehicle " + this + " pos= " + this.GetPosition() + " CE Lifetime default: " + GetEconomyProfile().GetLifetime() );
			Print( "Vehicle " + this + " pos= " + this.GetPosition() + " CE Lifetime remaining: " + GetLifetime() );
		}
	}

And here the Print:

SCRIPT       : Vehicle Truck_01_Covered<274701e0> pos= <13215.186523, 2.053945, 7390.652832> CE Lifetime default: 1.2096e+06
SCRIPT       : Vehicle Truck_01_Covered<274701e0> pos= <13215.186523, 2.053945, 7390.652832> CE Lifetime remaining: 2.06057e+06

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
Server
Steps To Reproduce
  • Set a lifetime for any Vehicle in types.xml
  • Let Vehicle spawn via events.xml
  • Wait until you got grey hair to witness it's not despawning due to unlimited lifetime

Event Timeline

Tyson created this task.Jul 29 2023, 12:28 AM

Afair it was like that before, that's why abandoned vehicle remover mod was made.
Yet it's still a bug and definitely need to be fixed

Vehicle despawn has always confused me...
What is the time on them, and is it actually adjustable

TheRealTDog added a subscriber: TheRealTDog.EditedJul 29 2023, 2:19 PM

I was just about to make a ticket on this. I support this ticket. I've also discovered that when you spawn a vehicle in via events.xml, the lifetime is zero. However, when you take an item from the boot/cargo or whatever, the lifetime that is set for that event will then be taken into account and begin the despawn process. Obviously, that is if the deletable="1" is set to 1.

I have a video here showcasing the vehicle spawning with the lifetime not being set (Top Left). I can then get in the car, drive it around and the lifetime will not be triggered or be in effect. Only until I take something out the back will the lifetime take into effect. I feel like whenever the car first spawns in, the lifetime should be in effect straight away or until someone interacts with it. Opening the car door or getting in for example. This should be changed imo.

Geez changed the task status from New to Awaiting internal Testing.Jul 31 2023, 11:07 AM

@Geez To add to my statement and findings, I've found that what the event is actually doing is getting the lifetime from types.xml. So for me at that time, my lifetime in the types.xml for Offroad_02 was 0. However, if you change the lifetime of the vehicle child to anything else (more than 0) the event will take that as the lifetime and then despawn the child when it hits 0 without the need to take anything out of the vehicle.

In short, (remember this is for vehicles only) lifetime in types for the child >=1? the car will spawn, use that lifetime then despawn. Completely disregarding the lifetime in events.xml for the child. Lifetime in types for the child =0? My first statement above happens

However, what is strange is that the theory with lifetime being 0, have to grab something out of the car for it to despawn, doesnt work for containers it seems. Only cars. Video example below,

Different event, different child, child lifetime set to 0 in types, take something out, nothing happens. It doesn't even read the lifetime from its event. Pick it up and chuck it, nothing will trigger it to despawn. Unless you ruin it and "deletable" is set to 1. Lifetime in types for the child >=1? Spawns, uses the lifetime, despawns. There is a clear disconnect with when an event spawns and where it pulls the lifetime from and when it should be triggered. This should definitely be looked into because i can guarantee its been like this for a while.

And I Would like to say now that THE RESTOCK VALUE IN EVENTS DOES NOT WORK WHATSOEVER I CANT GET IT TO WORK. Unless someone shows me otherwise, I've tried everything and nothing works.

Thank you.

Geez changed the task status from Awaiting internal Testing to Reviewed.Aug 7 2023, 12:02 PM

Hello Tyson.
Yes, by default all vehicle events have deletable = 0 set in events.xml, which means that it does not get any lifetime and gets set to 0 and indeed lives forever until the car is ruined.
On your own server you can set deletable = 1 and set the lifetime for events to whatever value you would like.

@TheRealTDog Thank you, we will take a look at your suggestion and if there can be something implemented.