--server side
sounds = {
{"song.mp3"},
{"song2.mp3"},
{"song3.mp3"}
}
addEvent("playrandom",true)
addEventHandler("playrandom",root,function()
ra=math.random(#sounds)
file=sounds[ra]
filename=split(file,".")[1]
outputChatBox("the file will played is "..filename,root,255,255,255,true)
triggerClientEvent(root,"playthesound",root,file)
end)
--client
addEvent("playthesound",true)
addEventHandler("playthesound",root,function(file)
if(sound and isElement(sound)) then destroyElement(sound) end
sound=playSound(file)
length_s=getSoundLength(sound)
setTimer(function()
triggerServerEvent("playrandom",localPlayer)
end,((length_s*1000 > 50 and length_s*1000) or 50),1)
end)
بالتوفيق @salh