initial release: Buffshotguns
+ fix a small error for invalid edict s
This commit is contained in:
parent
ae14cf0899
commit
807e6d71ff
76
BuffShotguns/scripting/BuffShotguns.sp
Normal file
76
BuffShotguns/scripting/BuffShotguns.sp
Normal file
@ -0,0 +1,76 @@
|
||||
#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;
|
||||
}
|
@ -187,7 +187,10 @@ public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &dam
|
||||
|
||||
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_knife"))
|
||||
return Plugin_Continue;
|
||||
|
Loading…
Reference in New Issue
Block a user