Give Damage Help!
#1

pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
    if(InTeamDM[playerid] == 1 && InTeamDM[damagedid] == 1)
    {
        if(PlayerTeam[playerid] == PlayerTeam[damagedid])
        {
            GameTextForPlayer(playerid,"~r~DO NOT ATTACK YOU TEAM MATES", 5000, 3);
        }
        return 1;
    }

    if(pctp[playerid] == 1 && pctp[damagedid] == 1)
    {
        if(GetPlayerTeam(playerid) == GetPlayerTeam(damagedid))
        {
            GameTextForPlayer(playerid,"~r~DO NOT ATTACK YOU TEAM MATES", 5000, 3);
        }
        return 1;
    }
    return 1;
}
this is the code. in this i want that if players are in teamdm or in pctp.. and they attack same team players they should get a message and their health should not decrease,
but it works correct when the players are in TeamDm or pctp. but when there pctp and teamdm variables are = 0; means when they are not in teamDm or pctp.. message doesn't show that don't attack team mates it okk but health is not getting decreased..
please help!
Reply
#2

Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
    if((InTeamDM[playerid] == 1 && InTeamDM[damagedid] == 1) || pctp[playerid] == 1 && pctp[damagedid] == 1)
    {
        if(PlayerTeam[playerid] == PlayerTeam[damagedid])
        {
            new Float:Health;
            GetPlayerHealth(damagedid,Health);
            GameTextForPlayer(playerid,"~r~DO NOT ATTACK YOU TEAM MATES", 5000, 3);
            SetPlayerHealth(damagedid,Health);
        }
    }
    return 1;
}
This should work.
Reply
#3

not works.
if player is not in tdm or pctm the health is not getting decreased. and if the player is in tdm or pctp even i shoot other team member it says do not attack team members and when i attack my same team mate it says do not attack team member.
Reply
#4

Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
    new Float:Health;
    GetPlayerHealth(damagedid,Health);
    if(InTeamDM[playerid] == 1 && InTeamDM[damagedid] == 1)
    {
        if(PlayerTeam[playerid] == PlayerTeam[damagedid])
        {
            GameTextForPlayer(playerid,"~r~DO NOT ATTACK YOU TEAM MATES", 5000, 3);
            SetPlayerHealth(damagedid, Health);
        }
        return 1;
    }

    if(pctp[playerid] == 1 && pctp[damagedid] == 1)
    {
        if(GetPlayerTeam(playerid) == GetPlayerTeam(damagedid))
        {
            GameTextForPlayer(playerid,"~r~DO NOT ATTACK YOU TEAM MATES", 5000, 3);
            SetPlayerHealth(damagedid, Health);
        }
        return 1;
    }
    return 1;
}
Reply
#5

man there is other problem when i remove all this code. and the players is not getting any damage..
Reply
#6

You should call OnPlayerTakeDamage then. It's more accurate when it comes on taken damage, not on given.

https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)