Onplayertakedamage
#1

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(PlayerInfo[playerid][OnDuty] == 1 || PlayerInfo[playerid][God] == 1)
    {
    if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
    {
        new string[128];
        new Float:distance = GetDistanceBetweenPlayers(playerid, issuerid, UNIT_METERS); // LINE 43
        format(string, sizeof(string), "~y~%s ~b~headshotted ~y~%s ~w~from ~r~%f meters.",GetName(issuerid),GetName(playerid), distance);
        bMessage(string);
        GameTextForPlayer(issuerid,"~r~Headshot!!", 3000, 3);
        GameTextForPlayer(playerid,"~r~Headshot!!", 3000, 3);
        SetPlayerHealth(playerid, 0.0);
    }
    }
    if(PlayerInfo[playerid][OnDuty] == 1 || PlayerInfo[playerid][God] == 1)
    {
        PlayerInfo[playerid][Aweaps] = 1;
        SetPlayerHealth(playerid, 1000.0);
        GameTextForPlayer(issuerid,"~r~Don't attack admins on-duty!", 3000, 3);
        new Float:Health, Float:x, Float:y, Float:z; GetPlayerHealth(issuerid,Health);
        GetPlayerPos(issuerid,x,y,z); SetPlayerPos(issuerid,x,y,z+6); PlayerPlaySound(issuerid,1190,0.0,0.0,0.0); PlayerPlaySound(issuerid,1190,0.0,0.0,0.0);
    }

    return 1;
}
Problem is Admin get Head shot when onduty but im used same for DOn't attack admins on duty second working for me

but that headshot show msg admin get headshot but admin not died
Reply
#2

Try This:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(PlayerInfo[playerid][OnDuty] == 1 || PlayerInfo[playerid][God] == 1)
    {
        PlayerInfo[playerid][Aweaps] = 1;
        SetPlayerHealth(playerid, 1000.0);
        GameTextForPlayer(issuerid,"~r~Don't attack admins on-duty!", 3000, 3);
        new Float:Health, Float:x, Float:y, Float:z;
        GetPlayerHealth(issuerid,Health);
        GetPlayerPos(issuerid,x,y,z);
        SetPlayerPos(issuerid,x,y,z+6);
        PlayerPlaySound(issuerid,1190,0.0,0.0,0.0);
    }
    if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
    {
        new string[128];
        new Float:distance = GetDistanceBetweenPlayers(playerid, issuerid, UNIT_METERS); // LINE 43
        format(string, sizeof(string), "~y~%s ~b~headshotted ~y~%s ~w~from ~r~%f meters.",GetName(issuerid),GetName(playerid), distance);
        bMessage(string);
        GameTextForPlayer(issuerid,"~r~Headshot!!", 3000, 3);
        GameTextForPlayer(playerid,"~r~Headshot!!", 3000, 3);
        SetPlayerHealth(playerid, 0.0);
    }

    return 1;
}
Reply
#3

Quote:
Originally Posted by M4D
Посмотреть сообщение
Try This:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(PlayerInfo[playerid][OnDuty] == 1 || PlayerInfo[playerid][God] == 1)
    {
        PlayerInfo[playerid][Aweaps] = 1;
        SetPlayerHealth(playerid, 1000.0);
        GameTextForPlayer(issuerid,"~r~Don't attack admins on-duty!", 3000, 3);
        new Float:Health, Float:x, Float:y, Float:z;
        GetPlayerHealth(issuerid,Health);
        GetPlayerPos(issuerid,x,y,z);
        SetPlayerPos(issuerid,x,y,z+6);
        PlayerPlaySound(issuerid,1190,0.0,0.0,0.0);
    }
    if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
    {
        new string[128];
        new Float:distance = GetDistanceBetweenPlayers(playerid, issuerid, UNIT_METERS); // LINE 43
        format(string, sizeof(string), "~y~%s ~b~headshotted ~y~%s ~w~from ~r~%f meters.",GetName(issuerid),GetName(playerid), distance);
        bMessage(string);
        GameTextForPlayer(issuerid,"~r~Headshot!!", 3000, 3);
        GameTextForPlayer(playerid,"~r~Headshot!!", 3000, 3);
        SetPlayerHealth(playerid, 0.0);
    }

    return 1;
}
Same problem
Reply
#4

The problem is this logic here

if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)

It should be


else if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)