function turn(thePlayer)
local vehicle = getPedOccupiedVehicle(thePlayer)
if (not vehicle) then return end
local speedx, speedy, speedz = getElementVelocity(vehicle)
local rX, rY, rZ = getVehicleRotation(vehicle)
local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)
local kmh = actualspeed * 180
local mph = actualspeed * 111.847
setElementRotation(vehicle, rX, rY, rZ + 180)
setElementVelocity ( vehicle, speedx, speedy, speedz - speedz^2 )
outputChatBox("You turned your vehicle with " .. tostring(kph) .. " km/h | " .. tostring(mph) .. " mph", thePlayer)
end
function bindTheKey()
for index, player in pairs(getElementsByType("player")) do
bindKey(player, "lctrl", "down", turn)
outputChatBox("#00FF00You can now press #0000FF'left ctrl' #00FF00in vehicle to turn for 180 degrees!", player, 255, 255, 255, true)
end
end
addEventHandler("onResourceStart", resourceRoot, bindTheKey)
addEventHandler("onPlayerJoin", root,
function()
bindKey(source, "lctrl", "down", turn)
end)
doesnt work