For monkeys sake, I've been fooling around with this for ages. No matter how I try to get a sound to play using lua, it doesnt work.
It works with 'play' in console.
It works in an old swep I made
but in this script, no matter what I try, it won't (@*# play.
function PickRandSong()
GTMSongList = _file.Find( "sound/"..GTM.SongFolder.."*.mp3" );
GTMSongNum = table.getn(GTMSongList)
if GTMSongNum <= 3 then
local more = 4 - GTMSongNum
_PrintMessageAll(HUD_PRINTTALK, "You cant play with less than 4 songs! Add at least "..more.." more songs and try again.\n")
_PrintMessageAll(HUD_PRINTCONSOLE, "You cant play with less than 4 songs! Add at least "..more.." more songs and try again.\n")
return;
end
GTMSongPlayingNum = math.random(1,GTMSongNum)
_Msg("Picked: "..GTMSongPlayingNum.."\n")
_PlaySound( ""..GTM.SongFolder..GTMSongList[GTMSongPlayingNum].."\n")
_Msg( ""..GTM.SongFolder..GTMSongList[GTMSongPlayingNum].."\n")
end