}
}
-void MoveToTeam(entity client, int team_colour, int type)
+bool MoveToTeam(entity client, int team_colour, int type)
{
+ if (client.team == teamnum)
+ {
+ return true;
+ }
+ if (MUTATOR_CALLHOOK(Player_ChangeTeam, client, Team_TeamToNumber(
+ client.team), Team_TeamToNumber(team_colour)) == true)
+ {
+ // Mutator has blocked team change.
+ return false;
+ }
int lockteams_backup = lockteams; // backup any team lock
lockteams = 0; // disable locked teams
+ int oldteam = client.team;
TeamchangeFrags(client); // move the players frags
SetPlayerColors(client, team_colour - 1); // set the players colour
Damage(client, client, client, 100000, DEATH_AUTOTEAMCHANGE.m_id, client.origin, '0 0 0'); // kill the player
lockteams = lockteams_backup; // restore the team lock
LogTeamchange(client.playerid, client.team, type);
+ MUTATOR_CALLHOOK(Player_ChangedTeam, client, oldteam, client.team);
+ return true;
}
/** print(), but only print if the server is not local */
void ClientKill_Now_TeamChange(entity this);
-void MoveToTeam(entity client, float team_colour, float type);
+/// \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, vector hitloc, vector force);
bool SetPlayerTeamSimple(entity player, int teamnum)
{
- if (player.team == teamnum)
- {
- return true;
- }
- if (MUTATOR_CALLHOOK(Player_ChangeTeam, player, Team_TeamToNumber(
- player.team), Team_TeamToNumber(teamnum)) == true)
- {
- // Mutator has blocked team change.
- return false;
- }
- int oldteam = player.team;
- SetPlayerColors(player, teamnum - 1);
- MUTATOR_CALLHOOK(Player_ChangedTeam, player, oldteam, player.team);
- return true;
+ return MoveToTeam(player, teamnum, 6);
}
void SetPlayerTeam(entity pl, float t, float s, float noprint)