Hi guys im trying to add music to my server but im having error which is server/main.lua:13: unexpected symbol near ‘,’
Failed to load script server/main.lua. Does anyone have any idea about how to solve it? or any another ideas to add in game music?
this one is __resource.lua
resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'
client_script 'client/main.lua'
server_script 'server/main.lua'
ui_page('client/html/index.html')
files({
'client/html/index.html',
'client/html/sounds/demi.ogg'
This one is server main.lua
RegisterServerEvent('InteractSound_SV:PlayOnAll')
AddEventHandler('InteractSound_SV:PlayOnAll',
function(soundFile, soundVolume)
TriggerClientEvent('InteractSound_CL:PlayOnAll', -1,
soundFile ('demi.ogg'),
soundVolume (1))
end)
This one is client main.lua
local standardVolumeOutput = 1.0;
RegisterNetEvent('LIFE_CL:Sound:PlayOnAll')
AddEventHandler('LIFE_CL:Sound:PlayOnAll', function(soundFile, soundVolume)
SendNUIMessage({
transactionType = 'playSound',
transactionFile = soundFile('client/html/sounds/demi.ogg'),
transactionVolume = soundVolume(1)
})
end)
and the last one index.html
<html>
<head>
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.1.1/howler.min.js" type="text/javascript"></script>
<script>
var audioPlayer = null;
window.addEventListener('message', function(event) {
if (event.data.transactionType == "playSound") {
if (audioPlayer != null) {
audioPlayer.pause();
}
audioPlayer = new Howl({src: ["./sounds/" + event.data.transactionFile + ".ogg"]});
audioPlayer.volume(event.data.transactionVolume);
audioPlayer.play();
}
});
</script>
</head>
</html>