Need Help For Anti Team Kill
#1

I have Setteam Commands...I want if player 1 & player 2 in same Team player 1 cant kill player 2 , and player 2 cant kill player 1.

This's Setteam Commands :
Код:
CMD:setteam(playerid,params[]) {
    if(PlayerInfo[playerid][Level] >= 7) {
	    new tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
	    if(!strlen(tmp) || !strlen(tmp2) || !IsNumeric(tmp2)) return SendClientMessage(playerid, red, "USAGE: /setteam [playerid] [teamid]");
	    new player1 = strval(tmp), teamid = strval(tmp2), string[256];

		if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
		{
			format(string, sizeof(string), "You have set \"%s's\" team to '$%d", pName(player1), teamid); SendClientMessage(playerid,blue,string);
	  		if(player1 != playerid) { format(string,sizeof(string)," \"%s\" has set your team to '$%d'", pName(playerid), teamid); SendClientMessage(player1,blue,string); }
	    	SetPlayerTeam(playerid,teamid);
	    } else return SendClientMessage(playerid,red,"ERROR: Player is not connected");
   	} else return SendClientMessage(playerid,-1,"You are not an Admin");
   	return 1;
}
*SorryForMyLittleEnglish
Reply
#2

I don't remeber the exact name of the new 0.3z callback, but if you want, you can use OnPlayerTakeDamage

PHP код:

public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    if(
team[playerid] == team[issuerid])
    {
       new 
Float:healthFloat:arm;
       if(
GetPlayerArmour(playerid) > 0
       {
            
GetPlayerArmour(playeridarm);
            
SetPlayerArmour(playeridfloatadd(armamount);
       }
       else 
       {
            
GetPlayerHealth(playeridhealth);
            
SetPlayerHealth(playeridfloatadd(healthamount);
        }
return 
1;

Reply
#3

Quote:
Originally Posted by S4t3K
Посмотреть сообщение
I don't remeber the exact name of the new 0.3z callback, but if you want, you can use OnPlayerTakeDamage

PHP код:

public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    if(
team[playerid] == team[issuerid])
    {
       new 
Float:healthFloat:arm;
       if(
GetPlayerArmour(playerid) > 0
       {
            
GetPlayerArmour(playeridarm);
            
SetPlayerArmour(playeridfloatadd(armamount);
       }
       else 
       {
            
GetPlayerHealth(playeridhealth);
            
SetPlayerHealth(playeridfloatadd(healthamount);
        }
return 
1;

Thank's i'll Try it
Reply
#4

Quote:
Originally Posted by S4t3K
Посмотреть сообщение
I don't remeber the exact name of the new 0.3z callback, but if you want, you can use OnPlayerTakeDamage

PHP код:

public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    if(
team[playerid] == team[issuerid])
    {
       new 
Float:healthFloat:arm;
       if(
GetPlayerArmour(playerid) > 0
       {
            
GetPlayerArmour(playeridarm);
            
SetPlayerArmour(playeridfloatadd(armamount);
       }
       else 
       {
            
GetPlayerHealth(playeridhealth);
            
SetPlayerHealth(playeridfloatadd(healthamount);
        }
return 
1;

Errors :

Quote:

G:\GTA SA-MP Installers\SA-MP Server\0.3x R2 Server\SATDM~FR 0.3x\gamemodes\Rg.pwn(13242) : error 028: invalid subscript (not an array or too many subscripts): "team"
G:\GTA SA-MP Installers\SA-MP Server\0.3x R2 Server\SATDM~FR 0.3x\gamemodes\Rg.pwn(13242) : warning 215: expression has no effect
G:\GTA SA-MP Installers\SA-MP Server\0.3x R2 Server\SATDM~FR 0.3x\gamemodes\Rg.pwn(13242) : error 001: expected token: ";", but found "]"
G:\GTA SA-MP Installers\SA-MP Server\0.3x R2 Server\SATDM~FR 0.3x\gamemodes\Rg.pwn(13242) : error 029: invalid expression, assumed zero
G:\GTA SA-MP Installers\SA-MP Server\0.3x R2 Server\SATDM~FR 0.3x\gamemodes\Rg.pwn(13242) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Reply
#5

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(team[playerid] == team[issuerid])
    {
       new Float:health, Float:arm;
       if(GetPlayerArmour(playerid) > 0)
       {
            GetPlayerArmour(playerid, arm);
            SetPlayerArmour(playerid, floatadd(arm, amount));
       }
       else
       {
            GetPlayerHealth(playerid, health);
            SetPlayerHealth(playerid, floatadd(health, amount));
        }
return 1;
}
Try now .
Reply
#6

Just use SetPlayerTeam and GetPlayerTeam.
Reply
#7

Quote:
Originally Posted by Neonman
Посмотреть сообщение
Just use SetPlayerTeam and GetPlayerTeam.
Can you make it for Me ?
Reply
#8

OnPlayerSpawn:
pawn Код:
SetPlayerTeam(playerid, 1); // If the player with the team 1 shoots another player in team 1, no damage will be conflicted.
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(GetPlayerTeam(playerid) == GetPlayerTeam(issuerid))
    {
       new Float:health, Float:arm;
       if(GetPlayerArmour(playerid) > 0)
       {
            GetPlayerArmour(playerid, arm);
            SetPlayerArmour(playerid, floatadd(arm, amount));
       }
       else
       {
            GetPlayerHealth(playerid, health);
            SetPlayerHealth(playerid, floatadd(health, amount));
        }
        return 1;
}
You also don't need to do this function as Neonman said, SetPlayerTeam doesn't allow you to harm another player on that team.
Reply
#9

Quote:
Originally Posted by Firewire
Посмотреть сообщение
OnPlayerSpawn:
pawn Код:
SetPlayerTeam(playerid, 1); // If the player with the team 1 shoots another player in team 1, no damage will be conflicted.
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(GetPlayerTeam(playerid) == GetPlayerTeam(issuerid))
    {
       new Float:health, Float:arm;
       if(GetPlayerArmour(playerid) > 0)
       {
            GetPlayerArmour(playerid, arm);
            SetPlayerArmour(playerid, floatadd(arm, amount));
       }
       else
       {
            GetPlayerHealth(playerid, health);
            SetPlayerHealth(playerid, floatadd(health, amount));
        }
        return 1;
}
You also don't need to do this function as Neonman said, SetPlayerTeam doesn't allow you to harm another player on that team.
Quote:

G:\GTA SA-MP Installers\SA-MP Server\0.3x R2 Server\SATDM~FR 0.3x\gamemodes\Rg.pwn(16284) : warning 202: number of arguments does not match definition

Error In This Line :

Quote:

if(GetPlayerArmour(playerid) > 0)

Reply
#10

https://sampwiki.blast.hk/wiki/GetPlayerArmour

Check !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)