Skip to content

Commit f636793

Browse files
committed
Prevent jointeam from being too spammable
1 parent 3757b84 commit f636793

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

addons/sourcemod/scripting/shavit-misc.sp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ char gS_RadioCommands[][] = { "coverme", "takepoint", "holdpos", "regroup", "fol
6161
"getinpos", "stormfront", "report", "roger", "enemyspot", "needbackup", "sectorclear", "inposition", "reportingin",
6262
"getout", "negative", "enemydown", "compliment", "thanks", "cheer", "go_a", "go_b", "sorry", "needrop", "playerradio", "playerchatwheel", "player_ping", "chatwheel_ping" };
6363

64+
float gF_LastJointeam[MAXPLAYERS+1];
6465
bool gB_Hide[MAXPLAYERS+1];
6566
bool gB_AutoRestart[MAXPLAYERS+1];
6667
bool gB_Late = false;
@@ -908,6 +909,17 @@ public Action Command_Jointeam(int client, const char[] command, int args)
908909
iTeam = GetRandomInt(2, 3);
909910
}
910911

912+
// Prevent `jointeam` from being too spammable.
913+
if (iTeam != 1)
914+
{
915+
float now = GetEngineTime();
916+
if (now - gF_LastJointeam[client] < 0.35)
917+
{
918+
return Plugin_Stop;
919+
}
920+
gF_LastJointeam[client] = now;
921+
}
922+
911923
CleanSwitchTeam(client, iTeam);
912924

913925
if(gCV_RespawnOnTeam.BoolValue && iTeam != 1)
@@ -1497,6 +1509,8 @@ public void OnClientPutInServer(int client)
14971509
return;
14981510
}
14991511

1512+
gF_LastJointeam[client] = 0.0;
1513+
15001514
if(gEV_Type == Engine_TF2)
15011515
{
15021516
SDKHook(client, SDKHook_PreThinkPost, TF2_OnPreThink);

0 commit comments

Comments
 (0)