Information
Hey FiveM members, this is my first release here, so it would be great if i could get some feedback. The script is very self explanatory, what it does is Trigger’s an alarm/chime sound when getting in or out of your vehicle (Video below). This script is not standalone however it uses InteractSound by @Scott for the chime noise (This is included in the Download).
Very nice! Would love to see something where you can set different sounds to differnt models, like an older ford chime like you have in right now for older ford models and the new chime for the new models… same sorta thing for other car models, could set them in a config. Would be cool if possible!
Hello there! I made some changes to this script to make it a bit more realistic. If @Chezza doesn’t mind, that is. These changes bring realism by keeping the chime active until the door is closed
–HOW TO EDIT–
You will need to change both cl_chime.lua in your door-chime resource folder AND main.lua in your in InteractSound resource folder.
This changes your main.lua in InteractSound – This should replace ONLY your “InteractSound_CL:PlayOnOne” EventHandler --SHOULD LOOK LIKE IMAGE BELOW-
RegisterNetEvent('InteractSound_CL:PlayOnOne')
AddEventHandler('InteractSound_CL:PlayOnOne', function(soundFile, soundVolume)
local ped = GetPlayerServerId (PlayerId ())
local veh = NetworkGetNetworkIdFromEntity(GetVehiclePedIsIn(GetPlayerPed(-1), true))
local lCoords = GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), true))
local eCoords = GetEntityCoords(GetPlayerPed(-1))
local distIs = Vdist(lCoords.x, lCoords.y, lCoords.z, eCoords.x, eCoords.y, eCoords.z)
if(distIs <= 4) then
SendNUIMessage({
transactionType = 'playSound',
transactionFile = soundFile,
transactionVolume = soundVolume
})
end
end)
This is a new version of cl_chime.lua in door-chime made by @Chezza
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local ped = GetPlayerPed(-1)
local veh = GetVehiclePedIsUsing(ped) or GetLastDrivenVehicle()
if DoesEntityExist(ped) and not IsEntityDead(ped) then
if IsPedInAnyVehicle(ped, false) and GetEntityModel(veh) then
if GetIsTaskActive(ped, 2) then
repeat TriggerServerEvent('InteractSound_SV:PlayOnSource', 'chime', .2)
Citizen.Wait(1000)
until GetIsTaskActive(ped, 168) or GetIsTaskActive(ped, 164) or IsPedInAnyVehicle(ped, true)
end
end
end
end
end)
Known Bugs;
If you close your door from the outside by running into it, the chime will stay on unless you close the door in any way by pressing F (If someone knows a fix to this please be my guest)