Team kill
#1

Heyy, First post so be nice lol

My server is a TDM server and there is two teams. When you kill a memberof the other team you get exp and 500$. But if you team kill you get -1000$. The problem is that when you team kill you also get 500$ and experince.

Here's the code: }

if (Eastteam[playerid] == Eastteam[killerid] ) // Easteam Team Kill
{
SendClientMessage(killerid, COLOR_RED, "Do not Team Kill (-1000 Money)");
GivePlayerMoney(killerid,-1000);
}

if (WestTeam[playerid] == WestTeam[killerid] ) // WestTeam team Kill
{
SendClientMessage(killerid, COLOR_RED, "Do not Team Kill(-1000)");
GivePlayerMoney(killerid,-1000);
}

if (WestTeam[playerid] == WestTeam[killerid]) //East kill West
{
PlayerInfo[killerid][pExp] += 10;
PlayerInfo[playerid][pDeaths] += 1;
PlayerInfo[killerid][pKills] = PlayerInfo[killerid][pKills]+ 1;
SendClientMessage(killerid,COLOR_RED," You got 500$ for the kill and 10 EXP.");
GivePlayerMoney(killerid,500);
}

if (Eastteam[playerid] == Eastteam[killerid]) // West Kill East
{
PlayerInfo[killerid][pExp] += 10;
PlayerInfo[playerid][pDeaths] += 1;
PlayerInfo[killerid][pKills] = PlayerInfo[killerid][pKills] + 1;
SendClientMessage(killerid,COLOR_RED," You got 500$ for the kill and 10 EXP.");
GivePlayerMoney(killerid,500);
}

SendDeathMessage(killerid, playerid, reason);
return 1;
}




If someone could help it would be great
Reply
#2


pawn Code:
if ( EastTeam[killerid] == true && EastTeam[playerid] == true ) // Easteam Team Kill
  {
  SendClientMessage(killerid, COLOR_RED, "Do not Team Kill (-1000 Money)");
  GivePlayerMoney(killerid,-1000);
  }

  if ( WestTeam[killerid] == true && WestTeam[playerid] == true ) // WestTeam team Kill
  {
  SendClientMessage(killerid, COLOR_RED, "Do not Team Kill(-1000)");
  GivePlayerMoney(killerid,-1000);
  }

  if ( WestTeam[killerid] = true && WestTeam[playerid] == false ) //East kill West
  {
  PlayerInfo[killerid][pExp] += 10;
  PlayerInfo[playerid][pDeaths] += 1;
  PlayerInfo[killerid][pKills] = PlayerInfo[killerid][pKills]+ 1;
  SendClientMessage(killerid,COLOR_RED," You got 500$ for the kill and 10 EXP.");
  GivePlayerMoney(killerid,500);
  }

  if ( EastTeam[killerid] == true && EastTeam[playerid] == false ) // West Kill East
  {
  PlayerInfo[killerid][pExp] += 10;
  PlayerInfo[playerid][pDeaths] += 1;
  PlayerInfo[killerid][pKills] = PlayerInfo[killerid][pKills] + 1;
  SendClientMessage(killerid,COLOR_RED," You got 500$ for the kill and 10 EXP.");
  GivePlayerMoney(killerid,500);
  }

  SendDeathMessage(killerid, playerid, reason);
  return 1;
  }
that should work, good luck
Reply
#3

that doesn;t work
Reply
#4

The only thing that i can come up with that could be wrong, is that playerid probably is set off playerid's team before this code is executed.
If the dead playerid is set off both teams when dead, playerid will come up as false in the if statement stating if playerid is on killerid's opposite team, which makes the reward code-piece execute.

EDIT:
Wait a min, if(Eastteam[playerid] == Eastteam[killerid]).
How would playerid ever be equal to killerid?
I don't see the logic in making teams this way.
Well, you need to run a for loop running through the id's in Eastteam and Westteam, then state if the id of playerid and killerid is within the same team array.
Reply
#5

Nobody else notice the fact he is first saying. East kill east give +500

Then the same for west, then below that he has the same if check and giving -1000

Stands out a bit.

Not only that, but it's also checking if it's equal.

if(east[playerid] == east[killerid])

It should be.

if(east[playerid] && west[killerid])

That would be west killing east.

if(west[playerid] && east[killerid])

East killing west.

Reply
#6

just use the variable gTeam[MAX_PLAYERS];

and then for team kill:
pawn Code:
if (gTeam[killerid] == gTeam[playerid])
{
  // stuff
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)