Anti DeathMatch (OnPlayerTakeDamage)
#1

pawn Код:
if(gTeam[issuerid] == TEAM_COP || gTeam[playerid] == TEAM_CIVIL && GetPlayerWantedLevel(playerid) <=4)
{
    GetPlayerHealth(playerid, hp);
    GetPlayerArmour(playerid, armour);
    if(GetPlayerWeapon(issuerid))   SetPlayerHealth(playerid, hp-0);        SetPlayerArmour(playerid, armour-0);
}
For those that didn't understand what i am trying to do here,the answer is simple: i am trying to stop cops from killing innocent players with a wanted level below 4.
This is working 90% but it actually makes the civilians lose their health,if you use a weapon that shoots bullets fast,such as M4,MP5,etc.
So can anyone help me fix this? Fix as there won't be any health loss?

Thanks in advance.
Reply
#2

Try using SetPlayerTeam (https://sampwiki.blast.hk/wiki/SetPlayerTeam).
Reply
#3

I don't need to use SetPlayerTeam on this one.
Reply
#4

pawn Код:
if(gTeam[issuerid] == TEAM_COP || gTeam[playerid] == TEAM_CIVIL && GetPlayerWantedLevel(playerid) <=4)
{
    new Float:hp, Float:armour;
    GetPlayerHealth(playerid, hp);
    GetPlayerArmour(playerid, armour);
    SetPlayerHealth(playerid, hp-0);
    SetPlayerArmour(playerid, armour-0);
}
try this and let me know if it works.
Reply
#5

pawn Код:
if(gTeam[issuerid] == TEAM_COP || gTeam[playerid] == TEAM_CIVIL && GetPlayerWantedLevel(playerid) <=4)
{
    new Float:hp, Float:armour;
    GetPlayerHealth(playerid, hp);
    GetPlayerArmour(playerid, armour);
    SetPlayerHealth(playerid, hp+amount);
    SetPlayerArmour(playerid, armour+amount);
}
more bugs might come so show ur whole onplayertakedamage
Reply
#6

Quote:
Originally Posted by Quickie
Посмотреть сообщение
pawn Код:
if(gTeam[issuerid] == TEAM_COP || gTeam[playerid] == TEAM_CIVIL && GetPlayerWantedLevel(playerid) <=4)
{
    new Float:hp, Float:armour;
    GetPlayerHealth(playerid, hp);
    GetPlayerArmour(playerid, armour);
    SetPlayerHealth(playerid, hp+amount);
    SetPlayerArmour(playerid, armour+amount);
}
more bugs might come so show ur whole onplayertakedamage
I forgot to add the amount lol. Thanks for that.
Reply
#7

Do this under OnPlayerWeaponShot
pawn Код:
if(hittype==BULLET_HIT_TYPE_PLAYER)
{
    if(gTeam[playerid] == TEAM_COP || gTeam[hitid] == TEAM_CIVIL && GetPlayerWantedLevel(hitid) <=4) return 0;
}
Reply
#8

Quote:
Originally Posted by DavidBilla
Посмотреть сообщение
Do this under OnPlayerWeaponShot
pawn Код:
if(hittype==BULLET_HIT_TYPE_PLAYER)
{
    if(gTeam[playerid] == TEAM_COP || gTeam[hitid] == TEAM_CIVIL && GetPlayerWantedLevel(hitid) <=4) return 0;
}
That won't work 100 percent of the time because a shot doesn't have to register a hit to be a hit on client.
Reply
#9

EDIT: Nevermind. Didn't see the last post.
Reply
#10

Quote:
Originally Posted by Banana_Ghost
Посмотреть сообщение
pawn Код:
if(gTeam[issuerid] == TEAM_COP || gTeam[playerid] == TEAM_CIVIL && GetPlayerWantedLevel(playerid) <=4)
{
    new Float:hp, Float:armour;
    GetPlayerHealth(playerid, hp);
    GetPlayerArmour(playerid, armour);
    SetPlayerHealth(playerid, hp-0);
    SetPlayerArmour(playerid, armour-0);
}
try this and let me know if it works.
Why -0 o_O what sense does it make?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)