Page MenuHomeFeedback Tracker

REQUEST: Add a way to spawn vehicle like CE does from events.xml
Closed, ResolvedPublic

Description

Hello,

Currently, the only way to spawn our vehicle is to spawn it with GetGame::CreateObject function. The problem is when a vehicle is saved, he is not considered as CE vehicle but like a dynamic object. But, when we do that we can't use any of the flags from the events. Like for example "remove_damaged".
Another disadvantage, when server owners want to wipe vehicles, we can't easily wipe all vehicles spawn with CreateObject function. If all vehicles would be inside vehicles.bin, this would be more simple to easily wipe stuff.

We discussed with Sumrak to try to find a workaround. But this is not an ideal goal, the only way would force the dynamic vehicle to not be ruined so it will not be deleted.

So, It's would be really useful to force spawn an event from events.xml with a position and maybe a rotation, so we can create our own vehicle.

Details

Severity
Feature
Resolution
Open
Reproducibility
N/A
Operating System
Windows 10 x64
Category
General

Event Timeline

NiiRoZz created this task.Apr 14 2020, 10:38 AM
Geez changed the task status from New to Assigned.Apr 15 2020, 12:12 PM
Geez closed this task as Resolved.EditedApr 16 2020, 12:21 PM
Geez claimed this task.
Geez added a subscriber: Geez.

Hello NiiRoZz.
This is already possible to do so by using GetCEApi().SpawnDE("VehicleOffroadHatchback",pos,0); or GetCEApi().SpawnDE_WIP("VehicleOffroadHatchback",pos,0,CESPAWN_NONE) with flags.
Regards,
Geez

Geez added a comment.Apr 16 2020, 12:28 PM

There is also a prototype function:

proto native void SpawnDE( string sEvName, vector vPos, float fAngle ); /* THIS WILL BE OBSOLETE OR PREFERABLY DEFAULT? */
 proto native void SpawnDE_WIP( string sEvName, vector vPos, float fAngle, int uFlags );

from CEApi class, as example:

GetCEApi().SpawnDE("VehicleOffroadHatchback",pos,0);
GetCEApi().SpawnDE_WIP("VehicleOffroadHatchback",pos,0,CESPAWN_NONE) with flags

You need to specify your vehicle in events.xml and then you can use its name to spawn it the very same way as CE does - do not forget to advance types and all proper values like lifetime and avoidance.
It is also possible to add spawn point for such event on the map in cfgeventspawns.xml.
In the next version we will add modable version of offline DB as well, so your files may be just attached to the original setup.

Hey,

Thanks for the reply @Geez.

Can we also use that for Weapons to spawn with attachments ? Or is this only a thing for Events ? Would be great if we would have the configured attachments from cfgspawnabletypes.xml for weapons working with that too

Geez added a comment.EditedMay 12 2020, 5:37 PM

@LBmaster

Yes. If you configure weapons with attachments exactly as int cfgSpawnableTypes.xml
For example:

<type name="CZ61">
    <attachments chance="0.10">
        <item name="AK_Suppressor" chance="1.00" />
    </attachments>
    <attachments chance="0.30">
        <item name="Mag_CZ61_20Rnd" chance="1.00" />
    </attachments>
</type>

You can use functions at CEApi class to spawn it with those according to configuration.
For direct item spawn of loot use:

proto native void SpawnEntity( string sClassName, vector vPos, float fRange, int iCount );

And if you want to create a dynamic event for such weapon (loot)

  • it is also possible ("ItemPlanks" event may be best sample)
  • then it can be spawned at DE points as vehicles.

Regards,
Geez

Thanks.
So I can spawn items / events in, but I don't get a reference to an object that was spawned ? Would be nice to get my spawned Item to manipulate it further