Skip to content

Commit

Permalink
Release 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dronelektron committed Sep 25, 2022
2 parents 113a5e1 + bd18e4e commit 8acc564
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions scripting/melee-friendly-fire.sp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public Plugin myinfo = {
name = "Melee friendly fire",
author = "Dron-elektron",
description = "Allows you to inflict damage to the allies",
version = "1.0.0",
version = "1.0.1",
url = "https://github.com/dronelektron/melee-friendly-fire"
};

Expand All @@ -25,7 +25,13 @@ public void OnClientPutInServer(int client) {
}

public void Hook_TraceAttackPost(int victim, int attacker, int inflictor, float damage, int damageType, int ammoType, int hitbox, int hitGroup) {
if (IsMeleeAttack(damageType) && IsPluginEnalbed()) {
bool takeDamage = true;

takeDamage &= IsPluginEnalbed();
takeDamage &= IsMeleeAttack(damageType);
takeDamage &= HasSameTeam(attacker, victim);

if (takeDamage) {
int weapon = GetPlayerWeaponSlot(attacker, WEAPON_SLOT_MELEE);

SDKHooks_TakeDamage(victim, inflictor, attacker, damage, damageType, weapon);
Expand All @@ -39,3 +45,10 @@ bool IsMeleeAttack(int damageType) {
bool IsPluginEnalbed() {
return g_pluginEnabled.IntValue == 1;
}

bool HasSameTeam(int client, int target) {
int clientTeam = GetClientTeam(client);
int targetTeam = GetClientTeam(target);

return clientTeam == targetTeam;
}

0 comments on commit 8acc564

Please sign in to comment.