--***********************************************************
--**                   KI5 / bikinihorst                   **
--***********************************************************

require "Hooks/DAMN_EnterAnimations";

DAMN = DAMN or {};
R32 = R32 or {};

DAMN.EnterAnimations:registerVehicleScript("Base.92nissanGTR", "low");
DAMN.EnterAnimations:registerVehicleScript("Base.92nissanGTRlhd", "low");

local fired = false

function R32.turbo(player)
    local vehicle = player.getVehicle and player:getVehicle() or nil
        if (vehicle and string.find( vehicle:getScriptName(), "92nissanGTR" )) then
            if not fired and vehicle:isEngineRunning() and (vehicle:getEngineSpeed() >= 5100) then
                getSoundManager():PlaySound("GTRturbo", false, 1)
                fired = true
            end
            if fired and vehicle:isEngineRunning() and (vehicle:getEngineSpeed() < 2700) then
                getSoundManager():PlaySound("GTRcrackling", false, 1)
                fired = false
            end
        end
end

Events.OnPlayerUpdate.Add(R32.turbo);