This commit is contained in:
Greyscale 2010-01-26 15:59:00 -08:00
commit 4bb9fa90a0
6 changed files with 44 additions and 27 deletions

View File

@ -54,6 +54,7 @@ enum SDKHookType
SDKHook_Touch,
SDKHook_TraceAttack,
SDKHook_TraceAttackPost,
SDKHook_WeaponCanSwitchTo,
SDKHook_WeaponCanUse,
SDKHook_WeaponDrop,
SDKHook_WeaponEquip,
@ -74,6 +75,7 @@ funcenum SDKHookCB
public(entity, other),
// SetTransmit
Action:public(entity, client),
// WeaponCanSwitchTo
// WeaponCanUse
// WeaponDrop
// WeaponEquip
@ -84,7 +86,7 @@ funcenum SDKHookCB
// OnTakeDamagePost
public(victim, attacker, inflictor, Float:damage, damagetype),
// FireBullets
public(client, shots, String:weaponname[]),
public(client, shots, const String:weaponname[]),
// TraceAttack
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup),
// TraceAttackPost

View File

@ -26,7 +26,7 @@
*/
// Comment to use ZR Tools Extension, otherwise SDK Hooks Extension will be used.
//#define USE_SDKHOOKS
#define USE_SDKHOOKS
#pragma semicolon 1
#include <sourcemod>

View File

@ -74,7 +74,7 @@ AccountOnClientSpawn(client)
* @param attacker The attacker index.
* @param dmg The amount of damage inflicted.
*/
AccountOnClientHurt(attacker, dmg_health)
AccountOnClientHurt(client, attacker, dmg_health)
{
// If attacker isn't valid, then stop.
if (!ZRIsClientValid(attacker))
@ -89,6 +89,18 @@ AccountOnClientHurt(attacker, dmg_health)
return;
}
// If attacker is hurting themself, then stop.
if (client == attacker)
{
return;
}
// If attacker isn't a human, then stop.
if (!InfectIsClientHuman(attacker))
{
return;
}
// Get current cash, add the damage done to it, then set new value.
new cash = AccountGetClientCash(attacker);
AccountSetClientCash(attacker, cash + dmg_health);

View File

@ -364,7 +364,7 @@ public ZRTools_Action:DamageOnTakeDamage(client, inflictor, attacker, Float:dama
}
/**
* Command callback (kill, jointeam, spectate)
* Command callback (kill, spectate, jointeam, joinclass)
* Block command if plugin thinks they are trying to commit suicide.
*
* @param client The client index.
@ -398,31 +398,37 @@ public Action:DamageSuicideIntercept(client, argc)
// Check if client is a zombie.
if (InfectIsClientInfected(client))
{
// If client is a normal zombie, and suicide intercept is disabled for zombies, then let command go.
if (!g_bDamageMotherZombie[client] && !suicidezombie)
// If client is a mother zombie, and suicide intercept is enabled for mother zombies zombies, then block command.
if (g_bDamageMotherZombie[client] && suicidezombiemother)
{
return Plugin_Continue;
// Tell client their command has been intercepted, and log.
TranslationPrintToChat(client, "Damage suicide intercept");
LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_Damage, "Suicide Intercept", "Player \"%L\" attempted suicide.", client);
return Plugin_Handled;
}
// If client is a mother zombie, and suicide intercept is disabled for mother zombies, then let command go.
if (g_bDamageMotherZombie[client] && !suicidezombiemother)
// If client is a zombie, and suicide intercept is enabled for zombies, then block command.
if (!g_bDamageMotherZombie[client] && suicidezombie)
{
return Plugin_Continue;
// Tell client their command has been intercepted, and log.
TranslationPrintToChat(client, "Damage suicide intercept");
LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_Damage, "Suicide Intercept", "Player \"%L\" attempted suicide.", client);
return Plugin_Handled;
}
}
// If client is a human, and suicide intercept is disabled for humans, then let command go.
if (InfectIsClientHuman(client) && !suicidehuman)
// If client is a human, and suicide intercept is enabled for humans, then block command.
if (InfectIsClientHuman(client) && suicidehuman)
{
return Plugin_Continue;
// Tell client their command has been intercepted, and log.
TranslationPrintToChat(client, "Damage suicide intercept");
LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_Damage, "Suicide Intercept", "Player \"%L\" attempted suicide.", client);
return Plugin_Handled;
}
// Tell client their command has been intercepted.
TranslationPrintToChat(client, "Damage suicide intercept");
// Log suicide interception
LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_Damage, "Suicide Intercept", "Player \"%L\" attempted suicide.", client);
// Block command.
return Plugin_Handled;
// Allow command.
return Plugin_Continue;
}

View File

@ -239,7 +239,7 @@ public Action:EventPlayerHurt(Handle:event, const String:name[], bool:dontBroadc
// Forward event to modules.
ClassAlphaUpdate(index);
InfectOnClientHurt(index, attacker, weapon);
AccountOnClientHurt(attacker, dmg_health);
AccountOnClientHurt(index, attacker, dmg_health);
SEffectsOnClientHurt(index);
KnockbackOnClientHurt(index, attacker, weapon, hitgroup, dmg_health);
NapalmOnClientHurt(index, attacker, weapon);

View File

@ -139,10 +139,7 @@ RestrictClientInit(client)
{
// Hook "Weapon_CanUse" on client.
#if defined USE_SDKHOOKS
SDKHook(client, SDKHook_WeaponEquip, RestrictCanUse);
// Note: Do we need to use WeaponSwitch too? On infection all weapons
// are removed anyways.
SDKHook(client, SDKHook_WeaponCanUse, RestrictCanUse);
// Set dummy value so it think it's hooked.
g_iCanUseHookID[client] = 1;