Skip to content

Commit

Permalink
add l4d2_many_pinned_prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
cH1yoi committed Dec 16, 2024
1 parent 6df0de0 commit 3ec3a9c
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
Binary file not shown.
94 changes: 94 additions & 0 deletions addons/sourcemod/scripting/l4d2_many_pinned_prompt.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <colors>

int g_iPreviousPinnedCount = 0;

public Plugin myinfo =
{
name = "L4D2 Many Pinned Prompt",
author = "Hana",
description = "Shows star rating for multiple survivor pins",
version = "1.0",
url = "https://steamcommunity.com/profiles/76561197983870853/"
};

public void OnPluginStart()
{
LoadTranslations("l4d2_many_pinned_prompt.phrases");

HookEvent("tongue_grab", Event_SpecialInfectedGrab, EventHookMode_PostNoCopy);
HookEvent("choke_start", Event_SpecialInfectedGrab, EventHookMode_PostNoCopy);
HookEvent("lunge_pounce", Event_SpecialInfectedGrab, EventHookMode_PostNoCopy);
HookEvent("jockey_ride", Event_SpecialInfectedGrab, EventHookMode_PostNoCopy);
HookEvent("charger_carry_start", Event_ChargerGrab, EventHookMode_PostNoCopy);
HookEvent("charger_pummel_start", Event_ChargerGrab, EventHookMode_PostNoCopy);

HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
}

public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
g_iPreviousPinnedCount = 0;
}

public void Event_SpecialInfectedGrab(Event event, const char[] name, bool dontBroadcast)
{
CreateTimer(1.1, DelayCheck, _, TIMER_FLAG_NO_MAPCHANGE);
}

public void Event_ChargerGrab(Event event, const char[] name, bool dontBroadcast)
{
CreateTimer(2.0, DelayCheck, _, TIMER_FLAG_NO_MAPCHANGE);
}

public Action DelayCheck(Handle timer)
{
CheckPinnedNumber();
return Plugin_Continue;
}

public void CheckPinnedNumber()
{
int pinned_number = 0;
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) &&
GetClientTeam(i) == 2 &&
IsPlayerAlive(i) &&
(GetEntPropEnt(i, Prop_Send, "m_tongueOwner") > 0 ||
GetEntPropEnt(i, Prop_Send, "m_pounceAttacker") > 0 ||
GetEntPropEnt(i, Prop_Send, "m_carryAttacker") > 0 ||
GetEntPropEnt(i, Prop_Send, "m_pummelAttacker") > 0 ||
GetEntPropEnt(i, Prop_Send, "m_jockeyAttacker") > 0))
{
pinned_number++;
}
}

if (pinned_number >= 2 && pinned_number != g_iPreviousPinnedCount)
{
char buffer[64];
switch(pinned_number)
{
case 2:
Format(buffer, sizeof(buffer), "%t", "Tag++");
case 3:
Format(buffer, sizeof(buffer), "%t", "Tag+++");
case 4:
Format(buffer, sizeof(buffer), "%t", "Tag++++");
default:
Format(buffer, sizeof(buffer), "%t", "Tag++++");
}

CPrintToChatAll("%t", "PinnedMessage", buffer, pinned_number);

g_iPreviousPinnedCount = pinned_number;
}
else if (pinned_number < 2)
{
g_iPreviousPinnedCount = 0;
}
}
29 changes: 29 additions & 0 deletions addons/sourcemod/translations/l4d2_many_pinned_prompt.phrases.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"Phrases"
{
"Tag+"
{
"chi" "{green}★{default}"
"en" "{green}★{default}"
}
"Tag++"
{
"chi" "{green}★★{default}"
"en" "{green}★★{default}"
}
"Tag+++"
{
"chi" "{green}★★★{default}"
"en" "{green}★★★{default}"
}
"Tag++++"
{
"chi" "{green}★★★★{default}"
"en" "{green}★★★★{default}"
}
"PinnedMessage"
{
"#format" "{1:s},{2:d}"
"chi" "{1} {red}特感阵营 {green}达成 {green}{2}控{default}!"
"en" "{1} {red}SI {green}Achieved {green}{2} pins{default}!"
}
}
3 changes: 3 additions & 0 deletions cfg/sharedplugins.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ sm plugins load hana/enhancedsprays.smx
// 自动切换tags
sm plugins load hana/hide_server.smx

// 特感多控提示
sm plugins load hana/l4d2_many_pinned_prompt.smx

/**
============= Convars/Cmd 配置/指令 =============
*/
Expand Down

0 comments on commit 3ec3a9c

Please sign in to comment.