Removing teamkill
#1

Hi all,i use LSTDM V.2 and i need to remove team kills.

This is the OnPlayerDeath

Код:
public OnPlayerDeath(playerid, killerid, reason)

{
    SendDeathMessage(killerid, playerid, reason);
	new playercash;
    new string[255], pname[24];
	new killedplayer[MAX_PLAYER_NAME];
	GivePlayerMoney(killerid, 500);
	playercash = GetPlayerMoney(playerid);
	if(gTeam[killerid] == gTeam[playerid])
	{
		SendClientMessage(killerid, COLOR_ORANGE, "TEAMKILLING NOT ALLOWED!");
		SetPlayerHealth(killerid, 100);
		GetPlayerName(killerid, pname, 24);
		format(string, 255, "%s(%d) has been warned for team killing!", pname, killerid);
		SendClientMessageToAll(COLOR_ORANGE, string);
	}
	if(killerid == INVALID_PLAYER_ID)
	{
		SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
	}
	else
	{
		SendDeathMessage(killerid,playerid,reason);
		SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
		{
			GetPlayerName(playerid, killedplayer, sizeof(killedplayer));
			

			GivePlayerMoney(killerid, bounty[playerid]);
			bounty[playerid] = 0;
		}
		if(playercash > 0)
		{
			GivePlayerMoney(killerid, playercash);
		}
	}
	return 1;
}
Thanks
Reply
#2

pawn Код:
SetPlayerTeam(playerid,NO_TEAM);
To remove anti-team kill (^^removes player from all teams).

And just set players on the same team to stop team kills.
https://sampwiki.blast.hk/wiki/SetPlayerTeam
Reply
#3

Where i need to add/remove that code?
Reply
#4

I'm not sure how youre GM does things, but id set the players to a team in 'onplayerspawn' using 'SetPlayerTeam' then people in the same team cant kill each other. Then if you wish to enable team damage use 'SetPlayerTeam(playerid,NO_TEAM);' when or where you need to.
Reply
#5

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Where i need to add/remove that code?
Try OnPlayerConnect, or OnPlayerSpawn (I'd recommend the first)
Reply
#6

You would need to do something like this to disable team kills, obviously swap the defines to suit the teams in your GM.
pawn Код:
#define TEAM_COPS   0
#define TEAM_MEDICS 1
//top under includes
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(GetPlayerSkin(playerid) == 187 || 130)//i know these are not copskins but cnt b bothered looking up :)
    {
        SetPlayerTeam(playerid,TEAM_COPS);
    }
    if(GetPlayerSkin(playerid) == 400 || 401)
    {
        SetPlayerTeam(playerid,TEAM_MEDICS);
    }
    return 1;
}
Reply
#7

mmm k thanks for the help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)