1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Leaving a vehicle by lua code

Discussion in 'Scripting' started by Yumi, Aug 17, 2016.

  1. Yumi

    Yumi New Member

    Hello,

    I like to be able to leave a vehicle via a lua script to return to player (pedestrian) like when pressing 'E' key.
    The lua script I'm writing is a global script not linked to a particular vehicle.
    I've tried to call g_client:getServerConnection():sendEvent(VehicleLeaveEvent:new(self.currentVehicle);
    self.currentVehicle being the controlled vehicle I'd like to leave.

    It seems it''s not sufficient since once called, I cannot move the camera or the player but I have the feeling not to be anymore in the vehicle.
    I've also tried to set some variables on the vehicle like .isControlled = false or .isEntered = false

    Does anyone know if and how this can be achieved ?
    Thanks
     
  2. ShermyPermy

    ShermyPermy Captain Break It Staff Member Media Staff SOB Modding

    Hi Yumi,

    just a quick question in between.
    why are you making a script to exit a vehicle?
    what benefits do you think you can gain to have a custom script for it?

    i do know if this kind off thing is posible since im not a scripter but im interested in why you want to do it this way.

    greets,

    shermy
     
  3. Yumi

    Yumi New Member

    Hello,
    I've post in Mod Ideas but I'm not able to reference this post so please find an extract of what I'm trying to achieve:
    So I need to be able to simulate several players on a solo game and have a way to enter vehicles (already done) but also leave them, my current issue.
    I'm not able to find any mod doing this scenario. If you have ideas...
     
    dj likes this.
  4. Yumi

    Yumi New Member

    well, it seems I've finally found the solution reading code doc.
    This is the key:
    g_currentMission: onLeaveVehicle(g_currentMission.playerStartX, g_currentMission.playerStartY, g_currentMission.playerStartZ);
     
    ShermyPermy and dj like this.
  5. Xentro

    Xentro Active Member Honorable Member Wiki Editor

    You can use the function like this if you want to adjust where the player should be place when leaving tractor (etc at the start location)
    Code:
    g_currentMission:onLeaveVehicle(g_currentMission.playerStartX, g_currentMission.playerStartY, g_currentMission.playerStartZ);
    Or you can use it like this and it should read the exit position of the machine you are leaving and place the player there.
    Code:
    g_currentMission:onLeaveVehicle();
     
    dj likes this.
  6. Yumi

    Yumi New Member

    Thanks, this is what I understood.
    I'll soon make a WIP post to present the mod I'm working on since it's already functionnal.
     
    dj and Enzosnext like this.

Share This Page