Lexicality / applejack

The private version of Applejack with loads of improvements and stuff (Side note - this has nothing to do with ponies)
4 stars 1 forks source link

Add sirens for police cars #37

Open Lexicality opened 10 years ago

Lexicality commented 10 years ago

Lexi From the forums

I am basing this off of the default VUmod, so some files may be different.

lua/autorun/client/ClientVehicleScript.lua

In the section with the keybinds and RunConsoleCommands, add

if string.find( bind, "impulse 201" ) then
    if AntiCmdSpam + 15 < CurTime() then
        RunConsoleCommand("PlaySiren")
        AntiCmdSpam = CurTime()
    end
    return true
end

lua/autorun/VehicleScript.lua

Add this somewhere in the script:

vu_enablesiren = CreateConVar( "vu_enablesiren", "1", { FCVAR_PROTECTED } )  
local function PlaySiren( player,cmd,arg )
    if player:InVehicle() and vu_enablesiren:GetInt() != 0 then
        local vehicle = player:GetVehicle()
        if vehicle.VehicleTable && vehicle.VehicleTable.Siren then
            player:GetVehicle():EmitSound(vehicle.VehicleTable.Siren.Sound, 100, vehicle.VehicleTable.Siren.Pitch)
        end
    end
end
concommand.Add( "PlaySiren", PlaySiren

In the file that has the police car vehicle script (Nova_vehicles.lua is the default), add this inside the police car vehicle script somewhere:

Siren = {Sound = "policesirenhaste1.mp3", Pitch = 100},

The modified jeep would look like this:

local V = {     
    Name = "Siren Jeep",
    Class = "prop_vehicle_jeep_old",
    Category = "VU-MOD",
    Author = "Nova[X]",
    Information = "A jeep with a siren",
    Model = "models/buggy.mdl",
    HeadLights = {
        Light1 = { Pos = Vector(-13,-50,40), Ang = Angle(0,10,90) } ,
        Light2 = { Pos = Vector(13,-50,40), Ang = Angle(0,-10,90) }
    },
    Horn = {Sound = "vu_horn_simple.wav", Pitch = 90},
    Siren = {Sound = "policesirenhaste1.mp3", Pitch = 100},
    Passengers  = { passenger1 = { Pos = Vector(16,37,19), Ang = Angle(0,0,0) } }, -------Set Up passenger seats!
    SeatType = "jeep_seat", ----if were not hideing the seat you probably want to choose a seat.
    HideSeats = false, -----Hide the passenger seats?
    KeyValues = {
                    vehiclescript    =    "scripts/vehicles/jeep_test.txt"
                }
}
list.Set( "Vehicles", "Jeep(VU)", V )

This results in only the police car having a siren. The siren is usable by hitting your 'spray' key, Impulse 201.

The server already has the siren sound, so no extra files are needed.

Thank you for reading this.

Baddog

I thought we had sirens? Codebase Link