M MY Multiplayer: Wiki
Side
Kind

setVehicleEngineSound

Client

Replaces a vehicle's engine sound on this client with a sound set from the mounted packs.

bool setVehicleEngineSound(vehicle vehicle [, string|false engine = false, string|false induction = false])

Parameters

NameTypeDescription
vehiclevehicleThe vehicle.
enginestring|falseThe engine sound set's name, as listed by getVehicleEngineSounds. false or omitted goes back to the model's sound.default false
inductionstring|falseThe name of the sound set whose turbo or supercharger is used. false or omitted uses the engine set's own.default false

Returns

true if the sound was replaced, false if the element is not a vehicle on this client.

The change applies on this client only and holds while the vehicle streams out and back in.

Example

addCommandHandler("motor", function(command, engine)
    local vehicle = getPedOccupiedVehicle(localPlayer)
    if vehicle then
        setVehicleEngineSound(vehicle, engine or false)
    end
end)
Coming from MTAMTA has no such function. It follows FiveM's ForceVehicleEngineAudio.
NoteA name no pack has raises no error: it is logged to app.log and the vehicle plays SA's original engine sound.

See also