mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-05 19:53:20 +00:00
Added L4D2FFKickProtection && l4d2_ff_test
This commit is contained in:
parent
f559493e3a
commit
f678a3ec81
5 changed files with 246 additions and 1 deletions
12
README.md
12
README.md
|
@ -64,4 +64,14 @@ Updated version of ConnerRia's plugin. Improves bots avoidance of tanks. Change
|
||||||
* `FlyYouFools_Version` - Prints the version of plugin
|
* `FlyYouFools_Version` - Prints the version of plugin
|
||||||
|
|
||||||
### BetterWitchAvoidance
|
### BetterWitchAvoidance
|
||||||
Inspired by the 200IQBots_FlyYouFools. Bots avoid witch if its over 40% anger when close, or a little bigger range at 60% or more.
|
Inspired by the 200IQBots_FlyYouFools. Bots avoid witch if its over 40% anger when close, or a little bigger range at 60% or more.
|
||||||
|
|
||||||
|
### L4D2FFKickProtection
|
||||||
|
Simple plugin that prevents a player that is being vote-kicked from doing any ff damage to teammates.
|
||||||
|
* **Convars:**
|
||||||
|
* `sm_votekick_force_threshold` - The threshold of damage where the offending player is just immediately kicked. 0 -> Any attempted damage, -1 -> No auto kick.
|
||||||
|
|
||||||
|
### l4d2_ff_test
|
||||||
|
More of a joke plugin, it will prevent a player from picking up a m60 if their friendly fire count or damage is over a certain threshold (Hardcoded as 5 and 35 respectively)
|
||||||
|
* **Commands:**
|
||||||
|
* `sm_view_ff` - View the ff damage and count of all players
|
BIN
plugins/L4D2FFKickProtection.smx
Normal file
BIN
plugins/L4D2FFKickProtection.smx
Normal file
Binary file not shown.
BIN
plugins/l4d2_ff_test.smx
Normal file
BIN
plugins/l4d2_ff_test.smx
Normal file
Binary file not shown.
113
scripting/L4D2FFKickProtection.sp
Normal file
113
scripting/L4D2FFKickProtection.sp
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
#pragma semicolon 1
|
||||||
|
#pragma newdecls required
|
||||||
|
|
||||||
|
|
||||||
|
#define PLUGIN_NAME "L4D2 FF Kick Protection"
|
||||||
|
#define PLUGIN_DESCRIPTION "Prevents assholes from friendly firing when being kicked."
|
||||||
|
#define PLUGIN_AUTHOR "jackzmc"
|
||||||
|
#define PLUGIN_VERSION "1.0"
|
||||||
|
#define PLUGIN_URL ""
|
||||||
|
|
||||||
|
#include <sourcemod>
|
||||||
|
#include <sdktools>
|
||||||
|
#include <sdkhooks>
|
||||||
|
|
||||||
|
static int disableFFClient; //client to disable FF for
|
||||||
|
static float ffDamageDone; //amount of damage offending user has attempted
|
||||||
|
static ConVar forceKickFFThreshold;
|
||||||
|
|
||||||
|
public Plugin myinfo = {
|
||||||
|
name = PLUGIN_NAME,
|
||||||
|
author = PLUGIN_AUTHOR,
|
||||||
|
description = PLUGIN_DESCRIPTION,
|
||||||
|
version = PLUGIN_VERSION,
|
||||||
|
url = PLUGIN_URL
|
||||||
|
};
|
||||||
|
|
||||||
|
public void OnPluginStart() {
|
||||||
|
EngineVersion g_Game = GetEngineVersion();
|
||||||
|
if(g_Game != Engine_Left4Dead && g_Game != Engine_Left4Dead2)
|
||||||
|
{
|
||||||
|
SetFailState("This plugin is for L4D/L4D2 only.");
|
||||||
|
}
|
||||||
|
AddCommandListener(VoteStart, "callvote");
|
||||||
|
HookUserMessage(GetUserMessageId("VotePass"), VotePassFail);
|
||||||
|
HookUserMessage(GetUserMessageId("VoteFail"), VotePassFail);
|
||||||
|
|
||||||
|
forceKickFFThreshold = CreateConVar("sm_votekick_force_threshold","0","The threshold of damage where the offending player is just immediately kicked. 0 -> Any attempted damage, -1 -> No auto kick.", FCVAR_NONE, true, -1.0);
|
||||||
|
|
||||||
|
//HookEvent("vote_started",Event_VoteStarted);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnClientPutInServer(int client) {
|
||||||
|
int team = GetClientTeam(client);
|
||||||
|
if(team == 2) {
|
||||||
|
SDKHook(client, SDKHook_OnTakeDamageAlive, OnTakeDamage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Event_PlayerTeam(Event event, const char[] name, bool dontBroadcast) {
|
||||||
|
if(!event.GetBool("disconnect")) {
|
||||||
|
int team = event.GetInt("team");
|
||||||
|
int userid = GetClientOfUserId(event.GetInt("userid"));
|
||||||
|
if(team == 2) {
|
||||||
|
SDKHook(userid, SDKHook_OnTakeDamageAlive, OnTakeDamage);
|
||||||
|
//add new hook
|
||||||
|
}else{
|
||||||
|
SDKUnhook(userid, SDKHook_OnTakeDamageAlive, OnTakeDamage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action VoteStart(int client, const char[] command, int argc) {
|
||||||
|
if(GetClientCount(true) == 0 || client == 0) return Plugin_Handled; //prevent votes while server is empty or if server tries calling vote
|
||||||
|
if(argc >= 1) {
|
||||||
|
char issue[32];
|
||||||
|
char caller[32];
|
||||||
|
|
||||||
|
GetCmdArg(1, issue, sizeof(issue));
|
||||||
|
Format(caller, sizeof(caller), "%N", client);
|
||||||
|
|
||||||
|
if(StrEqual(issue, "Kick", true)) {
|
||||||
|
char option[32];
|
||||||
|
GetCmdArg(2, option, sizeof(option));
|
||||||
|
if(strlen(option) < 1) { //empty userid/console can't call votes
|
||||||
|
int target = GetClientOfUserId(StringToInt(option));
|
||||||
|
int team = GetClientTeam(target);
|
||||||
|
if(team == 2) {
|
||||||
|
disableFFClient = target;
|
||||||
|
ffDamageDone = -1.0;
|
||||||
|
}
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
//Kick vote started
|
||||||
|
PrintToServer("KICK VOTE STARTED | Issue=%s Option=%s Caller=%N", issue, option, client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Plugin_Handled; //if it wasn't handled up there I would start panicking
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action VotePassFail(UserMsg msg_id, BfRead msg, const int[] players, int playersNum, bool reliable, bool init) {
|
||||||
|
disableFFClient = -1;
|
||||||
|
ffDamageDone = -1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action OnTakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype, int& weapon, float damageForce[3], float damagePosition[3]) {
|
||||||
|
if(disableFFClient == attacker) {
|
||||||
|
if(ffDamageDone == -1) {
|
||||||
|
PrintToServer("Player in vote to be kicked has done ff damage");
|
||||||
|
}
|
||||||
|
ffDamageDone = damage;
|
||||||
|
if(forceKickFFThreshold.FloatValue > -1.0) {
|
||||||
|
//auto kick
|
||||||
|
if(forceKickFFThreshold.FloatValue == 0.0) {
|
||||||
|
KickClient(disableFFClient, "Kicked for excessive friendly fire");
|
||||||
|
}else if(FloatCompare(ffDamageDone, forceKickFFThreshold.FloatValue) == 1) {
|
||||||
|
KickClient(disableFFClient, "Kicked for excessive friendly fire");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
damage = 0.0;
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
122
scripting/l4d2_ff_test.sp
Normal file
122
scripting/l4d2_ff_test.sp
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
#pragma semicolon 1
|
||||||
|
#pragma newdecls required
|
||||||
|
|
||||||
|
//#define DEBUG
|
||||||
|
|
||||||
|
#define PLUGIN_NAME "l4d2_ff_test"
|
||||||
|
#define PLUGIN_DESCRIPTION ""
|
||||||
|
#define PLUGIN_AUTHOR "jackzmc"
|
||||||
|
#define PLUGIN_VERSION "1.0"
|
||||||
|
#define PLUGIN_URL ""
|
||||||
|
|
||||||
|
#include <sourcemod>
|
||||||
|
#include <sdktools>
|
||||||
|
#include <sdkhooks>
|
||||||
|
|
||||||
|
static bool bLateLoaded;
|
||||||
|
static float ffDamage[MAXPLAYERS+1];
|
||||||
|
static int ffCount[MAXPLAYERS+1];
|
||||||
|
|
||||||
|
public Plugin myinfo =
|
||||||
|
{
|
||||||
|
name = PLUGIN_NAME,
|
||||||
|
author = PLUGIN_AUTHOR,
|
||||||
|
description = PLUGIN_DESCRIPTION,
|
||||||
|
version = PLUGIN_VERSION,
|
||||||
|
url = PLUGIN_URL
|
||||||
|
};
|
||||||
|
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) {
|
||||||
|
if(late) {
|
||||||
|
bLateLoaded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnPluginStart()
|
||||||
|
{
|
||||||
|
EngineVersion g_Game = GetEngineVersion();
|
||||||
|
if(g_Game != Engine_Left4Dead && g_Game != Engine_Left4Dead2)
|
||||||
|
{
|
||||||
|
SetFailState("This plugin is for L4D/L4D2 only.");
|
||||||
|
}
|
||||||
|
if(bLateLoaded) {
|
||||||
|
for(int i=1;i<MaxClients;i++) {
|
||||||
|
if(IsClientConnected(i)) {
|
||||||
|
int team = GetClientTeam(i);
|
||||||
|
if(team == 2) {
|
||||||
|
SDKHook(i, SDKHook_OnTakeDamageAlive, OnTakeDamage);
|
||||||
|
SDKHook(i, SDKHook_WeaponEquip, WeaponCanUse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HookEvent("round_start", Event_RoundStart);
|
||||||
|
RegConsoleCmd("sm_view_ff", Command_ViewFF, "View all player's friendly fire counts");
|
||||||
|
}
|
||||||
|
|
||||||
|
//sdkhook setups
|
||||||
|
public void OnClientPutInServer(int client) {
|
||||||
|
int team = GetClientTeam(client);
|
||||||
|
if(team == 2) {
|
||||||
|
SDKHook(client, SDKHook_OnTakeDamageAlive, OnTakeDamage);
|
||||||
|
SDKHook(client, SDKHook_WeaponEquip, WeaponCanUse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Event_PlayerTeam(Event event, const char[] name, bool dontBroadcast) {
|
||||||
|
if(!event.GetBool("disconnect")) {
|
||||||
|
int team = event.GetInt("team");
|
||||||
|
int userid = GetClientOfUserId(event.GetInt("userid"));
|
||||||
|
if(team == 2) {
|
||||||
|
SDKHook(userid, SDKHook_OnTakeDamageAlive, OnTakeDamage);
|
||||||
|
if(!IsFakeClient(userid)) {
|
||||||
|
SDKHook(userid, SDKHook_WeaponEquip, WeaponCanUse);
|
||||||
|
}
|
||||||
|
//add new hook
|
||||||
|
}else{
|
||||||
|
SDKUnhook(userid, SDKHook_OnTakeDamageAlive, OnTakeDamage);
|
||||||
|
SDKUnhook(userid, SDKHook_WeaponEquip, WeaponCanUse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//events
|
||||||
|
public void OnMapStart() {
|
||||||
|
for(int i=1; i < MaxClients+1; i++) {
|
||||||
|
ffDamage[i] = 0.0;
|
||||||
|
ffCount[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast) {
|
||||||
|
OnMapStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
//damage counting
|
||||||
|
public Action OnTakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype, int& weapon, float damageForce[3], float damagePosition[3]) {
|
||||||
|
ffDamage[attacker] += damage;
|
||||||
|
ffCount[attacker]++;
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//commands
|
||||||
|
public Action Command_ViewFF(int client, int args) {
|
||||||
|
ReplyToCommand(client, "FF Stats for this round: ");
|
||||||
|
for(int i=1; i < MaxClients+1; i++) {
|
||||||
|
if(IsClientConnected(i) && !IsFakeClient(i)) {
|
||||||
|
ReplyToCommand(client, "Client %N: %d HP (%d friendly fires)", i, RoundToNearest(ffDamage[i]), ffCount[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//events
|
||||||
|
public Action WeaponCanUse(int client, int weapon) {
|
||||||
|
char item[32];
|
||||||
|
GetEdictClassname(weapon, item, sizeof(item));
|
||||||
|
//event.GetString("item", item, sizeof(item));
|
||||||
|
if(StrEqual(item, "weapon_rifle_m60", true)) {
|
||||||
|
if(ffCount[client] > 5 || ffDamage[client] >= 35) {
|
||||||
|
int damage = RoundToNearest(ffDamage[client]);
|
||||||
|
PrintToChat(client, "Sorry, you can't use m60s due to your %d ff attacks (total %d HP)", ffCount[client], damage);
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue