Team damage / 2, How to do this?
#1

Is it possible to half the damage that you do on teammembers? I don't want to completely disable team damage, though, so don't say I can do that, cause I know how to
Reply
#2

Try adding this:

pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
    new Float:health;
    new Float:sum = GetPlayerHealth(damagedid,health) + amount / 2;
    if(pInfo[damagedid][Team] == pInfo[playerid][Team]) //Switch to your team variables
    {
        SetPlayerHealth(damagedid,sum); //Setting the damaged teammate's health to whatever he had plus half the damage he took
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by redneckvideogamer
Посмотреть сообщение
Try adding this:

pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
    new Float:health;
    new Float:sum = GetPlayerHealth(damagedid,health) + amount / 2;
    if(pInfo[damagedid][Team] == pInfo[playerid][Team]) //Switch to your team variables
    {
        SetPlayerHealth(damagedid,sum); //Setting the damaged teammate's health to whatever he had plus half the damage he took
    }
    return 1;
}
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if (GodMode[playerid] == 1)
    {
        SetPlayerHealth(playerid, 0x7F800000);
    }
    else
    {
        if(issuerid != INVALID_PLAYER_ID)
        {
            if (gTeam[playerid] == gTeam[issuerid])
            {
                new Float:Health;
                new Float:NewHealth = GetPlayerHealth(playerid,Health) + (0.5 * amount);
                SetPlayerHealth(playerid, NewHealth);
            }
        }
    }
    return 1;
}
Just made this, and I think it's about the same.

Would it work? I'd test it out but I don't have anyone to test it out on :<
Reply
#4

Send me IP via PM and I'll help you out.

(Either use Hamachi or Port-Forward), but it should work.
Reply
#5

It's working now, but if anyone has a way to get this effect done better please let me know.
Reply
#6

Try(but preserve your actual code cus I didnt test this):

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if (GodMode[playerid] == 1)
    {
        SetPlayerHealth(playerid, 0x7F800000);
    }
    else
    {
        if(issuerid != INVALID_PLAYER_ID)
        {
            if (gTeam[playerid] == gTeam[issuerid])
            {
                new Float:Health,Float:Armour;
                GetPlayerHealth(playerid,Health);
                GetPlayerArmour(playerid,Armour);
                if(amount < Health+Armour) //avoid double kill for playerid
                {
                    if(Armour>0.0) {
                        Armour -= amount/2.0;
                        if(Armour < 0.0) Health += Armour;
                    }
                    else {
                        Health -= amount/2.0;
                    }
                    SetPlayerArmour(playerid,(Armour>0)?(Armour):(0.0));
                    SetPlayerHealth(playerid, Health);
                }
            }
        }
    }
    return 1;
}
Reply
#7

What does this part do:

SetPlayerArmour(playerid,(Armour>0)?(Armour)0.0) );

I don't understand the

(Armour>0)?(Armour) : (0,0) part..

Does it say is Armour more than 0, then armour = Armour, else armour = 0.0?
Reply
#8

Yes, I put ternary operator for avoid negative armour.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)