// If so, lets continue and finally move the player
client.team_forced = 0;
- if (MoveToTeam(client, team_id, 6))
+ if (MoveToTeam(client, Team_TeamToIndex(team_id), 6))
{
successful = strcat(successful, (successful ? ", " : ""), playername(client, false));
LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", playername(client, false), ") has been moved to the ", Team_ColoredFullName(team_id), "^7.");
int team_index = 0;
FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, {
- int target_team_number = Team_IndexToTeam(team_index + 1);
- if (it.team != target_team_number) MoveToTeam(it, target_team_number, 6);
+ int target_team_index = team_index + 1;
+ if (Entity_GetTeamIndex(it) != target_team_index)
+ {
+ MoveToTeam(it, target_team_index, 6);
+ }
team_index = (team_index + 1) % number_of_teams;
});
// WEAPONTODO
#define DMG_NOWEP (weaponentities[0])
-float lockteams;
-
float sv_maxidle;
float sv_maxidle_spectatorsareidle;
int sv_maxidle_slots;
}
}
-bool MoveToTeam(entity client, int team_colour, int type)
-{
- int lockteams_backup = lockteams; // backup any team lock
- lockteams = 0; // disable locked teams
- TeamchangeFrags(client); // move the players frags
- if (!Player_SetTeamIndex(client, Team_TeamToIndex(team_colour)))
- {
- return false;
- }
- KillPlayerForTeamChange(client);
- lockteams = lockteams_backup; // restore the team lock
- LogTeamchange(client.playerid, client.team, type);
- return true;
-}
-
/** print(), but only print if the server is not local */
void dedicated_print(string input)
{
void ClientKill_Now_TeamChange(entity this);
-/// \brief Moves player to the specified team.
-/// \param[in,out] client Client to move.
-/// \param[in] team_colour Color of the team.
-/// \param[in] type ???
-/// \return True on success, false otherwise.
-bool MoveToTeam(entity client, float team_colour, float type);
-
void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force);
int Say(entity source, float teamsay, entity privatesay, string msgin, float floodcontrol);
return true;
}
+bool MoveToTeam(entity client, int team_index, int type)
+{
+ int lockteams_backup = lockteams; // backup any team lock
+ lockteams = 0; // disable locked teams
+ TeamchangeFrags(client); // move the players frags
+ if (!Player_SetTeamIndex(client, team_index))
+ {
+ lockteams = lockteams_backup; // restore the team lock
+ return false;
+ }
+ KillPlayerForTeamChange(client);
+ lockteams = lockteams_backup; // restore the team lock
+ LogTeamchange(client.playerid, client.team, type);
+ return true;
+}
+
void KillPlayerForTeamChange(entity player)
{
if (IS_DEAD(player))
#pragma once
+bool lockteams;
+
+// ========================== Global teams API ================================
+
/// \brief Returns the global team entity at the given index.
/// \param[in] index Index of the team.
/// \return Global team entity at the given index.
/// \return Global team entity that corresponds to the given TEAM_NUM value.
entity Team_GetTeam(int team_num);
+// ========================= Team specific API ================================
+
/// \brief Returns the score of the team.
/// \param[in] team_ Team entity.
/// \return Score of the team.
void LogTeamchange(float player_id, float team_number, float type);
+// ======================= Entity specific API ================================
+
void setcolor(entity this, int clr);
/// \brief Returns whether the given entity belongs to a valid team.
bool SetPlayerTeam(entity player, int destination_team_index,
int source_team_index, bool no_print);
+/// \brief Moves player to the specified team.
+/// \param[in,out] client Client to move.
+/// \param[in] team_index Index of the team.
+/// \param[in] type ???
+/// \return True on success, false otherwise.
+bool MoveToTeam(entity client, int team_index, float type);
+
/// \brief Kills player as a result of team change.
/// \param[in,out] player Player to kill.
void KillPlayerForTeamChange(entity player);