From 807e6d71ff5c3efb53652e87124c0e80cca0ac48 Mon Sep 17 00:00:00 2001 From: dogan Date: Tue, 10 Nov 2020 15:24:47 +0100 Subject: [PATCH] initial release: Buffshotguns + fix a small error for invalid edict s --- BuffShotguns/scripting/BuffShotguns.sp | 76 ++++++++++++++++++++++++++ KnifeBan/scripting/KnifeBan.sp | 5 +- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 BuffShotguns/scripting/BuffShotguns.sp diff --git a/BuffShotguns/scripting/BuffShotguns.sp b/BuffShotguns/scripting/BuffShotguns.sp new file mode 100644 index 00000000..f44c49cd --- /dev/null +++ b/BuffShotguns/scripting/BuffShotguns.sp @@ -0,0 +1,76 @@ +#pragma semicolon 1 + +#include +#include +#include +#include +#include + +float g_fShotgunBuffMultiplier; + +int g_hActiveWeapon; + +public Plugin myinfo = +{ + name = "BuffShotguns", + author = "Dogan", + description = "Simple Plugin to buff Shotguns (++damage)", + version = "1.0.0", + url = "" +} + +public void OnPluginStart() +{ + ConVar cvar; + HookConVarChange((cvar = CreateConVar("sm_buffshotguns_multiplier", "1.15", "damage multiplier for shotguns")), g_cvShotgunBuffMultiplier); + g_fShotgunBuffMultiplier = cvar.FloatValue; + delete cvar; + + AutoExecConfig(true, "plugin.BuffShotguns"); + + g_hActiveWeapon = FindSendPropInfo("CBaseCombatCharacter", "m_hActiveWeapon"); + if(g_hActiveWeapon == -1) + SetFailState("Couldn't find CBaseCombatCharacter::m_hActiveWeapon"); + + for(int i = 1; i <= MaxClients; i++) + { + if(IsClientInGame(i)) + OnClientPostAdminCheck(i); + } +} + +public void g_cvShotgunBuffMultiplier(ConVar convar, const char[] oldValue, const char[] newValue) +{ + g_fShotgunBuffMultiplier = convar.FloatValue; +} + +public void OnClientPostAdminCheck(int client) +{ + SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); +} + +public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3], int damagecustom) +{ + if(attacker < 1 || attacker > MaxClients) + return Plugin_Continue; + + if(!IsPlayerAlive(victim)) + return Plugin_Continue; + + if(!ZR_IsClientZombie(victim)) + return Plugin_Continue; + + char sWeapon[32]; + int iWeapon = GetEntDataEnt2(attacker, g_hActiveWeapon); + if(iWeapon != INVALID_ENT_REFERENCE) + GetEdictClassname(iWeapon, sWeapon, sizeof(sWeapon)); + else + return Plugin_Continue; + + if(!StrEqual(sWeapon, "weapon_m3") && !StrEqual(sWeapon, "weapon_xm1014")) + return Plugin_Continue; + + damage = float(RoundFloat(damage * g_fShotgunBuffMultiplier)); + + return Plugin_Changed; +} \ No newline at end of file diff --git a/KnifeBan/scripting/KnifeBan.sp b/KnifeBan/scripting/KnifeBan.sp index 048a6565..e11ec34a 100644 --- a/KnifeBan/scripting/KnifeBan.sp +++ b/KnifeBan/scripting/KnifeBan.sp @@ -187,7 +187,10 @@ public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &dam char sWeapon[32]; int iWeapon = GetEntDataEnt2(attacker, g_hActiveWeapon); - GetEdictClassname(iWeapon, sWeapon, sizeof(sWeapon)); + if(iWeapon != INVALID_ENT_REFERENCE) + GetEdictClassname(iWeapon, sWeapon, sizeof(sWeapon)); + else + return Plugin_Continue; if(!StrEqual(sWeapon, "weapon_knife")) return Plugin_Continue;