mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-09 17:23:21 +00:00
Disable autopunish running on car alarms
This commit is contained in:
parent
329d6c39a5
commit
b04fbed749
2 changed files with 21 additions and 11 deletions
Binary file not shown.
|
@ -73,6 +73,7 @@ public void OnPluginStart() {
|
||||||
|
|
||||||
HookEvent("player_disconnect", Event_PlayerDisconnect);
|
HookEvent("player_disconnect", Event_PlayerDisconnect);
|
||||||
HookEvent("player_death", Event_PlayerDeath);
|
HookEvent("player_death", Event_PlayerDeath);
|
||||||
|
HookEvent("triggered_car_alarm", Event_CarAlarm);
|
||||||
AddNormalSoundHook(view_as<NormalSHook>(SoundHook));
|
AddNormalSoundHook(view_as<NormalSHook>(SoundHook));
|
||||||
|
|
||||||
AutoExecConfig(true, "l4d2_feedthetrolls");
|
AutoExecConfig(true, "l4d2_feedthetrolls");
|
||||||
|
@ -120,7 +121,6 @@ public Action Event_WeaponReload(int weapon) {
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
public Action Event_ButtonPress(const char[] output, int entity, int client, float delay) {
|
public Action Event_ButtonPress(const char[] output, int entity, int client, float delay) {
|
||||||
PrintToChatAll("func_button");
|
|
||||||
if(client > 0 && client <= MaxClients) {
|
if(client > 0 && client <= MaxClients) {
|
||||||
lastButtonUser = client;
|
lastButtonUser = client;
|
||||||
}
|
}
|
||||||
|
@ -132,6 +132,14 @@ public void Event_PanicEventCreate(Event event, const char[] name, bool dontBroa
|
||||||
lastButtonUser = client;
|
lastButtonUser = client;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void Event_CarAlarm(Event event, const char[] name, bool dontBroadcast) {
|
||||||
|
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||||
|
if(client) {
|
||||||
|
PrintToChatAll("%N has alerted the horde!", client);
|
||||||
|
}
|
||||||
|
//Ignore car alarms for autopunish
|
||||||
|
lastButtonUser = -1;
|
||||||
|
}
|
||||||
public Action L4D2_OnChooseVictim(int attacker, int &curTarget) {
|
public Action L4D2_OnChooseVictim(int attacker, int &curTarget) {
|
||||||
// =========================
|
// =========================
|
||||||
// OVERRIDE VICTIM
|
// OVERRIDE VICTIM
|
||||||
|
@ -320,9 +328,12 @@ public Action Event_TakeDamage(int victim, int& attacker, int& inflictor, float&
|
||||||
public Action SoundHook(int[] clients, int& numClients, char sample[PLATFORM_MAX_PATH], int& entity, int& channel, float& volume, int& level, int& pitch, int& flags, char[] soundEntry, int& seed) {
|
public Action SoundHook(int[] clients, int& numClients, char sample[PLATFORM_MAX_PATH], int& entity, int& channel, float& volume, int& level, int& pitch, int& flags, char[] soundEntry, int& seed) {
|
||||||
if(lastButtonUser > -1 && StrEqual(sample, "npc/mega_mob/mega_mob_incoming.wav")) {
|
if(lastButtonUser > -1 && StrEqual(sample, "npc/mega_mob/mega_mob_incoming.wav")) {
|
||||||
PrintToConsoleAll("CRESCENDO STARTED BY %N", lastButtonUser);
|
PrintToConsoleAll("CRESCENDO STARTED BY %N", lastButtonUser);
|
||||||
float distance = GetFarthestClientDistance();
|
#if defined DEBUG
|
||||||
if(distance > AUTOPUNISH_FLOW_MIN_DISTANCE) {
|
PrintToChatAll("CRESCENDO STARTED BY %N", lastButtonUser);
|
||||||
NotifyAllAdmins("Autopunishing player %N for activation of event far from team (%f away)", lastButtonUser, distance);
|
#endif
|
||||||
|
|
||||||
|
if(IsPlayerFarDistance(lastButtonUser, AUTOPUNISH_FLOW_MIN_DISTANCE)) {
|
||||||
|
NotifyAllAdmins("Autopunishing player %N for activation of event far from team", lastButtonUser);
|
||||||
if(hAutoPunish.IntValue & 2 == 2)
|
if(hAutoPunish.IntValue & 2 == 2)
|
||||||
ApplyModeToClient(0, lastButtonUser, Troll_SpecialMagnet, TrollMod_None);
|
ApplyModeToClient(0, lastButtonUser, Troll_SpecialMagnet, TrollMod_None);
|
||||||
if(hAutoPunish.IntValue & 1 == 1)
|
if(hAutoPunish.IntValue & 1 == 1)
|
||||||
|
@ -396,11 +407,13 @@ public Action Command_ResetUser(int client, int args) {
|
||||||
for (int i = 0; i < target_count; i++)
|
for (int i = 0; i < target_count; i++)
|
||||||
{
|
{
|
||||||
if(IsClientConnected(target_list[i]) && IsClientInGame(target_list[i]) && IsPlayerAlive(target_list[i])) {
|
if(IsClientConnected(target_list[i]) && IsClientInGame(target_list[i]) && IsPlayerAlive(target_list[i])) {
|
||||||
|
if(g_iTrollUsers[target_list[i]] > 0) {
|
||||||
ResetClient(target_list[i], true);
|
ResetClient(target_list[i], true);
|
||||||
ShowActivity(client, "reset troll effects on \"%N\". ", target_list[i]);
|
ShowActivity(client, "reset troll effects on \"%N\". ", target_list[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
public Action Command_ApplyUser(int client, int args) {
|
public Action Command_ApplyUser(int client, int args) {
|
||||||
|
@ -678,8 +691,7 @@ void ThrowAllItems(int victim) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool IsPlayerFarDistance(int client, float distance) {
|
||||||
float GetFarthestClientDistance() {
|
|
||||||
int farthestClient = -1, secondClient = -1;
|
int farthestClient = -1, secondClient = -1;
|
||||||
float highestFlow, secondHighestFlow;
|
float highestFlow, secondHighestFlow;
|
||||||
for(int i = 1; i <= MaxClients; i++) {
|
for(int i = 1; i <= MaxClients; i++) {
|
||||||
|
@ -706,11 +718,9 @@ float GetFarthestClientDistance() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float difference = highestFlow - secondHighestFlow;
|
float difference = highestFlow - secondHighestFlow;
|
||||||
#if defined DEBUG
|
|
||||||
PrintToConsoleAll("Flow Check | Player=%N Flow=%f Delta=%f", farthestClient, highestFlow, difference);
|
PrintToConsoleAll("Flow Check | Player=%N Flow=%f Delta=%f", farthestClient, highestFlow, difference);
|
||||||
PrintToConsoleAll("Flow Check | Player2=%N Flow2=%f", secondClient, secondHighestFlow);
|
PrintToConsoleAll("Flow Check | Player2=%N Flow2=%f", secondClient, secondHighestFlow);
|
||||||
#endif
|
return client == farthestClient && difference > distance;
|
||||||
return difference;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetAutoPunishMode() {
|
int GetAutoPunishMode() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue