Teams help
#1

I have a way to make it so team kills get kicked. The problem is its not efficient since i gotta add many different combos like


TEAM_COP can't kill TEAM_ARMY

TEAM_ARMY cant kill TEAM_COP

Like that, it's not efficient, how can i just make 1 team kill preventing thing...


This is what i have:

pawn Код:
if(gTeam[killerid] == TEAM_COP && gTeam[playerid] == TEAM_COP && IsSpawned[killerid] == 1 && Jailed[killerid] == 0) {
    teamkiller[killerid] +=1;
    if(teamkiller[killerid] >=3) {
    new str[100];
  GetPlayerName(killerid, str, 24);
    format(str, 100, "**(AUTO KICK)** %s(%d) Too Many Team Kills(TeamKiller)", str,killerid);
    SendClientMessageToAll(0xFF7F50AA, str);
    printf("%s", str);
    SetPlayerInterior(killerid,10);
    SetPlayerPos(killerid,219.6257,111.2549,999.0156);
    SetPlayerFacingAngle(killerid,2.2339);
    SetCameraBehindPlayer(killerid);
    teamkiller[killerid] =0;
    Kicking[killerid] =1;
    SetTimer("KickPlayer",700,0);
    return 1;
}
    SendClientMessage(killerid,COLOR_RED, "TEAM KILL - Do not kill other Law Enforcement agents (Blue/Purple)");
    SendClientMessage(killerid,COLOR_RED, "If you continue to kill other Law Enforcement agents you will be kicked/banned");
    SendDeathMessage(killerid,playerid,reason);
    SetPlayerColor(playerid,COLOR_DEADCONNECT);
    oscore = GetPlayerScore(killerid);
  SetPlayerScore(killerid, oscore -1);
  return 1;
}

    if(gTeam[killerid] == TEAM_ARMY && gTeam[playerid] == TEAM_ARMY && IsSpawned[killerid] == 1 && Jailed[killerid] == 0) {
    teamkiller[killerid] +=1;
    if(teamkiller[killerid] >=3) {
    new str[100];
  GetPlayerName(killerid, str, 24);
    format(str, 100, "**(AUTO KICK)** %s(%d) Too Many Team Kills(TeamKiller)", str,killerid);
    SendClientMessageToAll(0xFF7F50AA, str);
    printf("%s", str);
    SetPlayerInterior(killerid,10);
    SetPlayerPos(killerid,219.6257,111.2549,999.0156);
    SetPlayerFacingAngle(killerid,2.2339);
    SetCameraBehindPlayer(killerid);
    teamkiller[killerid] =0;
    Kicking[killerid] =1;
    SetTimer("KickPlayer",700,0);
    return 1;
}
    SendClientMessage(killerid,COLOR_RED, "TEAM KILL - Do not kill other Law Enforcement agents (Blue/Purple)");
    SendClientMessage(killerid,COLOR_RED, "If you continue to kill other Law Enforcement agents you will be kicked/banned");
    SendDeathMessage(killerid,playerid,reason);
    SetPlayerColor(playerid,COLOR_DEADCONNECT);
    oscore = GetPlayerScore(killerid);
  SetPlayerScore(killerid, oscore -1);
  return 1;
}

    if(gTeam[killerid] == TEAM_ARMY && gTeam[playerid] == TEAM_COP && IsSpawned[killerid] == 1 && Jailed[killerid] == 0) {
    teamkiller[killerid] +=1;
    if(teamkiller[killerid] >=3) {
    new str[100];
  GetPlayerName(killerid, str, 24);
    format(str, 100, "**(AUTO KICK)** %s(%d) Too Many Team Kills(TeamKiller)", str,killerid);
    SendClientMessageToAll(0xFF7F50AA, str);
    printf("%s", str);
    SetPlayerInterior(killerid,10);
    SetPlayerPos(killerid,219.6257,111.2549,999.0156);
    SetPlayerFacingAngle(killerid,2.2339);
    SetCameraBehindPlayer(killerid);
    teamkiller[killerid] =0;
    Kicking[killerid] =1;
    SetTimer("KickPlayer",700,0);
    return 1;
}
    SendClientMessage(killerid,COLOR_RED, "TEAM KILL - Do not kill other Law Enforcement agents (Blue/Purple)");
    SendClientMessage(killerid,COLOR_RED, "If you continue to kill other Law Enforcement agents you will be kicked/banned");
    SendDeathMessage(killerid,playerid,reason);
    SetPlayerColor(playerid,COLOR_DEADCONNECT);
    oscore = GetPlayerScore(killerid);
  SetPlayerScore(killerid, oscore -1);
  return 1;
}
Reply
#2

