[Release] Play Custom Sounds for Interactions

You’re welcome.

I made a suicide bomber script with this, and i gotta say; its now become my favorite thing. Opens up a lot of things for me, mate :+1:

I have a question. If a bunch of people use interacting sounds and let’s say they spam it. Will it not trigger the in-promise error?

I have the same problem, anyone who wants to connect to mewen server, the message comes from the resource interact-sounds0.2.1
could not be loaded.

Can someone help me please?

Hello, I wanted to know if it is possible to play audios of more than 2 minutes such as a song?

1 Like

yeah im lookin for this too

Please share, that sounds awesome lol.

Meh, perhaps if more people would want it. But again; 85% of FiveM is RP, so this being relevant to anyone on FiveM is slim to none. Plus it also ear fucks the people surrounding you as well. Not sure how they would feel about it. I think I’ve given a good amount of my players PTSD from it now :joy:

How to play sounds?

i have one issue it says couldnt load resource when i join server!!

I want to make it so only police hear the sound when receiving a notification… but everyone on the server receive it even tho it’s in a loop… anyone can help ?

    local source = source
    local xPlayer = ESX.GetPlayerFromId(source)
    local Players = ESX.GetPlayers()

    for i = 1, #Players do
        local xPlayer = ESX.GetPlayerFromId(Players[i])

        if xPlayer["job"]["name"] == "police" then
        	TriggerClientEvent('InteractSound_CL:PlayOnOne', xPlayer.source, 'dispatch', 0.1)           
        end
    end 

Did u solve that?

nope :\

mine legit just doesnt work

    'client/html/index.html',
    'client/html/sounds/clicks.ogg',
    'client/html/sounds/tow.ogg'
} 
	TriggerEvent('InteractSound_SV:PlayWithinDistance', 5, 'clicks', 0.4)
	TriggerEvent("mt:missiontext", "~b~Officer " .. GetPlayerName(PlayerId()) .. "~w~: Dispatch, requesting a Tow Truck to my current location.", 5000)	enroute = true
	Wait(2000)
	TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 0.5, 'tow', 1.0)

you ever figure this out?

How can i add a Sound in esx_carlock?
my client.lua

ESX                           = nil

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end

end)



Citizen.CreateThread(function()
  local dict = "[email protected][email protected][email protected]"
  RequestAnimDict(dict)
  while not HasAnimDictLoaded(dict) do
      Citizen.Wait(0)
  end
  while true do
    Citizen.Wait(0)
	if (IsControlJustPressed(1, 303)) then
		local coords = GetEntityCoords(GetPlayerPed(-1))
		local hasAlreadyLocked = false
		cars = ESX.Game.GetVehiclesInArea(coords, 30)
		local carstrie = {}
		local cars_dist = {}		
		notowned = 0
		if #cars == 0 then
			ESX.ShowNotification("No vehicles to lock nearby.")
		else
			for j=1, #cars, 1 do
				local coordscar = GetEntityCoords(cars[j])
				local distance = Vdist(coordscar.x, coordscar.y, coordscar.z, coords.x, coords.y, coords.z)
				table.insert(cars_dist, {cars[j], distance})
			end
			for k=1, #cars_dist, 1 do
				local z = -1
				local distance, car = 999
				for l=1, #cars_dist, 1 do
					if cars_dist[l][2] < distance then
						distance = cars_dist[l][2]
						car = cars_dist[l][1]
						z = l
					end
				end
				if z ~= -1 then
					table.remove(cars_dist, z)
					table.insert(carstrie, car)
				end
			end
			for i=1, #carstrie, 1 do
				local plate = ESX.Math.Trim(GetVehicleNumberPlateText(carstrie[i]))
				ESX.TriggerServerCallback('carlock:isVehicleOwner', function(owner)
					if owner and hasAlreadyLocked ~= true then
						local vehicleLabel = GetDisplayNameFromVehicleModel(GetEntityModel(carstrie[i]))
						vehicleLabel = GetLabelText(vehicleLabel)
						local lock = GetVehicleDoorLockStatus(carstrie[i])
						if lock == 1 or lock == 0 then
							SetVehicleDoorShut(carstrie[i], 0, false)
							SetVehicleDoorShut(carstrie[i], 1, false)
							SetVehicleDoorShut(carstrie[i], 2, false)
							SetVehicleDoorShut(carstrie[i], 3, false)
							SetVehicleDoorsLocked(carstrie[i], 2)
							PlayVehicleDoorCloseSound(carstrie[i], 1)
							ESX.ShowNotification('You have ~r~locked~s~ your ~y~'..vehicleLabel..'~s~.')
							if not IsPedInAnyVehicle(PlayerPedId(), true) then
								TaskPlayAnim(PlayerPedId(), dict, "fob_click_fp", 8.0, 8.0, -1, 48, 1, false, false, false)
							end
							SetVehicleLights(carstrie[i], 2)
							Citizen.Wait(150)
							SetVehicleLights(carstrie[i], 0)
							Citizen.Wait(150)
							SetVehicleLights(carstrie[i], 2)
							Citizen.Wait(150)
							SetVehicleLights(carstrie[i], 0)
							hasAlreadyLocked = true
						elseif lock == 2 then
							SetVehicleDoorsLocked(carstrie[i], 1)
							PlayVehicleDoorOpenSound(carstrie[i], 0)
							ESX.ShowNotification('You have ~g~unlocked~s~ your ~y~'..vehicleLabel..'~s~.')
							if not IsPedInAnyVehicle(PlayerPedId(), true) then
								TaskPlayAnim(PlayerPedId(), dict, "fob_click_fp", 8.0, 8.0, -1, 48, 1, false, false, false)
							end
							SetVehicleLights(carstrie[i], 2)
							Citizen.Wait(150)
							SetVehicleLights(carstrie[i], 0)
							Citizen.Wait(150)
							SetVehicleLights(carstrie[i], 2)
							Citizen.Wait(150)
							SetVehicleLights(carstrie[i], 0)
							hasAlreadyLocked = true
						end
					else
						notowned = notowned + 1
					end
					if notowned == #carstrie then
						ESX.ShowNotification("No vehicles to lock nearby.")
					end	
				end, plate)
			end			
		end
	end
  end
end)

my Server.lua

ESX               = nil

TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

ESX.RegisterServerCallback('carlock:isVehicleOwner', function(source, cb, plate)
	local identifier = GetPlayerIdentifier(source, 0)

	MySQL.Async.fetchAll('SELECT owner FROM owned_vehicles WHERE owner = @owner AND plate = @plate', {
		['@owner'] = identifier,
		['@plate'] = plate
	}, function(result)
		if result[1] then
			cb(result[1].owner == identifier)
		else
			cb(false)
		end
	end)
end)

I can’t get the sound to play. This is the line of code relevant to InteractSound:

TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 10.0, 'cuffsound', 0.1)

And yes, the sound file is referenced in my __resource.lua
Any help appreciated

Any way to make this 3d audio? Like i set a coord and it plays audio from that place but using 3d

For those who still do not work try this to me it worked.

  1. open the main.lua
    from Interaction_sound / server / main.lua

  2. Change the following script:
    TriggerClientEvent (‘InteractSound_CL: PlayWithinDistance’, -1, source, maxDistance, soundFile, soundVolume)
    by:
    TriggerClientEvent (‘LIFE_CL: Sound: PlayWithinDistance’, -1, source, maxDistance, soundFile, soundVolume)

  3. ready try.

PD. sorry for my english


https://gyazo.com/0d5c56ea7ddfc8a4c06f52b5155bade6
i get this error when i try to use a custom sound