Raised This Month: $ Target: $400
 0% 

Change the damage of the knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Newu$er
Member
Join Date: Apr 2008
Old 12-24-2008 , 03:43   Change the damage of the knife
Reply With Quote #1

How can I change the damage of the knife in a player?

Thx
Newu$er is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 12-24-2008 , 04:43   Re: Change the damage of the knife
Reply With Quote #2

Code:
#include <amxmodx>
#include <hamsandwich>
 
new g_iMaxPlayers;
 
public plugin_init(){
 
RegisterHam(Ham_TakeDamage, "player", "Function");
 
g_iMaxPlayers = get_maxplayers();
}
 
public Function(id, inflictor, attacker, Float:damage, damagebits){
 
  if ( !(1 <= attacker <= g_iMaxPlayers) || !(1 <= id <= g_iMaxPlayers) || !is_user_alive(id) )
      return HAM_IGNORED;
 
  new weapon = get_user_weapon(attacker, _, _);
 
  if (weapon == CSW_KNIFE )
  {
      SetHamParamFloat(4, damage * 2); //Here knife does double damage, ofc you can set it to 0.0 or anything.
      return HAM_HANDLED;
  }
 
  return HAM_IGNORED;
}
Edit: Original isn't mine.
SnoW is offline
Send a message via MSN to SnoW
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-24-2008 , 04:54   Re: Change the damage of the knife
Reply With Quote #3

This : !(1 <= id <= g_iMaxPlayers) is not needed since the forward is registered with classname "player".
Also i think is_user_alive(id) is not needed.
Last, you should check if inflictor is same as attacker.
When a player is hit by a hegrenade, when damage is proceeded, attacker can have his knife on, so if inflictor is not same as attacker, just return the function.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 12-24-2008 , 05:11   Re: Change the damage of the knife
Reply With Quote #4

Okay so this is fine?
Code:
#include <amxmodx>
#include <hamsandwich>
 
public plugin_init()
{
   RegisterHam(Ham_TakeDamage, "player", "Function");
}
 
public Function(id, inflictor, attacker, Float:damage, damagebits)
{
   if(!is_user_connected(attacker)) 
       return HAM_IGNORED 
   new weapon = get_user_weapon(attacker, _, _) 
   if(weapon == CSW_KNIFE) 
   { 
      SetHamParamFloat(4, 0.0) //Modify here ofc...
       return HAM_HANDLED 
   } 
   return HAM_IGNORED 
}
SnoW is offline
Send a message via MSN to SnoW
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-24-2008 , 05:23   Re: Change the damage of the knife
Reply With Quote #5

!(1 <= attacker <= g_iMaxPlayers) would be faster than is_user_connected.
Was not need for id, but not for attacker.

I would try something like this :

PHP Code:
public Player_TakeDamage(idinflictorattackerFloat:damagedamagebits)
{
    if(    !(
<= attacker <= g_iMaxPlayers
    ||    
attacker != inflictor
    
||    get_user_weapon(attacker) != CSW_KNIFE    )
        return 
HAM_IGNORED;
 
    
SetHamParamFloat(4damage 2); //Here knife does double damage, ofc you can set it to 0.0 or anything.
    
return HAM_HANDLED;

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Newu$er
Member
Join Date: Apr 2008
Old 12-24-2008 , 06:17   Re: Change the damage of the knife
Reply With Quote #6

Thx, this work, +karma

Last edited by Newu$er; 12-24-2008 at 06:20.
Newu$er is offline
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 09:17.


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