63
« on: Saturday, January 31, 2015, 09:07:43 AM »
ok My SwapTeamsMod now works, an admin can type 'mutate switchsides' in console and it will swapteams (do this after the round has ended otherwise you will end the round by doing it) , The message "Changing to [ASSAULT/DEFENSE"] Next round!" still pops up but there is no remain button so everyone is forced to switch they can always try to switch back. There's a HalfTime
example:
If you set the game to 10 rounds assault wins 3 defense wins 2 after the round that makes assault score + defense score (3 + 2) (so after round 5) equal to the amount of rounds divided by 2 (so half, 10 / 2) so when the 6th round goes to start it will automatically end the round (no score no chance to spawn) , swap teams, then start the next round. when you swap teams theres also a red console message for everyone "[AA25] HalfTime... Switching Sides!" . There is also an ini file with 1 setting "bSwitchAtHalfTime" true is on false is off.
If anyone would like to download let me know ill upload it to the Brothers N Arms Download Gallery.
AdminSwitchTeams.uc:
class AdminTeamSwitch extends mutator config (ATS);
var config bool bSwitchAtHalftime;
event PreBeginPlay ()
{
Level.Game.BaseMutator.AddMutator(self);
Log("This mod is property of the [BA]^ Brothers N Arms Clan !",'LEEFFM');
Log("This mod is made by [BA]^LEEFFM",'LEEFFM');
Log("LEEFFM'S Switch Teams Mod Is Loaded",'LEEFFM');
}
function ModifyPlayer (Pawn Other)
{
if (bSwitchAtHalfTime)
{
HalfTimeSwitchSides () ;
} else
{
Log("HalfTime Disabled",'LEEFFM') ;
}
}
function Mutate (string MutateString, PlayerController Sender)
{
local array<string> Parts ;
local HumanController HC ;
local string Command ;
local string Option ;
HC = HumanController(Sender);
Split( MutateString, " ", Parts);
Command = caps(Parts[0]) ;
Option = caps(Parts[1]) ;
if (HC.PlayerReplicationInfo.bAdmin)
{
switch (Command)
{
case "switchteams":
SwitchSides () ;
break;
default:
HC.ClientMessage ("Type 'mutate switchteams' to switch Team Sides!") ;
break;
}
} else
{
HC.NotifyAdminMessage("'mutate switchteams' is an Administrator only command!") ;
}
}
state HalfTime
{
function BeginState ()
{
Level.Game.Endgame (none,"Switching Teams for HalfTime!") ;
settimer(5,true);
}
function Timer ()
{
SwitchSides () ;
settimer(0,true);
}
}
function HalfTimeSwitchSides ()
{
local int RoundsPerMatch;
local int RemainingRounds;
local int MidGame;
local int HalfTime;
RoundsPerMatch = Level.Game.GameReplicationInfo.RoundsPerMatch ;
RemainingRounds = Level.Game.GameReplicationInfo.RemainingRounds ;
MidGame = RoundsPerMatch / 2 ;
HalfTime = Level.Game.GameReplicationInfo.Teams[0].TeamScore + Level.Game.GameReplicationInfo.Teams[1].TeamScore ;
switch (HalfTime)
{
case MidGame:
GoToState ('HalfTime');
break;
default:
Log("Halftime is not equal to MidGame!",'LEEFFM');
break;
}
}
function SwitchSides ()
{
local HumanController HC;
local int PlayerID;
local int i;
PlayerID = HC.PlayerReplicationInfo.PlayerID ;
for (i = 0; i < Level.Game.GameReplicationInfo.PRIArray.Length; i++)
{
HC = HumanController(Level.Game.GameReplicationInfo.PRIArray[i].GetController());
switch (HC.PlayerReplicationInfo.Team.TeamIndex)
{
case 0:
SwapPlayer (HC,1) ;
break;
case 1:
SwapPlayer (HC,0) ;
break;
}
}
}
function SwapPlayer (HumanController HC, int NewTeam)
{
ChangeTeam (HC,NewTeam) ;
AGP_TeamInfo(HC.PlayerReplicationInfo.Team).ClearPlayerRequests(HC.PlayerReplicationInfo);
AGP_TeamInfo(HC.PlayerReplicationInfo.Team).AddToNoRequestList(HC.PlayerReplicationInfo,False);
}
function ChangeTeam (Controller C, int Team)
{
local int OldTeam;
local int NewTeam;
if (Team < 2)
{
OldTeam = C.PlayerReplicationInfo.Team.TeamIndex ;
NewTeam = Team;
} else
{
return;
}
if (C.PlayerReplicationInfo.Team.TeamIndex == NewTeam)
{
return;
}
C.StartSpot= none;
if (C.PlayerReplicationInfo.Team != None)
{
HumanController(C).PlayerReplicationInfo.Team.RemoveFromTeam(C);
HumanController(C).RequestChangeTeam(NewTeam);
}
if (Level.Game.GameReplicationInfo.Teams[NewTeam].AddToTeam(C))
{
HumanController(C).ClientMessage ("?[AA25] HalfTime... Switching Sides!") ;
}
}
defaultproperties
{
bSwitchAtHalfTime = true
}