807e6d71ff
+ fix a small error for invalid edict s
76 lines
1.9 KiB
SourcePawn
76 lines
1.9 KiB
SourcePawn
#pragma semicolon 1
|
|
|
|
#include <sourcemod>
|
|
#include <sdktools>
|
|
#include <sdkhooks>
|
|
#include <cstrike>
|
|
#include <zombiereloaded>
|
|
|
|
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;
|
|
} |