From c11d1af4867a66e91faec86d4c84815398ac9ead Mon Sep 17 00:00:00 2001 From: Greyscale Date: Mon, 11 Jan 2010 17:43:06 -0800 Subject: [PATCH 1/3] Fixed account module giving money to zombies hurting themself with self-inflicted damage. --- src/zr/account.inc | 14 +++++++++++++- src/zr/event.inc | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/zr/account.inc b/src/zr/account.inc index 191d23c..0a29579 100644 --- a/src/zr/account.inc +++ b/src/zr/account.inc @@ -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); diff --git a/src/zr/event.inc b/src/zr/event.inc index 8e38db6..c666693 100644 --- a/src/zr/event.inc +++ b/src/zr/event.inc @@ -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); From b66e93451c5da1f8b0a347a44b8e6c0364a2aa16 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Wed, 20 Jan 2010 17:48:13 -0800 Subject: [PATCH 2/3] Fixed zr_damage_suicide_human not working when enabled. --- src/zr/damage.inc | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/zr/damage.inc b/src/zr/damage.inc index e264db9..7e66334 100644 --- a/src/zr/damage.inc +++ b/src/zr/damage.inc @@ -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; } From 173b86f4acae9d94d286b3597dafe923405b5c69 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Mon, 25 Jan 2010 02:07:39 -0800 Subject: [PATCH 3/3] Switched the plugin to use SDKHooks instead of the unstable ZRTools. --- env/include/sdkhooks.inc | 6 ++++-- src/zombiereloaded.sp | 2 +- src/zr/weapons/restrict.inc | 5 +---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/env/include/sdkhooks.inc b/env/include/sdkhooks.inc index b712ec0..b225c8c 100644 --- a/env/include/sdkhooks.inc +++ b/env/include/sdkhooks.inc @@ -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 @@ -162,4 +164,4 @@ public Extension:__ext_sdkhooks = #else required = 0, #endif -}; \ No newline at end of file +}; diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index 450a027..9b8e5c0 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -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 diff --git a/src/zr/weapons/restrict.inc b/src/zr/weapons/restrict.inc index 2d477b5..71d2886 100644 --- a/src/zr/weapons/restrict.inc +++ b/src/zr/weapons/restrict.inc @@ -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;