So I have an error that says Bad argument @ "getPedOccupiedVehicle" [Expected ped at argument 1, got nil] and I have no idea how to fix it. If someone could help me I would really appreciate it.
local speed = 20
local buoyancy = 1.5
local drag = 1
function swimVehicle (vehicle, seat, jacked)
local id = getPedOccupiedVehicle (vehicle)
if id == 407 then
local x, y, z = getElementPosition ( vehicle )
local level = getWaterLevel ( x, y, z )
if id == 407 and level and z < level then
setElementData(vehicle, "buoyancy", 1.5)
setElementData(vehicle, "vehicleDrag", 1)
setElementData(vehicle, "centerOfMass", {0,0,-1})
setVehicleHandling(vehicle, "engineAcceleration", 20)
else
setElementData(vehicle, "buoyancy", 0)
setElementData(vehicle, "vehicleDrag", 0)
setVehicleHandling(vehicle, "engineAcceleration", 0)
end
end
end
addEventHandler("onClientRender", root, swimVehicle)