Raised This Month: $51 Target: $400
 12% 

Knife Damage Request


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cirovic
Senior Member
Join Date: Sep 2019
Old 04-08-2020 , 12:30   Knife Damage Request
Reply With Quote #1

Can someone edit me this plugin: https://forums.alliedmods.net/showthread.php?t=314299

I need this DAMAGE TO SEPARATE WITH DAMAGEL AND DAMAGER, damage with left click and damage with right click.. pls someone
Cirovic is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-08-2020 , 14:23   Re: Knife Damage Request
Reply With Quote #2

Use this sub-plugin:

Code:
#include <amxmodx>
#include <crxknives>
#include <fakemeta>
#include <hamsandwich>

const KNIFE_MIDATTACK1HIT = 6
const KNIFE_MIDATTACK2HIT = 7

#if !defined MAX_PLAYERS
const MAX_PLAYERS = 32
#endif

new const PLUGIN_VERSION[] = "0.1-alpha"

new const ATTRIBUTE_SLASH_DAMAGE[] = "SLASH_DAMAGE"
new const ATTRIBUTE_STAB_DAMAGE[]  = "STAB_DAMAGE"

new g_szSlashDamage[MAX_PLAYERS + 1][8]
new g_szStabDamage[MAX_PLAYERS + 1][8]

public plugin_init()
{
	register_plugin("CRXKnives: Slash/Stab Damage", PLUGIN_VERSION, "OciXCrom")
	register_cvar("CRXKnivesSlashStab", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
	RegisterHam(Ham_TakeDamage, "player", "PreTakeDamage", 0)
}

public crxknives_knife_updated(id, iKnife, bool:bOnConnect)
{
	if(bOnConnect)
	{
		g_szSlashDamage[id][0] = EOS
		g_szStabDamage[id][0]  = EOS
	}

	if(!crxknives_get_attribute_str(id, ATTRIBUTE_SLASH_DAMAGE, g_szSlashDamage[id], charsmax(g_szSlashDamage[])))
	{
		g_szSlashDamage[id][0] = EOS
	}

	if(!crxknives_get_attribute_str(id, ATTRIBUTE_STAB_DAMAGE, g_szStabDamage[id], charsmax(g_szStabDamage[])))
	{
		g_szStabDamage[id][0] = EOS
	}
}

public PreTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage)
{
    if(is_user_connected(iInflictor) && get_user_weapon(iInflictor) == CSW_KNIFE && crxknives_can_use_skill(iInflictor))
    {
		if(KNIFE_MIDATTACK1HIT <= pev(iInflictor, pev_weaponanim) <= KNIFE_MIDATTACK2HIT)
		{
			if(g_szSlashDamage[iInflictor][0])
			{
				SetHamParamFloat(4, math_add_f(fDamage, g_szSlashDamage[iInflictor]))
			}
		}
		else
		{
			if(g_szStabDamage[iInflictor][0])
			{
				SetHamParamFloat(4, math_add_f(fDamage, g_szStabDamage[iInflictor]))
			}
		}
    }
}

Float:math_add_f(Float:fNum, const szMath[])
{
	static szNewMath[16], Float:fMath, bool:bPercent, cOperator

	copy(szNewMath, charsmax(szNewMath), szMath)
	bPercent = szNewMath[strlen(szNewMath) - 1] == '%'
	cOperator = szNewMath[0]

	if(!isdigit(szNewMath[0]))
	{
		szNewMath[0] = ' '
	}

	if(bPercent)
	{
		replace(szNewMath, charsmax(szNewMath), "%", "")
	}

	trim(szNewMath)
	fMath = str_to_float(szNewMath)

	if(bPercent)
	{
		fMath *= fNum / 100
	}

	switch(cOperator)
	{
		case '+': fNum += fMath
		case '-': fNum -= fMath
		case '/': fNum /= fMath
		case '*': fNum *= fMath
		default: fNum = fMath
	}

	return fNum
}
Skills usage:

Code:
SLASH_DAMAGE = <left click damage>
STAB_DAMAGE = <right click damage
The format is same as the DAMAGE skill from the default plugin.
__________________

Last edited by OciXCrom; 04-08-2020 at 14:23.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Cirovic
Senior Member
Join Date: Sep 2019
Old 04-09-2020 , 12:13   Re: Knife Damage Request
Reply With Quote #3

Is damage added, if right stab is 65 and my value is 200 i will deal 265 dmg or it is 200% that menas 195dmg ?
Cirovic is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-09-2020 , 14:07   Re: Knife Damage Request
Reply With Quote #4

200 will make it 200.
+200 will make it 265.
+200% will make it 195.
200% will make it 130.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:01.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode