Raised This Month: $ Target: $400
 0% 

Tag mismatch (Falldmg reducer)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-20-2010 , 07:14   Tag mismatch (Falldmg reducer)
Reply With Quote #1

Hello guys,

I try to reduce the fall damage of a player by a procent. (in this example 10%)

Here is my code:

PHP Code:
public fwTakeDamage(iVictimiInflictoriAttackerFloat:flDamageiDamage_type
{
    if(
iDamage_type DMG_FALL && iVictim <= 32 && iVictim >= 1)
    {
        switch(
dmglevel[iVictim])
        {
            case 
1:
            {
                new 
float:procent 10.0 // get the procent
                
new float:bDamage flDamage 100.0 // damage / 100
                
new float:aDamage bDamage procent // then multiply * procent to get the 10% of the damage
                
new dmg flDamage aDamage // remove the 10% from the real damage
                
SetHamParamFloat(4dmg); // set the damage
            
            
}
       }

but i get tag mismatches
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers

Last edited by mottzi; 07-20-2010 at 07:18.
mottzi is offline
Send a message via MSN to mottzi
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-20-2010 , 07:17   Re: Tag mismatch (Falldmg reducer)
Reply With Quote #2

new Float:dmg
__________________
Arkshine is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-21-2010 , 00:18   Re: Tag mismatch (Falldmg reducer)
Reply With Quote #3

Also, you're creating unneeded variables... this is much easier:

PHP Code:
#define DAMAGE_REDUCTION 0.9 /* 90% of total damage is applied, meaning 10% reduction */

new g_iMaxPlayers

// in plugin_init()
    
g_iMaxPlayers get_maxplayers()

//...

public fwTakeDamage(iVictimiInflictoriAttackerFloat:flDamageiDamage_type
{
    if(
iDamage_type DMG_FALL && <= iVictim <= g_iMaxPlayers)
    {
        switch(
dmglevel[iVictim])
        {
            case 
1SetHamParamFloat(4flDamage DAMAGE_REDUCTION); // set the damage
            
case 2/* If you have other cases use switch... if not, just add the dmglevel[iVictim] to the if() above, at the end */
       
}

Or if you want to actually specify the reduction amount, just make the calculations in a single line, don't create variables for each one.
__________________
Hunter-Digital 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 07:03.


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