2010-08-28 13:47:52 +00:00
|
|
|
#include "teams.h"
|
2010-11-06 22:54:35 +00:00
|
|
|
#include <engine/shared/config.h>
|
2011-02-02 10:49:19 +00:00
|
|
|
#include <engine/server/server.h>
|
2010-08-28 13:47:52 +00:00
|
|
|
|
2011-01-06 05:30:19 +00:00
|
|
|
CGameTeams::CGameTeams(CGameContext *pGameContext) : m_pGameContext(pGameContext)
|
|
|
|
{
|
2010-09-24 13:37:13 +00:00
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
2011-01-06 05:30:19 +00:00
|
|
|
void CGameTeams::Reset()
|
|
|
|
{
|
2010-09-24 13:37:13 +00:00
|
|
|
m_Core.Reset();
|
2011-01-06 05:30:19 +00:00
|
|
|
for(int i = 0; i < MAX_CLIENTS; ++i)
|
|
|
|
{
|
2011-02-02 10:49:19 +00:00
|
|
|
m_TeamState[i] = TEAMSTATE_EMPTY;
|
2010-08-28 13:47:52 +00:00
|
|
|
m_TeeFinished[i] = false;
|
2010-11-06 22:54:35 +00:00
|
|
|
m_MembersCount[i] = 0;
|
2010-12-19 03:48:16 +00:00
|
|
|
m_LastChat[i] = 0;
|
2011-02-02 10:49:19 +00:00
|
|
|
m_TeamLeader[i] = -1;
|
|
|
|
m_TeeJoinTick[i] = -1;
|
2011-02-14 21:34:46 +00:00
|
|
|
m_TeamStrict[i] = g_Config.m_SvTeamStrict;
|
2010-08-28 13:47:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-02 10:49:19 +00:00
|
|
|
void CGameTeams::OnCharacterStart(int ClientID)
|
|
|
|
{
|
2010-08-28 20:53:42 +00:00
|
|
|
int Tick = Server()->Tick();
|
2011-02-02 10:49:19 +00:00
|
|
|
int Team = m_Core.Team(ClientID);
|
|
|
|
CCharacter* StartingChar = Character(ClientID);
|
2010-12-19 03:48:16 +00:00
|
|
|
if(!StartingChar)
|
|
|
|
return;
|
|
|
|
if(StartingChar->m_DDRaceState == DDRACE_FINISHED)
|
|
|
|
StartingChar->m_DDRaceState = DDRACE_NONE;
|
2011-02-02 10:49:19 +00:00
|
|
|
if(Team == TEAM_FLOCK || Team == TEAM_SUPER)
|
2010-12-19 03:48:16 +00:00
|
|
|
{
|
|
|
|
StartingChar->m_DDRaceState = DDRACE_STARTED;
|
|
|
|
StartingChar->m_StartTime = Tick;
|
|
|
|
StartingChar->m_RefreshTime = Tick;
|
|
|
|
}
|
2011-02-14 21:34:46 +00:00
|
|
|
else if(Count(Team) == 1)
|
|
|
|
{
|
|
|
|
if(m_TeamState[Team] <= TEAMSTATE_CLOSED)
|
|
|
|
{
|
|
|
|
ChangeTeamState(Team, TEAMSTATE_STARTED);
|
|
|
|
for(int i = 0; i < MAX_CLIENTS; ++i)
|
|
|
|
{
|
|
|
|
if(Team == m_Core.Team(i))
|
|
|
|
{
|
|
|
|
CCharacter* pChar = Character(i);
|
|
|
|
if(pChar && pChar->IsAlive())
|
|
|
|
{
|
|
|
|
pChar->m_DDRaceState = DDRACE_STARTED;
|
|
|
|
pChar->m_StartTime = Tick;
|
|
|
|
pChar->m_RefreshTime = Tick;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-12-19 03:48:16 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
bool Waiting = false;
|
|
|
|
for(int i = 0; i < MAX_CLIENTS; ++i)
|
|
|
|
{
|
2011-02-02 10:49:19 +00:00
|
|
|
if(Team == m_Core.Team(i))
|
2010-12-19 03:48:16 +00:00
|
|
|
{
|
2011-02-14 18:36:30 +00:00
|
|
|
CCharacter* pChar = Character(i);
|
|
|
|
if(pChar && pChar->IsAlive() && pChar->m_DDRaceState == DDRACE_FINISHED)
|
2010-12-19 03:48:16 +00:00
|
|
|
{
|
|
|
|
Waiting = true;
|
2011-02-02 10:49:19 +00:00
|
|
|
if(m_LastChat[ClientID] + Server()->TickSpeed() + g_Config.m_SvChatDelay < Tick)
|
2010-12-19 03:48:16 +00:00
|
|
|
{
|
|
|
|
char aBuf[128];
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s has finished and didn't go through start yet, wait for him or join another team.", Server()->ClientName(i));
|
2011-02-02 10:49:19 +00:00
|
|
|
GameServer()->SendChatTarget(ClientID, aBuf);
|
|
|
|
m_LastChat[ClientID] = Tick;
|
2010-12-19 03:48:16 +00:00
|
|
|
}
|
|
|
|
if(m_LastChat[i] + Server()->TickSpeed() + g_Config.m_SvChatDelay < Tick)
|
|
|
|
{
|
|
|
|
char aBuf[128];
|
2011-02-02 10:49:19 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "%s wants to start a new round, kill or walk to start.", Server()->ClientName(ClientID));
|
2010-12-19 03:48:16 +00:00
|
|
|
GameServer()->SendChatTarget(i, aBuf);
|
|
|
|
m_LastChat[i] = Tick;
|
|
|
|
}
|
|
|
|
}
|
2011-02-14 18:36:30 +00:00
|
|
|
else if(pChar && pChar->IsAlive() && pChar->m_DDRaceState == DDRACE_STARTED)
|
|
|
|
{
|
|
|
|
Waiting = true;
|
|
|
|
if(m_LastChat[ClientID] + Server()->TickSpeed() + g_Config.m_SvChatDelay < Tick)
|
|
|
|
{
|
|
|
|
char aBuf[128];
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s has started, wait for him, ask him to kill or join another team.", Server()->ClientName(i));
|
|
|
|
GameServer()->SendChatTarget(ClientID, aBuf);
|
|
|
|
m_LastChat[ClientID] = Tick;
|
|
|
|
}
|
|
|
|
}
|
2010-12-19 03:48:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-02 10:49:19 +00:00
|
|
|
if(m_TeamState[Team] <= TEAMSTATE_CLOSED && !Waiting)
|
2010-12-19 03:48:16 +00:00
|
|
|
{
|
2011-02-02 10:49:19 +00:00
|
|
|
ChangeTeamState(Team, TEAMSTATE_STARTED);
|
2010-12-19 03:48:16 +00:00
|
|
|
for(int i = 0; i < MAX_CLIENTS; ++i)
|
|
|
|
{
|
2011-02-02 10:49:19 +00:00
|
|
|
if(Team == m_Core.Team(i))
|
2010-12-19 03:48:16 +00:00
|
|
|
{
|
2011-02-14 18:36:30 +00:00
|
|
|
CCharacter* pChar = Character(i);
|
|
|
|
if(pChar && pChar->IsAlive())
|
2010-12-19 03:48:16 +00:00
|
|
|
{
|
2011-02-14 18:36:30 +00:00
|
|
|
pChar->m_DDRaceState = DDRACE_STARTED;
|
|
|
|
pChar->m_StartTime = Tick;
|
|
|
|
pChar->m_RefreshTime = Tick;
|
2010-12-19 03:48:16 +00:00
|
|
|
}
|
2010-08-28 20:53:42 +00:00
|
|
|
}
|
2010-08-28 13:47:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-02 10:49:19 +00:00
|
|
|
void CGameTeams::OnCharacterFinish(int ClientID)
|
2011-01-06 05:30:19 +00:00
|
|
|
{
|
2011-02-02 10:49:19 +00:00
|
|
|
int Team = m_Core.Team(ClientID);
|
|
|
|
if(Team == TEAM_FLOCK || Team == TEAM_SUPER)
|
2010-12-19 03:48:16 +00:00
|
|
|
{
|
2011-02-02 10:49:19 +00:00
|
|
|
Character(ClientID)->OnFinish();
|
2010-12-19 03:48:16 +00:00
|
|
|
}
|
2011-02-14 21:34:46 +00:00
|
|
|
else if(Count(Team) == 1)
|
|
|
|
{
|
|
|
|
m_TeeFinished[ClientID] = true;
|
|
|
|
if(TeamFinished(Team))
|
|
|
|
{
|
|
|
|
ChangeTeamState(Team, TEAMSTATE_OPEN);
|
|
|
|
Character(ClientID)->OnFinish();
|
|
|
|
m_TeeFinished[ClientID] = false;
|
|
|
|
}
|
|
|
|
}
|
2010-12-19 03:48:16 +00:00
|
|
|
else
|
|
|
|
{
|
2011-02-02 10:49:19 +00:00
|
|
|
m_TeeFinished[ClientID] = true;
|
|
|
|
if(TeamFinished(Team))
|
2010-12-19 03:48:16 +00:00
|
|
|
{
|
2011-02-02 10:49:19 +00:00
|
|
|
ChangeTeamState(Team, TEAMSTATE_OPEN);
|
2010-12-19 03:48:16 +00:00
|
|
|
for(int i = 0; i < MAX_CLIENTS; ++i)
|
|
|
|
{
|
2011-02-02 10:49:19 +00:00
|
|
|
if(Team == m_Core.Team(i))
|
2010-12-19 03:48:16 +00:00
|
|
|
{
|
2011-02-14 21:34:46 +00:00
|
|
|
CCharacter* pChar = Character(i);
|
2011-02-14 18:36:30 +00:00
|
|
|
if(pChar != 0 && pChar->m_DDRaceState == DDRACE_STARTED)
|
2010-12-19 03:48:16 +00:00
|
|
|
{
|
2011-02-14 18:36:30 +00:00
|
|
|
pChar->OnFinish();
|
2010-08-28 20:53:42 +00:00
|
|
|
m_TeeFinished[i] = false;
|
2010-12-19 03:48:16 +00:00
|
|
|
}
|
2010-08-28 20:53:42 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-28 13:47:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-14 18:36:30 +00:00
|
|
|
void CGameTeams::OnCharacterDeath(int ClientID)
|
|
|
|
{
|
2011-02-14 21:34:46 +00:00
|
|
|
if(m_TeamStrict[m_Core.Team(ClientID)] && m_Core.Team(ClientID) != TEAM_FLOCK && m_Core.Team(ClientID) != TEAM_SUPER)
|
2011-02-14 18:36:30 +00:00
|
|
|
{
|
2011-02-14 21:34:46 +00:00
|
|
|
for(int LoopClientID = 0; LoopClientID < MAX_CLIENTS; ++LoopClientID)
|
2011-02-14 18:36:30 +00:00
|
|
|
{
|
2011-02-14 21:34:46 +00:00
|
|
|
if(m_Core.Team(ClientID) == m_Core.Team(LoopClientID))
|
|
|
|
{
|
|
|
|
CCharacter* pChar = Character(LoopClientID);
|
|
|
|
if(pChar)
|
|
|
|
pChar->Die(ClientID, WEAPON_SELF);
|
|
|
|
}
|
2011-02-14 18:36:30 +00:00
|
|
|
}
|
2011-02-14 21:34:46 +00:00
|
|
|
ChangeTeamState(m_Core.Team(ClientID), TEAMSTATE_OPEN);
|
2011-02-14 18:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!g_Config.m_SvStickyTeams && m_Core.Team(ClientID) != TEAM_FLOCK && m_Core.Team(ClientID) != TEAM_SUPER)
|
|
|
|
SetForceCharacterTeam(ClientID, 0);
|
|
|
|
}
|
|
|
|
|
2011-02-02 10:49:19 +00:00
|
|
|
int CGameTeams::SetCharacterTeam(int ClientID, int Team)
|
2011-01-06 05:30:19 +00:00
|
|
|
{
|
2010-09-14 20:36:48 +00:00
|
|
|
//Check on wrong parameters. +1 for TEAM_SUPER
|
2011-02-02 10:49:19 +00:00
|
|
|
if(ClientID < 0 || ClientID >= MAX_CLIENTS || Team < 0 || Team >= MAX_CLIENTS + 1)
|
|
|
|
return ERROR_WRONG_PARAMS;
|
2010-09-14 20:36:48 +00:00
|
|
|
//You can join to TEAM_SUPER at any time, but any other group you cannot if it started
|
2011-02-02 10:49:19 +00:00
|
|
|
if(Team != TEAM_SUPER && m_TeamState[Team] >= TEAMSTATE_CLOSED)
|
|
|
|
return ERROR_CLOSED;
|
2010-09-14 20:36:48 +00:00
|
|
|
//No need to switch team if you there
|
2011-02-02 10:49:19 +00:00
|
|
|
if(m_Core.Team(ClientID) == Team)
|
|
|
|
return ERROR_ALREADY_THERE;
|
2010-09-14 20:36:48 +00:00
|
|
|
//You cannot be in TEAM_SUPER if you not super
|
2011-02-02 10:49:19 +00:00
|
|
|
if(Team == TEAM_SUPER && !Character(ClientID)->m_Super)
|
|
|
|
return ERROR_NOT_SUPER;
|
2010-09-14 20:36:48 +00:00
|
|
|
//if you begin race
|
2011-02-02 10:49:19 +00:00
|
|
|
if(Character(ClientID)->m_DDRaceState != DDRACE_NONE && Team != TEAM_SUPER)
|
|
|
|
return ERROR_STARTED;
|
|
|
|
SetForceCharacterTeam(ClientID, Team);
|
2010-11-06 22:54:35 +00:00
|
|
|
|
2011-02-02 10:49:19 +00:00
|
|
|
return 0;
|
2010-09-22 10:43:59 +00:00
|
|
|
}
|
|
|
|
|
2011-02-02 10:49:19 +00:00
|
|
|
void CGameTeams::SetForceCharacterTeam(int ClientID, int Team)
|
2011-01-06 05:30:19 +00:00
|
|
|
{
|
2011-02-02 10:49:19 +00:00
|
|
|
char aBuf[64];
|
|
|
|
CServer* pServ = (CServer*)Server();
|
|
|
|
CPlayer *pPlayer = GameServer()->m_apPlayers[ClientID];
|
|
|
|
m_TeeFinished[ClientID] = false;
|
|
|
|
int OldTeam = m_Core.Team(ClientID);
|
|
|
|
if(OldTeam != TEAM_FLOCK && OldTeam != TEAM_SUPER && m_TeamState[OldTeam] != TEAMSTATE_EMPTY)
|
2011-01-06 05:30:19 +00:00
|
|
|
{
|
2010-08-28 20:53:42 +00:00
|
|
|
bool NoOneInOldTeam = true;
|
2011-01-06 05:30:19 +00:00
|
|
|
for(int i = 0; i < MAX_CLIENTS; ++i)
|
2011-02-02 10:49:19 +00:00
|
|
|
if(i != ClientID && OldTeam == m_Core.Team(i))
|
2011-01-06 05:30:19 +00:00
|
|
|
{
|
2010-08-28 20:53:42 +00:00
|
|
|
NoOneInOldTeam = false;//all good exists someone in old team
|
|
|
|
break;
|
|
|
|
}
|
2011-01-06 05:30:19 +00:00
|
|
|
if(NoOneInOldTeam)
|
2011-02-02 10:49:19 +00:00
|
|
|
m_TeamState[OldTeam] = TEAMSTATE_EMPTY;
|
2010-08-28 13:47:52 +00:00
|
|
|
}
|
2011-02-02 10:49:19 +00:00
|
|
|
|
|
|
|
m_MembersCount[OldTeam]--;
|
|
|
|
|
|
|
|
m_Core.Team(ClientID, Team);
|
2010-11-12 21:50:51 +00:00
|
|
|
|
2011-02-14 18:36:30 +00:00
|
|
|
if(Team != TEAM_SUPER)
|
2011-01-06 05:22:08 +00:00
|
|
|
{
|
2011-02-02 10:49:19 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "\'%s\' joined team %d.", pServ->ClientName(pPlayer->GetCID()), Team);
|
|
|
|
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
2010-11-12 21:50:51 +00:00
|
|
|
}
|
2011-02-02 10:49:19 +00:00
|
|
|
if(Count(OldTeam) > 0)
|
|
|
|
m_TeeJoinTick[ClientID] = Server()->Tick();
|
2010-08-28 13:47:52 +00:00
|
|
|
|
2011-02-02 10:49:19 +00:00
|
|
|
if(Team != TEAM_SUPER)
|
|
|
|
m_MembersCount[Team]++;
|
2010-11-06 22:54:35 +00:00
|
|
|
|
2011-02-02 10:49:19 +00:00
|
|
|
if(Team != TEAM_SUPER && m_TeamState[Team] == TEAMSTATE_EMPTY)
|
|
|
|
ChangeTeamState(Team, TEAMSTATE_OPEN);
|
|
|
|
|
|
|
|
if(OldTeam != TEAM_FLOCK && OldTeam != TEAM_SUPER && ClientID == GetTeamLeader(OldTeam))
|
|
|
|
{
|
2011-02-10 00:50:18 +00:00
|
|
|
if(Count(OldTeam) > 1)
|
2011-02-02 10:49:19 +00:00
|
|
|
{
|
|
|
|
int FirstJoinedID = -1;
|
|
|
|
int Tick = Server()->Tick();
|
|
|
|
for (int LoopCID = 0; LoopCID < MAX_CLIENTS; ++LoopCID)
|
|
|
|
if(m_Core.Team(LoopCID) == OldTeam)
|
|
|
|
if(m_TeeJoinTick[LoopCID] < Tick)
|
2011-02-10 00:50:18 +00:00
|
|
|
{
|
2011-02-02 10:49:19 +00:00
|
|
|
FirstJoinedID = LoopCID;
|
2011-02-10 00:50:18 +00:00
|
|
|
Tick = m_TeeJoinTick[LoopCID];
|
|
|
|
}
|
|
|
|
if(FirstJoinedID != -1)
|
|
|
|
SetTeamLeader(OldTeam, FirstJoinedID);
|
|
|
|
}
|
|
|
|
else if(Count(OldTeam))
|
|
|
|
{
|
|
|
|
for (int LoopCID = 0; LoopCID < MAX_CLIENTS; ++LoopCID)
|
|
|
|
if(m_Core.Team(LoopCID) == OldTeam)
|
|
|
|
{
|
|
|
|
SetTeamLeader(OldTeam, LoopCID);
|
|
|
|
break;
|
|
|
|
}
|
2011-02-02 10:49:19 +00:00
|
|
|
}
|
|
|
|
else
|
2011-02-14 21:34:46 +00:00
|
|
|
{
|
2011-02-02 10:49:19 +00:00
|
|
|
SetTeamLeader(OldTeam, -1);
|
2011-02-14 21:34:46 +00:00
|
|
|
m_TeamStrict[OldTeam] = g_Config.m_SvTeamStrict;
|
|
|
|
}
|
2011-02-02 10:49:19 +00:00
|
|
|
}
|
2010-11-06 22:54:35 +00:00
|
|
|
|
2011-02-02 10:49:19 +00:00
|
|
|
dbg_msg1("Teams", "Id = %d Team = %d", ClientID, Team);
|
|
|
|
|
|
|
|
for (int LoopCID = 0; LoopCID < MAX_CLIENTS; ++LoopCID)
|
|
|
|
{
|
|
|
|
if(Character(LoopCID) && Character(LoopCID)->GetPlayer()->m_IsUsingDDRaceClient)
|
|
|
|
SendTeamsState(LoopCID);
|
|
|
|
}
|
|
|
|
}
|
2010-11-06 22:54:35 +00:00
|
|
|
|
2011-02-02 10:49:19 +00:00
|
|
|
int CGameTeams::Count(int Team) const
|
2011-01-06 05:30:19 +00:00
|
|
|
{
|
2011-02-02 10:49:19 +00:00
|
|
|
if(Team == TEAM_SUPER)
|
|
|
|
return -1;
|
|
|
|
return m_MembersCount[Team];
|
2010-08-28 13:47:52 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 05:30:19 +00:00
|
|
|
bool CGameTeams::TeamFinished(int Team)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < MAX_CLIENTS; ++i)
|
2011-02-14 18:36:30 +00:00
|
|
|
{
|
|
|
|
CCharacter *pChar = (GameServer()->m_apPlayers[i]) ? GameServer()->m_apPlayers[i]->GetCharacter() : 0;
|
|
|
|
if(pChar)
|
|
|
|
if(m_Core.Team(i) == Team && (!m_TeeFinished[i] && pChar->m_DDRaceState == DDRACE_STARTED))
|
|
|
|
return false;
|
|
|
|
}
|
2010-08-28 13:47:52 +00:00
|
|
|
return true;
|
2010-09-08 16:22:11 +00:00
|
|
|
}
|
|
|
|
|
2011-01-26 20:57:23 +00:00
|
|
|
int CGameTeams::TeamMask(int Team, int ExceptID)
|
2011-01-06 05:30:19 +00:00
|
|
|
{
|
2010-09-14 20:36:48 +00:00
|
|
|
if(Team == TEAM_SUPER) return -1;
|
2010-09-08 16:22:11 +00:00
|
|
|
int Mask = 0;
|
2011-01-06 05:30:19 +00:00
|
|
|
for(int i = 0; i < MAX_CLIENTS; ++i)
|
2011-01-26 20:57:23 +00:00
|
|
|
if(i != ExceptID)
|
|
|
|
if((Character(i) && (m_Core.Team(i) == Team || m_Core.Team(i) == TEAM_SUPER))
|
|
|
|
|| (GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() == -1))
|
|
|
|
Mask |= 1 << i;
|
2010-09-08 16:22:11 +00:00
|
|
|
return Mask;
|
|
|
|
}
|
2010-10-24 10:47:25 +00:00
|
|
|
|
2011-02-02 10:49:19 +00:00
|
|
|
void CGameTeams::SendTeamsState(int ClientID)
|
2011-01-06 05:30:19 +00:00
|
|
|
{
|
2010-10-24 10:47:25 +00:00
|
|
|
CNetMsg_Cl_TeamsState Msg;
|
|
|
|
Msg.m_Tee0 = m_Core.Team(0);
|
|
|
|
Msg.m_Tee1 = m_Core.Team(1);
|
|
|
|
Msg.m_Tee2 = m_Core.Team(2);
|
|
|
|
Msg.m_Tee3 = m_Core.Team(3);
|
|
|
|
Msg.m_Tee4 = m_Core.Team(4);
|
|
|
|
Msg.m_Tee5 = m_Core.Team(5);
|
|
|
|
Msg.m_Tee6 = m_Core.Team(6);
|
|
|
|
Msg.m_Tee7 = m_Core.Team(7);
|
|
|
|
Msg.m_Tee8 = m_Core.Team(8);
|
|
|
|
Msg.m_Tee9 = m_Core.Team(9);
|
|
|
|
Msg.m_Tee10 = m_Core.Team(10);
|
|
|
|
Msg.m_Tee11 = m_Core.Team(11);
|
|
|
|
Msg.m_Tee12 = m_Core.Team(12);
|
|
|
|
Msg.m_Tee13 = m_Core.Team(13);
|
|
|
|
Msg.m_Tee14 = m_Core.Team(14);
|
|
|
|
Msg.m_Tee15 = m_Core.Team(15);
|
|
|
|
|
2011-02-02 10:49:19 +00:00
|
|
|
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID);
|
2010-10-24 10:47:25 +00:00
|
|
|
|
|
|
|
}
|
2011-02-02 10:49:19 +00:00
|
|
|
|
|
|
|
void CGameTeams::SetTeamLeader(int Team, int ClientID)
|
|
|
|
{
|
|
|
|
if(Team == TEAM_FLOCK || Team == TEAM_SUPER)
|
|
|
|
return;
|
|
|
|
m_TeamLeader[Team] = ClientID;
|
2011-02-10 00:50:18 +00:00
|
|
|
if(ClientID == -1)
|
|
|
|
return;
|
|
|
|
char aBuf[64];
|
2011-02-02 10:49:19 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "\'%s\' is now the team %d leader.", Server()->ClientName(ClientID), Team);
|
|
|
|
if(Count(Team) > 1)
|
2011-02-13 05:35:13 +00:00
|
|
|
for (int LoopClientID = 0; LoopClientID < MAX_CLIENTS; ++LoopClientID)
|
|
|
|
if(LoopClientID != ClientID)
|
|
|
|
if(m_Core.Team(LoopClientID) == Team)
|
|
|
|
GameServer()->SendChatTarget(LoopClientID, aBuf);
|
2011-02-02 10:49:19 +00:00
|
|
|
|
|
|
|
str_format(aBuf, sizeof(aBuf), "You are now the team %d leader.", Team);
|
|
|
|
GameServer()->SendChatTarget(ClientID, aBuf);
|
|
|
|
}
|
2011-02-14 21:34:46 +00:00
|
|
|
|
|
|
|
int CGameTeams::ToggleStrictness(int Team)
|
|
|
|
{
|
|
|
|
char aBuf[64];
|
|
|
|
str_format(aBuf, sizeof(aBuf), "\'%s\' Toggled Team Strictness to %d.", Server()->ClientName(m_TeamLeader[Team]), m_TeamStrict[Team]);
|
|
|
|
if(Count(Team) > 1)
|
|
|
|
{
|
|
|
|
for (int LoopClientID = 0; LoopClientID < MAX_CLIENTS; ++LoopClientID)
|
|
|
|
if(m_Core.Team(LoopClientID) == Team)
|
|
|
|
GameServer()->SendChatTarget(LoopClientID, aBuf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
GameServer()->SendChatTarget(m_TeamLeader[Team], aBuf);
|
|
|
|
|
|
|
|
return m_TeamStrict[Team] = !m_TeamStrict[Team];
|
|
|
|
}
|