about summary refs log tree commit diff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/server/gamecontext.cpp22
-rw-r--r--src/game/variables.h1
2 files changed, 16 insertions, 7 deletions
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp
index 403f782e..b345ec8c 100644
--- a/src/game/server/gamecontext.cpp
+++ b/src/game/server/gamecontext.cpp
@@ -1131,24 +1131,32 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
 	else if (MsgID == NETMSGTYPE_CL_KILL && !m_World.m_Paused)
 	{
 		/* begin zCatch*/
-		if((pPlayer->GetTeam() == TEAM_SPECTATORS) || (pPlayer->m_LastKillTry && pPlayer->m_LastKillTry+Server()->TickSpeed()*2 > Server()->Tick()))
+		if(pPlayer->GetTeam() == TEAM_SPECTATORS || (pPlayer->m_LastKill && pPlayer->m_LastKill+Server()->TickSpeed()*3 > Server()->Tick()) ||
+				(pPlayer->m_LastKillTry+Server()->TickSpeed()*3 > Server()->Tick()))
 			return;
 
-		if(pPlayer->GetCharacter() && pPlayer->GetCharacter()->m_FreezeTicks)
+		if(g_Config.m_SvSuicideTime == 0)
 		{
-			SendChatTarget(ClientID, "You can't kill yourself while you're frozen");
-			pPlayer->m_LastKillTry = Server()->Tick();
+			SendChatTarget(ClientID, "Suicide is not allowed.");
 		}
-		else if(pPlayer->m_LastKill && pPlayer->m_LastKill + Server()->TickSpeed()*15 > Server()->Tick())
-		{	
-			SendBroadcast("Only one kill in 15sec is allowed.", ClientID);
+		else if(pPlayer->m_LastKill && pPlayer->m_LastKill+Server()->TickSpeed()*g_Config.m_SvSuicideTime > Server()->Tick())
+		{
+			char aBuf[128];
+			str_format(aBuf, sizeof(aBuf), "Only one suicide every %d seconds is allowed.", g_Config.m_SvSuicideTime);
+			SendChatTarget(ClientID, aBuf);
+		}
+		else if(pPlayer->GetCharacter() && pPlayer->GetCharacter()->m_FreezeTicks)
+		{
+			SendChatTarget(ClientID, "You can't kill yourself while you're frozen.");
 		}
 		else
 		{
 			pPlayer->m_LastKill = Server()->Tick();
 			pPlayer->KillCharacter(WEAPON_SELF);
 			pPlayer->m_Deaths++;
+			return;
 		}
+		pPlayer->m_LastKillTry = Server()->Tick();
 		/* end zCatch*/
 	}
 }
diff --git a/src/game/variables.h b/src/game/variables.h
index d2121fe8..7b14264a 100644
--- a/src/game/variables.h
+++ b/src/game/variables.h
@@ -107,4 +107,5 @@ MACRO_CONFIG_INT(SvAnticamperRange, sv_anticamper_range, 200, 0, 1000, CFGFLAG_S
 
 MACRO_CONFIG_INT(SvKickForceReason, sv_kick_force_reason, 1, 0, 1, CFGFLAG_SERVER, "Allow only kickvotes with a reason")
 MACRO_CONFIG_INT(SvGrenadeMinDamage, sv_grenade_min_damage, 4, 1, 6, CFGFLAG_SERVER, "How much damage the grenade must do to kill the player (depends how far away it explodes)")
+MACRO_CONFIG_INT(SvSuicideTime, sv_suicide_time, 15, 0, 60, CFGFLAG_SERVER, "Minimum time between suicides. 0 to forbid suicides completely")
 #endif