Log in to reply

[Script C#] It is possible that dead peds in vehicle get out of vehicle by itself ?

  • Hey, guys.

    I'm writing a simple script mod in C# and I'm in a kind of trouble.

    I want peds which died in vehicle to get out its vehicle by itself when the vehicle stops.

    I've tried: (Please don't mind names of variables. They are different in real codes.)

    • if (ped.IsDead) ped.Task.LeaveVehicle(vehicle, false); // in onTick
    • Function.Call(Hash.SET_PED_DIES_IN_VEHICLE, ped, false); // when creating ped

    But I've got nothing. Peds are still dead in vehicle even if vehicle stopped.

    If you have any suggestions, every idea is welcome.

    Thank you for reading and have a great day.

  • @ES_SENCE A dead ped can't leave a vehicle. He or she is dead! However you can simply delete it.


  • @Cyron43 First of all, thank you so much for taking your time to leave a comment for me.
    Yes, I thought so too. You know, giving a task to "dead" entity ? It's really weird ...
    But I did because I was desperate. And like you suggested, deleting ped looks pretty strange in my opinion.
    So I wanted to let ped dead inside vehicle get out like turning over from it. (Sorry for my bad English.)
    I think I saw some peds did that animation, so I want to implement it.
    Sorry but thank you again for helping me.

  • You could try the native function RESURRECT_PED to bring the ped back to life and then do what you like with it.


    This function will simply bring the dead person back to life.
    Try not to use it alone, since using this function alone, will make peds fall through ground in hell(well for the most of the times).
    Instead, before calling this function, you may want to declare the position, where your Resurrected ped to be spawn at.(For instance, Around 2 floats of Player's current position.)
    Also, disabling any assigned task immediately helped in the number of scenarios, where If you want peds to perform certain decided tasks.

    Call it like this:

    Function.Call(Hash.RESURRECT_PED, ped);

  • @Jitnaught Thank you for replying. I really appreciate it.
    Your suggestion might help I think it would be better that dead peds fall out of their vehicles.
    I think I saw some peds did it so I want to implement that feature.
    Thank you again for your time.

  • @ES_SENCE You could resurrect them, task them to leave the vehicle, then kill them again.

  • @Jitnaught Wow, I've never thought so.
    It's not ideal to me but it should work.
    I'll give it a try. Thank you for your help !

  • The easiest way to do what you want, is simply to add this flag : FallsOutWhenDead
    to all vehicle entries in vehiclelayouts.meta.

    In context, it would looks like this :

        <Item type="CVehicleSeatAnimInfo">
          <DriveByInfo ref="DRIVEBY_BIKE_CHOPPER" />
          <InsideClipSetMap ref="INSIDE_CLIPSET_MAP_CHOPPER_FRONT" />
          <PanicClipSet />
          <AgitatedClipSet />
    	  <DuckedClipSet />
          <FemaleClipSet />
          <SeatAnimFlags>CanDetachViaRagdoll UseBikeInVehicleAnims SupportsInAirState UseRestrictedTorsoLeanIK FallsOutWhenDead</SeatAnimFlags>
          <SteeringSmoothing value="0.100000" />
          <ExitToAimInfoName />
          <MaleGestureClipSetId />
          <FemaleGestureClipSetId />
    Of course, the above only applies if I have understood your need correctly, and all you aim to acheive is to have the peds falls out of the vehicle, when they die. 
    Anyway, I hope this helps.

  • @grateful_for_mods Wow, this is awesome !
    I'll try this out right away. Thank you so much for your help.


    @grateful_for_mods Now this is the sort of expert help I admire! Chapeau! :)

Log in to reply

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.