Xonotic
sv_kick_teamkiller.qc
Go to the documentation of this file.
1 #include "sv_kick_teamkiller.qh"
2 
5 
7 
8 MUTATOR_HOOKFUNCTION(kick_teamkiller, PlayerDies)
9 {
10  if (!teamplay)
11  {
12  return;
13  }
14  if (warmup_stage)
15  {
16  return;
17  }
18  entity attacker = M_ARGV(1, entity);
19  if (!IS_REAL_CLIENT(attacker))
20  {
21  return;
22  }
23 
24  int teamkills = PlayerScore_Get(attacker, SP_TEAMKILLS);
25  // use the players actual playtime
26  float playtime = time - CS(attacker).startplaytime;
27  // rate is in teamkills/minutes, playtime in seconds
28  if (teamkills >= autocvar_g_kick_teamkiller_lower_limit &&
29  teamkills >= autocvar_g_kick_teamkiller_rate*playtime/60.0)
30  {
31  if (dropclient_schedule(attacker))
32  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_KICK_TEAMKILL, attacker.netname);
33  }
34 }
MUTATOR_HOOKFUNCTION(kick_teamkiller, PlayerDies)
#define PlayerScore_Get(player, scorefield)
Returns the player's score.
Definition: scores.qh:43
entity() spawn
ClientState CS(Client this)
Definition: state.qh:47
bool warmup_stage
Definition: main.qh:103
bool dropclient_schedule(entity this)
Schedules dropclient for a player and returns true; if dropclient is already scheduled (for that play...
Definition: main.qc:42
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
REGISTER_MUTATOR(kick_teamkiller,(autocvar_g_kick_teamkiller_rate > 0))
#define NULL
Definition: post.qh:17
float autocvar_g_kick_teamkiller_lower_limit
float teamplay
Definition: progsdefs.qc:31
#define M_ARGV(x, type)
Definition: events.qh:17
float time
Definition: csprogsdefs.qc:16
float autocvar_g_kick_teamkiller_rate