sm-plugins/NoGrenadeRinging/scripting/NoGrenadeRinging.sp

50 lines
1.3 KiB
SourcePawn
Raw Normal View History

2016-01-19 23:57:32 +01:00
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <dhooks>
2016-12-19 08:33:16 +01:00
// int CCSPlayer::OnDamagedByExplosion(CTakeDamageInfo const&)
2016-01-19 23:57:32 +01:00
Handle g_hDamagedByExplosion;
public Plugin myinfo =
{
name = "NoGrenadeRinging",
author = "BotoX",
description = "Block the annoying ringing noise when a grenade explodes next to you",
2016-12-19 08:33:16 +01:00
version = "1.0.1",
2016-01-19 23:57:32 +01:00
url = ""
};
public void OnPluginStart()
{
Handle hTemp = LoadGameConfigFile("NoGrenadeRinging.games");
if(hTemp == INVALID_HANDLE)
SetFailState("Why you no has gamedata?");
int Offset = GameConfGetOffset(hTemp, "OnDamagedByExplosion");
g_hDamagedByExplosion = DHookCreate(Offset, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity, OnDamagedByExplosion);
DHookAddParam(g_hDamagedByExplosion, HookParamType_ObjectPtr);
CloseHandle(hTemp);
2016-12-19 08:33:16 +01:00
/* Late load */
for(int client = 1; client <= MaxClients; client++)
{
if(IsClientInGame(client))
OnClientPutInServer(client);
}
2016-01-19 23:57:32 +01:00
}
public void OnClientPutInServer(int client)
{
2016-12-19 08:33:16 +01:00
// Don't add removal callback for this one
2016-01-19 23:57:32 +01:00
DHookEntity(g_hDamagedByExplosion, false, client);
}
2016-12-19 08:33:16 +01:00
// int CCSPlayer::OnDamagedByExplosion(CTakeDamageInfo const&)
public MRESReturn OnDamagedByExplosion(int pThis, Handle hReturn, Handle hParams)
2016-01-19 23:57:32 +01:00
{
// Block call
2016-12-19 08:33:16 +01:00
DHookSetReturn(hReturn, 0);
2016-01-19 23:57:32 +01:00
return MRES_Supercede;
}