fivem-functional-flatbed
fivem-functional-flatbed copied to clipboard
NetworkHasControlOfEntity Issues
The pull request that was merged #1 has an issue here where it may never return. In my testing this can cause beds to not delete if the script gets locked in this loop and the vehicle is then deleted. There should be a timeout or something similar put into it to prevent this.
https://github.com/glitchdetector/fivem-functional-flatbed/blob/f49a516a051896b3b8639c8fa89d1b66cb845b69/flatbed.lua#L245
After som debugging, i found out that this happens when the raycast returns 0 which means it hasn't found a vehicle on the bed... For some reason the if statement 'if newCar then' does nok work correctly. I changed it to 'if newCar ~= 0 then'. And then made an else statement for when the raycast returns 0.
This prevents the script from ever going into the infinite loop you are mentioning. There are some addon cars that the raycast just wont find. Therefore i also added so that if the raycast returns 0 it instead uses the last car that i entered, which should be the car i drove onto the bed. This has been working flawlessly ever since.
@Mikkelhost hello I had found the same problem your changes interests me a lot
just like the LSPD model problem or the fact that a non-mechanic can control the maneuver
if you could share me your work thank you very much, the author does not seem to update the script anymore or correct all this
Thats my fix of breaking the function othzerwise
if newCar ~= 0 then local carPos = GetEntityCoords(newCar, false) NetworkRequestControlOfEntity(newCar) while not NetworkHasControlOfEntity(newCar) do Wait(0) end AttachEntityToEntity(newCar, bed, 0, attachmentOffset[1] + vector3(0.0, 0.0, carPos.z - bedPos.z - 0.50), attachmentOffset[2], 0, 0, false, 0, 0, 1) car = newCar DecorSetInt(veh, "flatbed3_car", VehToNet(newCar)) attached = true DecorSetBool(veh, "flatbed3_attached", attached) else attached = false end