Is this possible?
#7

Guys I really need this, why this ISN'T working ?
What I want to make is if player is closer to target it will cause more damage to target, but this isn't working can someone help please?

REP +1 to guy who can help :/
Thanks in advance

pawn Код:
#include a_samp

#define WEAPON_BODY_PART_TORSO 3
#define WEAPON_BODY_PART_GROIN  4
#define WEAPON_BODY_PART_LEFT_ARM 5
#define WEAPON_BODY_PART_RIGHT_ARM 6
#define WEAPON_BODY_PART_LEFT_LEG 7
#define WEAPON_BODY_PART_RIGHT_LEG 8
#define WEAPON_BODY_PART_HEAD 9

forward Float:GetDistanceBetweenPlayers(p1,p2);
public Float:GetDistanceBetweenPlayers(p1,p2)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
    {
        return -1.00;
    }
    GetPlayerPos(p1,x1,y1,z1);
    GetPlayerPos(p2,x2,y2,z2);
    return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    new Float:pHealth;
    GetPlayerHealth(playerid, pHealth);
   
    new Float:x, Float:y, Float:z;
    GetPlayerPos(issuerid, x, y, z);
   
    if(!IsPlayerConnected(playerid)) return 0;
    if(!IsPlayerConnected(issuerid)) return 0;
    if(issuerid != INVALID_PLAYER_ID && weaponid == 30 && bodypart == 9) // AK, Head
    {
        if(GetDistanceBetweenPlayers(issuerid, playerid) < 10)
        {
            SetPlayerHealth(playerid, pHealth-60);
            return 1;
        }
        else if(GetDistanceBetweenPlayers(issuerid, playerid) > 10)
        {
            SetPlayerHealth(playerid, pHealth-30);
            return 1;
        }
    }
    if(issuerid != INVALID_PLAYER_ID && weaponid == 25 && bodypart == 9) // Shotgun, Head
    {
        if(GetDistanceBetweenPlayers(issuerid, playerid) < 10)
        {
            SetPlayerHealth(playerid, pHealth-80);
            return 1;
        }
        else if (GetDistanceBetweenPlayers(issuerid, playerid) > 10 && GetDistanceBetweenPlayers(issuerid, playerid) < 15)
        {
            SetPlayerHealth(playerid, pHealth-40);
            return 1;
        }
        else if (GetDistanceBetweenPlayers(issuerid, playerid) > 15 && GetDistanceBetweenPlayers(issuerid, playerid) < 20)
        {
            SetPlayerHealth(playerid, pHealth-20);
            return 1;
        }
        else if (GetDistanceBetweenPlayers(issuerid, playerid) > 20)
        {
            SetPlayerHealth(playerid, pHealth-10);
            return 1;
        }
    }
    return 1;
}
Reply


Messages In This Thread
Is this possible? - by Lajko1 - 19.01.2014, 19:42
Re: Is this possible? - by jakejohnsonusa - 19.01.2014, 20:00
Re: Is this possible? - by Audi_Quattrix - 19.01.2014, 20:02
Re: Is this possible? - by Lajko1 - 19.01.2014, 20:23
Re: Is this possible? - by Lajko1 - 19.01.2014, 22:12
Re: Is this possible? - by Lajko1 - 20.01.2014, 09:32
Re: Is this possible? - by Lajko1 - 20.01.2014, 15:58
Re: Is this possible? - by Lajko1 - 21.01.2014, 11:07

Forum Jump:


Users browsing this thread: 1 Guest(s)