SetPlayerTeams can still kill each other
#1

Hello, so im having a bit of trouble with player team still being able to kill each other, It says on the samp wiki that players in the same team cannot kill each other. Is there something wrong with my code?
pawn Код:
#define SURVIVORS 0
#define NETHERS 1

//onplayerspawn
    switch(GetPlayerTeam(playerid))
    {
        case SURVIVORS:
        {
            SetPlayerTeam(playerid, SURVIVORS);
        }
        case NETHERS:
        {
            SetPlayerTeam(playerid, NETHERS);
        }
    }
//onplayerrequestclass
    switch(classid)
    {
        case 0:
        {
            SetPlayerTeam(playerid, SURVIVORS);
            GameTextForPlayer(playerid, "~b~Survivors", 1000, 6);
            SetPlayerPos(playerid, 2528.9143,-1667.7504,15.1689);
            SetPlayerFacingAngle(playerid, 91.28600);
            SetPlayerCameraPos(playerid, 2523.7410,-1667.3444,15.0331);
            SetPlayerCameraLookAt(playerid, 2528.9143,-1667.7504,15.1689);
        }

        case 1:
        {
            SetPlayerTeam(playerid, NETHERS);
            GameTextForPlayer(playerid, "~r~NETHERS", 1000, 6);
            SetPlayerPos(playerid, 2429.6602,-1639.7306,13.4655);
            SetPlayerFacingAngle(playerid, 180.0818);
            SetPlayerCameraPos(playerid, 2430.0981,-1647.5112,13.5288);
            SetPlayerCameraLookAt(playerid, 2429.6602,-1639.7306,13.4655);
        }
    }
//i tried this command to debug it, but it works correctly (survivors get survivors returned and nethers get nether returned)
CMD:myteam(playerid, params[])
{
    if(GetPlayerTeam(playerid) == 0) return SendClientMessage(playerid, -1, ""chat" "COL_GREY"You are in the survivor's team!");
    if(GetPlayerTeam(playerid) == 1) return SendClientMessage(playerid, -1, ""chat" "COL_GREY"You are in the nether team!");
    return 1;
}
thank you.
Reply
#2

anyone?
Reply
#3

i suggest you to put on the top of script this and using it
pawn Код:
new gTeam[MAX_PLAYERS];
and then:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
 {
     if(gTeam[playerid] == gTeam[issuerid]) // checking if player's team same as attacker team
     {
         new Float:health , Float:armour
         GetPlayerHealth(playerid, health); // restoring player's health & armour
         GetPlayerArmour(playerid, armour);
         SetPlayerHealth(playerid, health);
         SetPlayerArmour(playerid, armour);
         SendClientMessage(issuerid, red, "Don't attack your team"); //

     }
     return 1;
}
sorry if this didn't help you :/
Reply
#4

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
i suggest you to put on the top of script this and using it
pawn Код:
new gTeam[MAX_PLAYERS];
and then:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
 {
     if(gTeam[playerid] == gTeam[issuerid]) // checking if player's team same as attacker team
     {
         new Float:health , Float:armour
         GetPlayerHealth(playerid, health); // restoring player's health & armour
         GetPlayerArmour(playerid, armour);
         SetPlayerHealth(playerid, health);
         SetPlayerArmour(playerid, armour);
         SendClientMessage(issuerid, red, "Don't attack your team"); //

     }
     return 1;
}
sorry if this didn't help you :/
No problem! thank you for trying i will test this
Reply
#5

Quote:
Originally Posted by Voxel
Посмотреть сообщение
No problem! thank you for trying i will test this
You are using SetPlayerTeam so you could also use GetPlayerTeam instead of using the variable gTeam just return it by 0 and it will do the job.

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
 {
    if(GetPlayerTeam(playerid) == GetPlayerTeam(issuerid))
    {
        SendClientMessage(issuerid, red, "Don't attack your team"); return 0;
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
You are using SetPlayerTeam so you could also use GetPlayerTeam instead of using the variable gTeam just return it by 0 and it will do the job.

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
 {
    if(GetPlayerTeam(playerid) == GetPlayerTeam(issuerid))
    {
        SendClientMessage(issuerid, red, "Don't attack your team"); return 0;
    }
    return 1;
}
Thank you, will try later!
Reply
#7

don't bother with that OnPlayerTakeDamage, just start your team ids from id 1 and not 0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)