I'm editing an existing mutator (just a single class) to build a kind of simple LobbyMusic mutator, that shutdowns map music and starts a new music when game ends and mapvote shows up.
this is the working code for a single music:
Code: Select all
class LobbyMusic extends Mutator;
#exec NEW MUSICFACTORY FILE=Music\song1.wav NAME=song1
var bool LobbyMusicIsOn;
function PostBeginPlay()
{
SetTimer(4.0,true);
}
function bool AlwaysKeep(Actor Other)
{
if (NextMutator != None)
return (NextMutator.AlwaysKeep(Other));
return false;
}
function Timer()
{
if (Level.Game.bGameEnded)
{
if (LobbyMusicIsOn == False)
{
ShutDownLevelMusic();
LobbyMusicIsOn=True;
}
}
}
function ShutDownLevelMusic()
{
local Pawn A;
A = Level.PawnList;
While (A != None)
{
if (A.IsA('PlayerPawn'))
PlayerPawn(A).ClientSetMusic(Music'song1', 0, 255, MTRAN_Fade);
A = A.nextPawn;
}
}
defaultproperties
{
LobbyMusicIsOn=False
}
I'm not a programmer with a good knowledge of UnrealScript so I can't understand the type of error. This is the code:
Code: Select all
class LobbyMusic extends Mutator;
// #exec NEW MUSICFACTORY FILE=Music\song1.wav NAME=song1
#exec NEW MUSICFACTORY FILE=Music\song0.wav NAME=song0
#exec NEW MUSICFACTORY FILE=Music\song1.wav NAME=song1
#exec NEW MUSICFACTORY FILE=Music\song2.wav NAME=song2
#exec NEW MUSICFACTORY FILE=Music\song3.wav NAME=song3
var bool LobbyMusicIsOn;
var int cSong;
const nSongs = 4;
var string sSongs[4];
sSongs[0]=song0;
sSongs[0]=song1;
sSongs[0]=song2;
sSongs[0]=song3;
function PostBeginPlay()
{
SetTimer(4.0,true);
}
function bool AlwaysKeep(Actor Other)
{
if (NextMutator != None)
return (NextMutator.AlwaysKeep(Other));
return false;
}
function Timer()
{
if (Level.Game.bGameEnded)
{
if (LobbyMusicIsOn == False)
{
ShutDownLevelMusic();
LobbyMusicIsOn=True;
}
}
}
function ShutDownLevelMusic()
{
local Pawn A;
A = Level.PawnList;
While (A != None)
{
if (A.IsA('PlayerPawn'))
// PlayerPawn(A).ClientSetMusic(Music'song1', 0, 255, MTRAN_Fade);
cSong = rand(nSongs);
PlayerPawn(A).ClientSetMusic(sSongs[cSong], 0, 255, MTRAN_Fade);
A = A.nextPawn;
}
}
defaultproperties
{
LobbyMusicIsOn=False
}
cheers,
Pietro