Odd bug I came across. Seemingly random and the repro only works some of the time. After a few ticks the result of GetVehiclePedIsIn goes back to 0.
for i = 1, 10 do
-- Setup
local targetPlayer = GetPlayers()[1]
local playerPed = GetPlayerPed(targetPlayer)
local playerPos = GetEntityCoords(playerPed)
local setupVehicle = CreateVehicle(`RUINER2`, playerPos.x, playerPos.y, playerPos.z, GetEntityHeading(playerPed), true, true)
repeat Citizen.Wait(0) until DoesEntityExist(setupVehicle)
SetPedIntoVehicle(playerPed, setupVehicle, -1)
print("Setup complete!")
Citizen.Wait(1000)
for i = 0, 1 do
local vehicleToDelete = GetVehiclePedIsIn(GetPlayerPed(targetPlayer), i)
while DoesEntityExist(vehicleToDelete) do
DeleteEntity(vehicleToDelete)
Citizen.Wait(100)
end
end
Citizen.Wait(100)
print('Stage 1: Player is in vehicle ' .. GetVehiclePedIsIn(GetPlayerPed(targetPlayer), false))
local newVehicle = CreateVehicleServerSetter(`RUINER2`, 'automobile', vehicleSpawnPos.x, vehicleSpawnPos.y, vehicleSpawnPos.z, 100.)
print('Created server vehicle with handle ' .. newVehicle)
print('Stage 2: Player is in vehicle ' .. GetVehiclePedIsIn(GetPlayerPed(targetPlayer), false))
print(tostring(newVehicle == GetVehiclePedIsIn(GetPlayerPed(targetPlayer), false)))
Citizen.Wait(1000)
end
Can reproduce the bug on FXServer-master SERVER v1.0.0.7080 win32 using same code as @DatGuy1 gave, GetVehiclePedIsIn return 0 when the player is in a vehicle.
Odd bug I came across. Seemingly random and the repro only works some of the time. After a few ticks the result of GetVehiclePedIsIn goes back to 0.