Give player a certain amount of damage?
#1

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid) {
    if(issuerid != INVALID_PLAYER_ID) {
        if(PlayerInfo[issuerid][pPerks_ExtraDamage] > 0) {
            new Float:damage;
            damage = amount * 0.5;
            OnPlayerTakeDamage(playerid, INVALID_PLAYER_ID, damage, weaponid);
        }
    }
    return 1;
}
So I'm trying to make the player take 1.5x more damage, and this doesn't work. Is there a certain thing to make a player take damage?
Reply
#2

Quote:
Originally Posted by Dubya
Посмотреть сообщение
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid) {
    if(issuerid != INVALID_PLAYER_ID) {
        if(PlayerInfo[issuerid][pPerks_ExtraDamage] > 0) {
            new Float:damage;
            damage = amount * 0.5;
            OnPlayerTakeDamage(playerid, INVALID_PLAYER_ID, damage, weaponid);
        }
    }
    return 1;
}
So I'm trying to make the player take 1.5x more damage, and this doesn't work. Is there a certain thing to make a player take damage?
You don't have to call callback. You have to reduce his health by half of damage already taken.
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(PlayerInfo[issuerid][pPerks_ExtraDamage] > 0)
        {
            new Float:damage,Float:HP;
            damage = amount/2;
            GetPlayerHealth(playerid,HP);
            SetPlayerHealth(playerid,(HP-damage));
        }
    }
    return 1;
}
Reply
#3

But what if they have armour?
Reply
#4

There. It's good.
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(PlayerInfo[issuerid][pPerks_ExtraDamage] > 0)
        {
            new Float:damage,Float:HP[2];
            damage = amount/2;
            GetPlayerHealth(playerid,HP[0]);
            GetPlayerArmour(playerid,HP[1]);
            if(HP[1] <= 0.0) SetPlayerHealth(playerid,(HP-damage)); //if he doesn't have armour
            else if(HP[1] < damage) //if he has armour but it's not larger than damage we should deduct
            {
                SetPlayerArmour(playerid,0.0);
                SetPlayerHealth(playerid,HP[0]-(damage-HP[1]));
            }
            else SetPlayerArmour(playerid,HP[1]-damage); //and if his armour is high enough to take from it.
        }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
There. It's good.
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(PlayerInfo[issuerid][pPerks_ExtraDamage] > 0)
        {
            new Float:damage,Float:HP[2];
            damage = amount/2;
            GetPlayerHealth(playerid,HP[0]);
            GetPlayerArmour(playerid,HP[1]);
            if(HP[1] <= 0.0) SetPlayerHealth(playerid,(HP-damage)); //if he doesn't have armour
            else if(HP[1] < damage) //if he has armour but it's not larger than damage we should deduct
            {
                SetPlayerArmour(playerid,0.0);
                SetPlayerHealth(playerid,HP[0]-(damage-HP[1]));
            }
            else SetPlayerArmour(playerid,HP[1]-damage); //and if his armour is high enough to take from it.
        }
    }
    return 1;
}
While you were making that I made this:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid) {
    if(issuerid != INVALID_PLAYER_ID) {
        if(PlayerInfo[issuerid][pPerks_ExtraDamage] > 0) {
            new Float:damage,Float:HP,Float:A,Float:T;
            damage = amount / 2;
            T = damage;
                       GetPlayerHealth(playerid,HP);
            GetPlayerArmour(playerid, A);
            if(A > 0) { // If the player has armour
                if(damage > A) { // if damage is more than armor
                    T = damage - A; // amount of health that will be take.
                    SetPlayerArmour(playerid, 0); // getting rid of armour
                    SetPlayerHealth(playerid, (HP - T));
                } else { SetPlayerArmour(playerid, (A - damage)); }
                return 1;
            }
            SetPlayerHealth(playerid,(HP-damage));
        }
    }
    return 1;
}
Not sure if mine will work though.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)