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

Editing damage dealt by custom weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DeLiriuM
Senior Member
Join Date: Dec 2006
Old 07-26-2011 , 02:41   Editing damage dealt by custom weapons
Reply With Quote #1

Hey,

I'm trying to edit a custom weapons damage dealt, but everything i try seems to fail.

So here's the code->

Code:
public TakeDamage(victim, inflictor, attacker, Float:damage, damage_type) {     if (victim == attacker || !is_user_connected(attacker))         return HAM_IGNORED;                 if (get_user_weapon(attacker) == CSW_KNIFE && !IsGrenade(inflictor) && g_Chain[attacker])     {                SetHamParamFloat(4, 500)     }                    if (get_user_weapon(attacker) == CSW_KNIFE && !IsGrenade(inflictor) && g_Electro[attacker])     {         SetHamParamFloat(4, 80)     }     if (get_user_weapon(attacker) == CSW_KNIFE && !IsGrenade(inflictor) && g_CrowBar[attacker] && get_user_team(attacker) != get_user_team(victim))     {         SetHamParamFloat(4, 50)     }         if (get_user_team(victim) == get_user_team(attacker) && IsGrenade(inflictor))     {         return HAM_SUPERCEDE     }         return HAM_IGNORED }

Weapons deal waay too little damage. Between 15-20, no matter if it's in the head or body.

So I want the weapons to deal atleast 25 damage, and 50-70 if it's in the head...
__________________

Last edited by DeLiriuM; 07-26-2011 at 05:01.
DeLiriuM is offline
t3hNox
Senior Member
Join Date: Oct 2009
Old 07-26-2011 , 04:21   Re: Editing damage dealt by custom weapons
Reply With Quote #2

I don't know if it is the main fault but you are not passing a float value in SetHamParamFloat.

It should be SetHamParamFloat(4, 500.0) NOT SetHamParamFloat(4, 500).
Also probably 3rd and 4th IF could be changed to ELSE IF.
t3hNox is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-26-2011 , 05:08   Re: Editing damage dealt by custom weapons
Reply With Quote #3

Test on non-armored players and print some debug messages to be sure they get damaged by the right values...

Also, alot of wasted calls there, consider this instead:
Code:
    if (get_user_weapon(attacker) == CSW_KNIFE && !IsGrenade(inflictor))
    {
        new Float:fDamage = 0.0

        if(g_Chain[attacker])
           fDamage = 500.0
        else if(g_Electro[attacker])
           fDamage = 80.0
        else if(g_CrowBar[attacker] && get_user_team(attacker) != get_user_team(victim))
           fDamage = 50.0

        if(fDamage > 0.0)
        {
           SetHamParamFloat(4, fDamage)
           client_print(attacker, print_chat, "[debug] Damage changed to %.1f", fDamage)
        }
        else
           client_print(attacker, print_chat, "[debug] No damage change!")
    }
And why are you checking for friendlyfire only on crowbar ?
__________________
Hunter-Digital is offline
DeLiriuM
Senior Member
Join Date: Dec 2006
Old 07-26-2011 , 05:32   Re: Editing damage dealt by custom weapons
Reply With Quote #4

Quote:
Originally Posted by Hunter-Digital View Post
Test on non-armored players and print some debug messages to be sure they get damaged by the right values...

Also, alot of wasted calls there, consider this instead:
Code:
    if (get_user_weapon(attacker) == CSW_KNIFE && !IsGrenade(inflictor))
    {
        new Float:fDamage = 0.0

        if(g_Chain[attacker])
           fDamage = 500.0
        else if(g_Electro[attacker])
           fDamage = 80.0
        else if(g_CrowBar[attacker] && get_user_team(attacker) != get_user_team(victim))
           fDamage = 50.0

        if(fDamage > 0.0)
        {
           SetHamParamFloat(4, fDamage)
           client_print(attacker, print_chat, "[debug] Damage changed to %.1f", fDamage)
        }
        else
           client_print(attacker, print_chat, "[debug] No damage change!")
    }
And why are you checking for friendlyfire only on crowbar ?
Thanks!

The plugins isn't mine, but yeah. That's strange, will fix that
__________________
DeLiriuM is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-26-2011 , 17:06   Re: Editing damage dealt by custom weapons
Reply With Quote #5

Also, you were setting integer values into a function that accepts floats.
When the integer is casted into the float value, it isn't the same value anymore.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 05:50.


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