So I’m new to this and recently I’ve downloaded this script. First I tried creating a command which plays a sound for me, but I failed.
A screenshot from the directory.
This is the command in my client main.lua:
RegisterCommand("playSoundFM", function(source,args)
print("debug1")
TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 1.0, 'seatbelt-buckle', 1.0)
end, false)
And in server main.lua file this is the event:
RegisterServerEvent('InteractSound_SV:PlayWithinDistance')
AddEventHandler('InteractSound_SV:PlayWithinDistance', function(maxDistance, soundFile, soundVolume)
print("debug2")
TriggerClientEvent('InteractSound_CL:PlayWithinDistance', -1, source, maxDistance, soundFile, soundVolume)
end)
(important that debug2 is not being printed)
This is client PLayWithinDistance:
RegisterNetEvent('LIFE_CL:Sound:PlayWithinDistance')
AddEventHandler('LIFE_CL:Sound:PlayWithinDistance', function(playerNetId, maxDistance, soundFile, soundVolume)
local lCoords = GetEntityCoords(GetPlayerPed(-1))
local eCoords = GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(playerNetId)))
local distIs = Vdist(lCoords.x, lCoords.y, lCoords.z, eCoords.x, eCoords.y, eCoords.z)
if(distIs <= maxDistance) then
SendNUIMessage({
transactionType = 'playSound',
transactionFile = soundFile,
transactionVolume = soundVolume
})
end
end)
(I’m literally using default stuff from the interact-sound script and a custom command.)