AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Tag mismatch (Falldmg reducer) (https://forums.alliedmods.net/showthread.php?t=132928)

mottzi 07-20-2010 07:14

Tag mismatch (Falldmg reducer)
 
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

Arkshine 07-20-2010 07:17

Re: Tag mismatch (Falldmg reducer)
 
new Float:dmg

Hunter-Digital 07-21-2010 00:18

Re: Tag mismatch (Falldmg reducer)
 
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.


All times are GMT -4. The time now is 07:03.

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