Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions l4d2_tank_draw/scripting/l4d2_tank_draw.sp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public void OnPluginStart()

HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
HookEvent("mission_lost", Event_Lost, EventHookMode_Pre);
HookEvent("player_bot_replace", Event_PlayerBotReplace, EventHookMode_Pre);

HookEvent("molotov_thrown", Event_Molotov);

Expand Down Expand Up @@ -312,6 +313,46 @@ public void OnClientDisconnect(int client)
return;
}

public Action Event_PlayerBotReplace(Event event, const char[] name, bool dontBroadcast)
{
if (g_iTankDrawEnable == 0) { return Plugin_Continue; }
DebugPrint("Event_PlayerBotReplace triggered.");

// Get the player who was replaced (the human player who went idle)
int player = GetClientOfUserId(event.GetInt("player"));
DebugPrint("player id : %d is replaced", player);

if (!IsValidClient(player))
{
DebugPrint("Invalid player in player_bot_replace event.");
return Plugin_Continue;
}

// Check if player has a timer bomb
if (g_hTimeBombTimer[player] != null || g_hFreezeBombTimer[player] != null || g_hDrugTimers[player] != null)
{
char playerName[MAX_NAME_LENGTH];
GetClientName(player, playerName, sizeof(playerName));

CPrintToChatAll("%t", "TankDraw_Avoid_Punish", playerName);
PrintHintTextToAll("%t", "TankDraw_Avoid_Punish_NoColor", playerName);

int botId = GetClientOfUserId(event.GetInt("bot"));
DebugPrint("replace bot id: %d", botId);

KillFreezeBombTimer(player);
KillFreezeBombTimer(botId);

ForcePlayerSuicide(player);
ForcePlayerSuicide(botId);

DebugPrint("Player %s (userid: %d) was killed for avoiding punishment.", playerName, event.GetInt("player"));
return Plugin_Continue;
}

return Plugin_Continue;
}

public Action Event_Molotov(Event event, const char[] name, bool dontBroadcast)
{
DebugPrint("Event_Molotov triggered.");
Expand Down
12 changes: 12 additions & 0 deletions l4d2_tank_draw/translations/l4d2_tank_draw.phrases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -671,4 +671,16 @@
"en" "[Tank Draw] Player %s's lucky draw result: Drug all survivor for %d seconds."
"chi" "[坦克抽奖] 玩家 %s 的幸运抽奖结果: 全体中毒 %d 秒"
}

"TankDraw_Avoid_Punish"
{
"en" "{yellow}[Tank Draw] {lightgreen}Player {olive}%s{lightgreen} attempted to avoid punishment. {olive} Executed."
"chi" "{yellow}[坦克抽奖] {lightgreen}玩家 {olive}%s{lightgreen} 试图躲避惩罚,已被{olive}处决"
}

"TankDraw_Avoid_Punish_NoColor"
{
"en" "[Tank Draw] Player %s attempted to avoid punishment. Executed."
"chi" "[坦克抽奖] 玩家 %s 视图躲避惩罚,已被处决"
}
}