LUA, Random Music playing.

I found this code:


local function PlayMusic(wintype)
if wintype == WIN_INNOCENT then

local choice = math.random( 1, 7 )
if ( choice == 1 ) then
BroadcastLua('surface.PlaySound("ttt/innocentwin1.mp3")')


But i don’t think it is finished, Can anyone help me finish it? This is what I have so far:



local function PlayMusic(wintype)
if wintype == WIN_INNOCENT then

local choice = math.random( 1, 7 )
if ( choice == 1 ) then
BroadcastLua('surface.PlaySound("ttt/innocentwin1.mp3")')
else
if ( choice == 2 ) then
BroadcastLua('surface.PlaySound("ttt/innocentwin2.mp3")')
else
if ( choice == 3 ) then
BroadcastLua('surface.PlaySound("ttt/innocentwin3.mp3")')
else
if ( choice == 4 ) then
BroadcastLua('surface.PlaySound("ttt/innocentwin4.mp3")')
else
if ( choice == 5 ) then
BroadcastLua('surface.PlaySound("ttt/innocentwin5.mp3")')
else
if ( choice == 6 ) then
BroadcastLua('surface.PlaySound("ttt/innocentwin6.mp3")')
else
if ( choice == 7 ) then
BroadcastLua('surface.PlaySound("ttt/innocentwin7.mp3")')
end
if wintype == WIN_TRAITOR then
local choice = math.random( 1, 7 )
if ( choice == 1 ) then
BroadcastLua('surface.PlaySound("ttt/traitorwin1.mp3")')
else
if ( choice == 2 ) then
BroadcastLua('surface.PlaySound("ttt/traitorwin2.mp3")')
else
if ( choice == 3 ) then
BroadcastLua('surface.PlaySound("ttt/traitorwin3.mp3")')
else
if ( choice == 4 ) then
BroadcastLua('surface.PlaySound("ttt/traitorwin4.mp3")')
else
if ( choice == 5 ) then
BroadcastLua('surface.PlaySound("ttt/traitorwin5.mp3")')
else
if ( choice == 6 ) then
BroadcastLua('surface.PlaySound("ttt/traitorwin6.mp3")')
else
if ( choice == 7 ) then
BroadcastLua('surface.PlaySound("ttt/traitorwin7.mp3")')
end


I’m not sure if that is correct though.



local function PlayMusic(wintype)
    local choice = math.random( 1, 7 )
    if wintype == WIN_INNOCENT then
        BroadcastLua('surface.PlaySound("ttt/innocentwin"..choice..".mp3")')
    else
        BroadcastLua('surface.PlaySound("ttt/traitorwin"..choice..".mp3")')
    end
end


Here is the correct/cleaned up code, add it to the correct hook.