Player is not taking damage and Anti Team Kill doesn't work
#1

This is the code:

OnPlayerTakeDamage
pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{  
    new Float:HP;
    GetPlayerHealth(playerid, HP);
    if(pTeam[playerid] && pTeam[issuerid] == TEAM_POLICE)
    {
        SetPlayerHealth(playerid, HP);
        GameTextForPlayer(issuerid, "~b~DON'T ATTACK TEAM MATE", 2000, 4);
    }
    // Civillian Attack Each Other //
    else if(pTeam[issuerid] && pTeam[playerid] == TEAM_CIVILLIAN)
    {
        SetPlayerHealth(playerid, HP-amount);
    }
    // Civillian Attack Police //
    else if(pTeam[issuerid] == TEAM_CIVILLIAN && pTeam[playerid] == TEAM_POLICE)
    {
        SetPlayerHealth(playerid, HP-amount);
    }
    else if(pTeam[issuerid] == TEAM_POLICE && pTeam[playerid] == TEAM_CIVILLIAN)
    {
        // Not Innocent //
        if(GetPlayerWantedLevel(playerid) >= 6 && pTeam[playerid] == TEAM_CIVILLIAN)
        {
            SetPlayerHealth(playerid, HP-amount);
        }
    }
    // Innocent //
    else if(GetPlayerWantedLevel(playerid) == 0 && pTeam[playerid] == TEAM_CIVILLIAN)
    {
        SetPlayerHealth(playerid, HP);
        GameTextForPlayer(issuerid, "~b~DON'T INNOCENT", 2000, 4);
    }
    return 1;
}
OnPlayerSpawn (Set team)
pawn Code:
if(pTeam[playerid] == TEAM_POLICE)
    {
        pTeam[playerid] = TEAM_POLICE;
    }
    else if(pTeam[playerid] == TEAM_CIVILLIAN)
    {
        pTeam[playerid] = TEAM_CIVILLIAN;
    }
Reply
#2

"GetPlayerHealth and GetPlayerArmour will return the old amounts of the player before this callback." Taken from the wiki.
I would then imagine if the player has 100 HP, every SetPlayerHealth(playerid, HP); would set him back to 100 again.
Reply
#3

What have you done to try debugging it?
Reply
#4

Actually you dont have to do this stuff for anti team kill
SetPlayerTeam covers it all
pawn Code:
//make other teams also like this in OnPlayerSpawn
    if(pTeam[playerid] == TEAM_POLICE)
    {
        pTeam[playerid] = TEAM_POLICE;
        SetPlayerTeam(playerid, pTeam[playerid]);
    }
    else if(pTeam[playerid] == TEAM_CIVILLIAN)
    {
        pTeam[playerid] = TEAM_CIVILLIAN;
        SetPlayerTeam(playerid, pTeam[playerid]);
    }
And remove all your codes in OnPlayerTakeDamage

This will make players in same team unable to kill each other! And they can kill players on other teams

EDIT: If a solution we give you worked, make a reply by telling that the solution worked. Else other guys will bump the thread unnecessarily and it will be a help for others who is looking for the same answer
Reply
#5

Quote:
Originally Posted by GameOvr
View Post
Actually you dont have to do this stuff for anti team kill
SetPlayerTeam covers it all
pawn Code:
//make other teams also like this in OnPlayerSpawn
    if(pTeam[playerid] == TEAM_POLICE)
    {
        pTeam[playerid] = TEAM_POLICE;
        SetPlayerTeam(playerid, pTeam[playerid]);
    }
    else if(pTeam[playerid] == TEAM_CIVILLIAN)
    {
        pTeam[playerid] = TEAM_CIVILLIAN;
        SetPlayerTeam(playerid, pTeam[playerid]);
    }
And remove all your codes in OnPlayerTakeDamage

This will make players in same team unable to kill each other! And they can kill players on other teams
What if they are civillians. Also i have
pawn Code:
SetPlayerTeam(playerid, pTeam[playerid]);
under OnPlayerSpawn
Reply
#6

You might want to take a look here:
https://sampwiki.blast.hk/wiki/SetPlayerTeam

It contain useful information for your case
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)