Anyone?
Reply
#3

if(gTeam[killerid] == gTeam[playerid])//team kill happened
Reply
#4

Quote:
Originally Posted by (SF)Noobanatior
if(gTeam[killerid] == gTeam[playerid])//team kill happened
That's what i have up there. It works, but I would have to make so many different combinations for it to work.


That's why i'm asking, is there a better way to do anti team kill, other then this?
Reply
#5

Maybe on spawn, set their team?
pawn Код:
public OnPlayerSpawn(playerid)
{
 SetPlayerTeam(playerid, 1); // sets the players team to 1 when they spawn.
 return 1;
}

I think
that will automatically make them have God Mode for their team-mates
in-case they Shoot at their team-mates.

Reply
#6

Quote:
Originally Posted by ViruZZzZ_ChiLLL
Maybe on spawn, set their team?
pawn Код:
public OnPlayerSpawn(playerid)
{
 SetPlayerTeam(playerid, 1); // sets the players team to 1 when they spawn.
 return 1;
}

I think
that will automatically make them have God Mode for their team-mates
in-case they Shoot at their team-mates.
I used that, and did this:
pawn Код:
if(gTeam[playerid] == TEAM_COP) {
    SetPlayerPos( playerid, 1573.7228,-1694.9384,6.2188);
    SendClientMessage(playerid,0x1E90FFAA, "Type /commands for your commands");
    SendClientMessage(playerid,0x1E90FFAA, "POLICE OFFICER: Your job is to keep criminals off the streets of San Andreas");
    SendClientMessage(playerid,0x1E90FFAA, "Remember: This is not a deathmatch server. Please abide by the /rules and enjoy");
    hastazer[playerid] =1;
    HasLawEnforcementRadio[playerid] =1;
    LawEnforcementRadio[playerid] =1;
    TextDrawShowForPlayer(playerid,txtTypeSkill1);
    CanChooseSkill[playerid] = 0;
    SetPlayerTeam(playerid, TEAM_COP);
  }

Cops are now not able to attack each other which is great, but now, When i'm a cop and i try to kill another team, it doesn't work....and no one is able to hurt me.


I just want it to cops can't hurt each other
Reply
#7

Trying to fix the same thing, wont work
Reply
#8

Quote:
Originally Posted by ruckfules99
Trying to fix the same thing, wont work
yeah i know, I tried editing it in many ways to try to make it work, nothings working.


Any suggestions?
Reply
#9

set gTeam for everyplayer on the server and then the SetPlayerTeam just for the cops
then just check if(gTeam[killerid] == gTeam[playerid]) //teamkill for the other teams

and no one can kill you coz you are setting the players team to 1 for everyone when they spawn you only want to do this for the cop skins
Reply
#10

Quote:
Originally Posted by (SF)Noobanatior
set gTeam for everyplayer on the server and then the SetPlayerTeam just for the cops
then just check if(gTeam[killerid] == gTeam[playerid]) //teamkill for the other teams

and no one can kill you coz you are setting the players team to 1 for everyone when they spawn you only want to do this for the cop skins
I have already done this.


pawn Код:
SetPlayerTeamFromClass(playerid, classid) {

 if(classid == 0 || classid == 1 || classid == 2 || classid == 3 || classid == 4 || classid == 5 || classid == 6 || classid == 7 || classid == 10) {

        gTeam[playerid] = TEAM_COP;

    } else if(classid == 8) {

      gTeam[playerid] = TEAM_ARMY;

    } else if(classid == 9) {

      gTeam[playerid] = TEAM_CASSEC;

    } else if(classid == 11) {

      gTeam[playerid] = TEAM_AIRSUPPORT;

    } else if(classid == 12) {

      gTeam[playerid] = TEAM_MARINE;

    } else if(classid == 13) {

      gTeam[playerid] = TEAM_JAILTK;

    } else if(classid == 14) {

      gTeam[playerid] = TEAM_MEDIC;

    } else if(classid == 15) {

      gTeam[playerid] = TEAM_MECHANIC;

    } else if(classid == 16) {

      gTeam[playerid] = TEAM_BISTRO;

    } else if(classid == 17 || classid == 18) {

      gTeam[playerid] = TEAM_DRIVER;

  } else if(classid >= 19 && classid <= 64) {

      gTeam[playerid] = TEAM_CIVIL;


    }

}

Do you mean under onplayerspawn?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)