AvaN0x
July 27, 2022, 4:16pm
1
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)
Run the command test
while not in a vehicle and not having entered any vehicle, it should return 0
Get in a vehicle, run the command again, it will return the id of the vehicle
Get out of the vehicle, run the command once more, now you get the id of the last vehicle the ped
I tested this on build 2612 and the result of the step 3 is as expected 0
1 Like
0xLuca
July 27, 2022, 5:35pm
2
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
Linden
July 28, 2022, 4:58am
4
local ped = PlayerPedId()
local vehicle = GetVehiclePedIsUsing(ped)
For an actual workaround.
nta
July 28, 2022, 6:19am
5
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
AvaN0x
July 28, 2022, 9:06am
6
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
0xLuca
July 28, 2022, 10:45am
7
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?
Linden
July 28, 2022, 11:01am
9
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.
0xLuca
July 28, 2022, 11:06am
10
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
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:
committed 05:16PM - 28 Jul 22 UTC
This is a compatibility fix to make it act like older builds.
Reported at https… ://forum.cfx.re/t/4886984 originally.
Co-authored-by: Disquse <disquse@mail.com>
1 Like
AvaN0x
July 28, 2022, 5:01pm
12
Nice thank you!
(Very strange to change the behavior of this native like that but well, R* doing R* things)
AvaN0x
July 29, 2022, 10:58am
13
I just tested it and it indeed fixed it, thank you
1 Like