Game build 2699 - GetVehiclePedIsIn ignore second arg and take it as true

1. Client (production/canary) and FXServer version
Linux 5755 - Canary - Build 2699

2. What you expected to happen
GetVehiclePedIsIn - FiveM Natives @ Cfx.re Docs with a second arg of false / nil / 0 should only return the vehicle the ped is in

3. What actually happens
As if the second arg was true, the last ped vehicle is returned

4. Category of bug (eg. client, server, weapons, peds, native)
Client native on build 2699

5. Reproducible steps, preferably with example script(s)

RegisterCommand("test", function(source, args)
    print(GetVehiclePedIsIn(PlayerPedId(), false))
end, false)
  1. Run the command test while not in a vehicle and not having entered any vehicle, it should return 0
    image

  2. Get in a vehicle, run the command again, it will return the id of the vehicle
    image

  3. Get out of the vehicle, run the command once more, now you get the id of the last vehicle the ped
    image

I tested this on build 2612 and the result of the step 3 is as expected 0

1 Like

Can confirm on Windows Server - 5755 - 2699 - Canary

1 Like

Confirmed, Windows Server 5756 - 2699, ugly work around is ugly

workaround hidden so people don't try using this one, see linden's post below

image

local ped = PlayerPedId()
local vehicle = GetVehiclePedIsUsing(ped)

For an actual workaround.

This isn’t a FiveM bug, it’s a R* change(/bug?) - even happens in SP script hooks.

We’re still looking into it.

3 Likes

Another possible workaround:

AddEventHandler("baseevents:leftVehicle", function()
    ResetPedLastVehicle(PlayerPedId())
end)

(because GetVehiclePedIsUsing will get the vehicle the ped is trying to enter too)

EDIT: fixed the code snippet

We are using IsPedInAnyVehicle - FiveM Natives @ Cfx.re Docs as a check before getting the actual vehicle the ped is inside of. This works in Lua & C#.

This works? Did you test it? That doesn’t really make sense, does it?

Could you enlighten me?

Why would it not work, and what doesn’t make sense?

The difference is that GetVehiclePedIsUsing will return at enter and exit (see docs); which may or may not fit the use-case.

RegisterCommand('getvehicle', function()
    local ped = PlayerPedId()

    -- vehicle id or 0
    print(GetVehiclePedIsUsing(ped))

    -- vehicle id or false
    print(IsPedInAnyVehicle(ped, false) and GetVehiclePedIsIn(ped, false))
end)

Both will have the same output while in a vehicle.

Sorry, misread. It looked like the only think you changed was the peds handle being stored in a variable, but you used an entirely different native :sweat_smile:

The logic of this native was changed by R* in b2699.
We prepared a fix for this compatibility issue. Currently passing internal testing!

UPD. Should be fixed now:

1 Like

Nice thank you!
(Very strange to change the behavior of this native like that but well, R* doing R* things)

I just tested it and it indeed fixed it, thank you :slight_smile:

1 Like