SA-MP Forums Archive
Onplayertakedamage - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Onplayertakedamage (/showthread.php?tid=545158)



Onplayertakedamage - Hostoxide - 06.11.2014

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


Re: Onplayertakedamage - M4D - 06.11.2014

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;
}



Re: Onplayertakedamage - Hostoxide - 06.11.2014

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


Re: Onplayertakedamage - Pottus - 06.11.2014

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)