• If traitors win the round after innocents win?
    3 replies, posted
I have this code for my round end music script: [lua] if win == WIN_INNOCENT then BroadcastLua('surface.PlaySound("'..InnocentWinSounds[math.random(1, #InnocentWinSounds)]..'")') [/lua] I'm trying to make it so a sound would play the round after the traitors win but only if the innocents won the round before that one. Does anyone have an idea on how to do this?
Common sense says that you would keep track of the previously won group, and then compare it to the current rounds winning group.
I would set a variable based on who wins a round, and have it check that variable before playing the sound. After playing the noise, have it set the variable to be checked for next round. edit: maybe something like this. [CODE] if win == WIN_INNOCENT then if lastroundwin == WIN_TRAITOR then --play sounds you want here else BroadcastLua('surface.PlaySound("'..InnocentWinSounds[math.random(1, #InnocentWinSounds)]..'")') end [/CODE]
Okay so I haven't tested it but this is what I came up with for anyone that's wondering: [lua] local function PlaySoundClip(win) if win == WIN_INNOCENT then BroadcastLua('surface.PlaySound("'..InnocentWinSounds[math.random(1, #InnocentWinSounds)]..'")') if LastRoundWin == WIN_INNOCENT then TwoRoundsAgoWin = WIN_INNOCENT end LastRoundWin = WIN_INNOCENT elseif win == WIN_TRAITOR then if LastRoundWin == WIN_TRAITOR then TwoRoundsAgoWin = WIN_TRAITOR elseif TwoRoundsAgoWin == WIN_INNOCENT then BroadcastLua('surface.PlaySound("'..TraitorsBackSounds[math.random(1, #TraitorsBackSounds)]..'")') else BroadcastLua('surface.PlaySound("'..TraitorWinSounds[math.random(1, #TraitorWinSounds)]..'")') end LastRoundWin = WIN_TRAITOR elseif win == WIN_TIMELIMIT then BroadcastLua('surface.PlaySound("'..OutOfTimeSounds[math.random(1, #OutOfTimeSounds)]..'")') if LastRoundWin == WIN_TIMELIMIT then TwoRoundsAgoWin = WIN_TIMELIMIT end LastRoundWin = WIN_TIMELIMIT end end [/lua]In theory, it should play the TraitorsBackSounds only if the innocents win two rounds in a row before the traitors win.
Sorry, you need to Log In to post a reply to this thread.