Well, it is very dirty, but it works.
There is a patch :
diff -u -r teeworlds-0.4.2-src/src/game/server/gs_common.h teeworlds-0.4.2-src-mod/src/game/server/gs_common.h
--- teeworlds-0.4.2-src/src/game/server/gs_common.h 2008-04-05 15:13:02.000000000 +0200
+++ teeworlds-0.4.2-src-mod/src/game/server/gs_common.h 2008-05-17 17:58:09.000000000 +0200
@@ -321,6 +321,11 @@
//
int64 last_chat;
+ // punishment informations
+ int punishment_time;
+ int last_teamkills_ticks[10];
+ int punishment_count;
+
//
player();
void init();
@@ -352,6 +357,9 @@
virtual bool take_damage(vec2 force, int dmg, int from, int weapon);
virtual void snap(int snaping_client);
+
+ void set_punishment_time(int time);
+ void teamkill_logging(int server_tick);
};
extern player *players;
diff -u -r teeworlds-0.4.2-src/src/game/server/gs_game.cpp teeworlds-0.4.2-src-mod/src/game/server/gs_game.cpp
--- teeworlds-0.4.2-src/src/game/server/gs_game.cpp 2008-04-05 15:13:02.000000000 +0200
+++ teeworlds-0.4.2-src-mod/src/game/server/gs_game.cpp 2008-05-17 19:08:48.000000000 +0200
@@ -207,8 +207,28 @@
victim->score--; // suicide
else
{
- if(is_teamplay && victim->team == killer->team)
+ if(is_teamplay && victim->team == killer->team){
killer->score--; // teamkill
+ killer->teamkill_logging(server_tick());
+
+ //Teamkiller punishment
+ if(config.sv_teamkill_limit && config.sv_punishment_time > 0){
+ int teamkills_last_minute=0;
+ int tick = server_tick();
+
+ for(int i=0; i<10; i++)
+ if( killer->last_teamkills_ticks[i]>0 && (tick- killer->last_teamkills_ticks[i])/server_tickspeed() < 60)
+ teamkills_last_minute++;
+
+
+ if(teamkills_last_minute >= config.sv_teamkill_limit){
+ killer->punishment_count++;
+ killer->set_punishment_time(config.sv_punishment_time * killer->punishment_count);
+
+ dbg_msg("game", "%s has been punished for abusive team kills for %i seconds" ,server_clientname(killer->client_id) ,config.sv_punishment_time * killer->punishment_count);
+ }
+ }
+ }
else
killer->score++; // normal kill
}
diff -u -r teeworlds-0.4.2-src/src/game/server/gs_server.cpp teeworlds-0.4.2-src-mod/src/game/server/gs_server.cpp
--- teeworlds-0.4.2-src/src/game/server/gs_server.cpp 2008-04-05 15:13:02.000000000 +0200
+++ teeworlds-0.4.2-src-mod/src/game/server/gs_server.cpp 2008-05-17 18:54:54.000000000 +0200
@@ -707,6 +707,12 @@
active_weapon = WEAPON_GUN;
last_weapon = WEAPON_HAMMER;
queued_weapon = -1;
+
+ punishment_time=0;
+ punishment_count=0;
+ for(int i=0; i<10; i++)
+ last_teamkills_ticks[i] = 0;
+
}
void player::destroy() { }
@@ -1112,7 +1118,7 @@
void player::fire_weapon()
{
- if(reload_timer != 0 || active_weapon == WEAPON_NINJA)
+ if(punishment_time != 0 || reload_timer != 0 || active_weapon == WEAPON_NINJA)
return;
do_weaponswitch();
@@ -1428,6 +1434,10 @@
player_state = input.player_state;
+ // decreasing the punishment time
+ if(punishment_time != 0)
+ punishment_time--;
+
// Previnput
previnput = input;
return;
@@ -1678,6 +1688,17 @@
}
}
+void player::set_punishment_time(int time){
+ punishment_time = time*server_tickspeed();
+}
+
+void player::teamkill_logging(int server_tick){
+ for(int i=10; i; i--)
+ last_teamkills_ticks[i] = last_teamkills_ticks[i-1];
+
+ last_teamkills_ticks[0] = server_tick;
+}
+
player *players;
//////////////////////////////////////////////////
diff -u -r teeworlds-0.4.2-src/src/engine/e_config_variables.h teeworlds-0.4.2-src-mod/src/engine/e_config_variables.h
--- teeworlds-0.4.2-src/src/engine/e_config_variables.h 2008-04-05 15:13:02.000000000 +0200
+++ teeworlds-0.4.2-src-mod/src/engine/e_config_variables.h 2008-05-17 17:40:07.000000000 +0200
@@ -67,3 +67,6 @@
MACRO_CONFIG_STR(dbg_stress_server, 32, "localhost")
MACRO_CONFIG_INT(sv_map_reload, 0, 0, 1)
+
+MACRO_CONFIG_INT(sv_punishment_time, 30, 0, 120)
+MACRO_CONFIG_INT(sv_teamkill_limit, 3, 0, 10)
Apply it with
patch -ul -d teeworlds-0.4.2-src -p1 < tkpunish.patch
and compile.
It makes a player be unable to use his weapons during <sv_punishment_time> if he does <sv_teamkill_limit> in one minute.
Play
ctf_fall if you dare!