mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 10:13:21 +00:00
Update tkstopper
This commit is contained in:
parent
6c0e7bc1f2
commit
9d06642e73
3 changed files with 62 additions and 2 deletions
Binary file not shown.
|
@ -161,4 +161,47 @@ public Action Timer_CheckIsInSpit(Handle h, int userid) {
|
|||
return Plugin_Stop;
|
||||
}
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
float CHARGER_CHECK_MIN[3] = { -15.0, -15.0, 2.0};
|
||||
float CHARGER_CHECK_MAX[3] = { 15.0, 15.0, 20.0 };
|
||||
|
||||
public Action Timer_CheckForChargerOpportunity(Handle h, int userid) {
|
||||
int client = GetClientOfUserId(userid);
|
||||
if(client) {
|
||||
int activator = GetClientOfUserId(g_iSmartChargeActivator[client]);
|
||||
if(!activator) {
|
||||
g_iSmartChargeActivator[client] = 0;
|
||||
}
|
||||
float pos[3], ang[3], endPos[3], spawnPos[3];
|
||||
GetClientAbsOrigin(client, pos);
|
||||
GetClientEyeAngles(client, ang);
|
||||
|
||||
GetHorizontalPositionFromOrigin(pos, ang, -150.0, endPos);
|
||||
TR_TraceHullFilter(endPos, pos, CHARGER_CHECK_MIN, CHARGER_CHECK_MAX, MASK_SOLID, Filter_CheckChargerValid, client);
|
||||
if(!TR_DidHit()) {
|
||||
spawnPos = endPos;
|
||||
GetHorizontalPositionFromOrigin(pos, ang, 500.0, endPos);
|
||||
TR_TraceHullFilter(endPos, pos, CHARGER_CHECK_MIN, CHARGER_CHECK_MAX, MASK_SOLID, Filter_CheckChargerValid, client);
|
||||
if(!TR_DidHit()) {
|
||||
SpawnSpecialAtPosition(Special_Charger, spawnPos, ang, client);
|
||||
if(activator) PrintToChat(activator, "Auto charge %N successfully after %d tries", client, g_iSmartChargeAttempts[client]);
|
||||
g_iSmartChargeAttempts[client] = 0;
|
||||
g_iSmartChargeActivator[client] = 0;
|
||||
return Plugin_Stop;
|
||||
}
|
||||
}
|
||||
if(++g_iSmartChargeAttempts[client] > g_iSmartChargeMaxAttempts[client]) {
|
||||
if(activator) PrintToChat(activator, "Auto charge timed out after %d attempts", g_iSmartChargeAttempts[client]);
|
||||
g_iSmartChargeAttempts[client] = 0;
|
||||
g_iSmartChargeActivator[client] = 0;
|
||||
return Plugin_Stop;
|
||||
}
|
||||
return Plugin_Continue;
|
||||
}
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
public bool Filter_CheckChargerValid(int entity, int contentsMask, any data) {
|
||||
return entity <= 0 || entity >= MaxClients || (entity != data && GetClientTeam(entity) == 2);
|
||||
}
|
|
@ -49,6 +49,8 @@ enum struct PlayerData {
|
|||
PlayerData pData[MAXPLAYERS+1];
|
||||
|
||||
ConVar hForgivenessTime, hBanTime, hThreshold, hJoinTime, hTKAction, hSuicideAction, hSuicideLimit, hFFAutoScaleAmount, hFFAutoScaleForgivenessAmount, hFFAutoScaleMaxRatio, hFFAutoScaleIgnoreAdmins;
|
||||
char gamemode[64];
|
||||
bool isEnabled = true;
|
||||
|
||||
public Plugin myinfo = {
|
||||
name = "TK Stopper",
|
||||
|
@ -83,6 +85,10 @@ public void OnPluginStart() {
|
|||
hFFAutoScaleForgivenessAmount = CreateConVar("l4d2_tk_auto_ff_forgive_rate", "0.05", "This amount times amount of minutes since last ff is removed from ff rate", FCVAR_NONE, true, 0.0);
|
||||
hFFAutoScaleIgnoreAdmins = CreateConVar("l4d2_tk_auto_ff_ignore_admins", "1", "Should automatic reverse ff ignore admins? 0 = Admins are subjected\n1 = Admins are excempt", FCVAR_NONE, true, 0.0, true, 1.0);
|
||||
|
||||
ConVar hGamemode = FindConVar("mp_gamemode");
|
||||
hGamemode.AddChangeHook(Event_GamemodeChange);
|
||||
Event_GamemodeChange(hGamemode, gamemode, gamemode);
|
||||
|
||||
AutoExecConfig(true, "l4d2_tkstopper");
|
||||
|
||||
HookEvent("finale_vehicle_ready", Event_FinaleVehicleReady);
|
||||
|
@ -119,6 +125,14 @@ public void OnPluginStart() {
|
|||
}
|
||||
LoadTranslations("common.phrases");
|
||||
}
|
||||
public void Event_GamemodeChange(ConVar cvar, const char[] oldValue, const char[] newValue) {
|
||||
cvar.GetString(gamemode, sizeof(gamemode));
|
||||
if(StrEqual(gamemode, "coop")) {
|
||||
isEnabled = true;
|
||||
} else {
|
||||
isEnabled = false;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Special Infected Events
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -210,7 +224,7 @@ public void OnClientDisconnect(int client) {
|
|||
|
||||
// Only clear things when they fully left on their own accord:
|
||||
public void Event_PlayerDisconnect(Event event, const char[] name, bool dontBroadcast) {
|
||||
if(!event.GetBool("disconnect")) return;
|
||||
if(!event.GetBool("disconnect") || !isEnabled) return;
|
||||
|
||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||
if(client > 0 && event.GetInt("team") <= 2) {
|
||||
|
@ -243,7 +257,7 @@ public void Event_PlayerDisconnect(Event event, const char[] name, bool dontBroa
|
|||
}
|
||||
|
||||
public Action Event_OnTakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype, int& weapon, float damageForce[3], float damagePosition[3]) {
|
||||
if(damage > 0.0 && victim <= MaxClients && attacker <= MaxClients && attacker > 0 && victim > 0) {
|
||||
if(isEnabled && damage > 0.0 && victim <= MaxClients && attacker <= MaxClients && attacker > 0 && victim > 0) {
|
||||
if(GetClientTeam(victim) != GetClientTeam(attacker) || attacker == victim)
|
||||
return Plugin_Continue;
|
||||
else if(damagetype & DMG_BURN && IsFakeClient(attacker) && GetClientTeam(attacker) == 2) {
|
||||
|
@ -406,6 +420,9 @@ public Action Event_OnTakeDamage(int victim, int& attacker, int& inflictor, flo
|
|||
|
||||
public Action Command_TKInfo(int client, int args) {
|
||||
int time = GetTime();
|
||||
if(!isEnabled) {
|
||||
ReplyToCommand(client, "Warn: Plugin is disabled in current gamemode (%s)", gamemode);
|
||||
}
|
||||
if(args > 0) {
|
||||
static char arg1[32];
|
||||
GetCmdArg(1, arg1, sizeof(arg1));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue