Count team kills
#1

hello guys i made a war system the team with highest kill will win the war i did everything else but i have no idea how to count both teams kills and then compare between two so the team with highest kills will win

i am not asking for a all code just want a simple example
Reply
#2

Alright, for example we have team 1 & team 2

we will create a variable to store the kills in
Код:
new Team1Kills = 0;
new Team2Kills = 0;
Then as it's a war server, it should increase the team kills after a member of the team kills a member of the other team
so we will use
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    return1;
}
So here we go:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(GetPlayerTeam(killerid) == 1) // Checks if the killer is in team 1
    {
        // if the killer in team 1 it will increase the Team1Kills by 1
        Team1Kills = Team1Kills + 1; // or you can use "Team1Kills += 1;
    }
    else if(GetPlayerTeam(killerid) == 2) // Checks if the killer is in team 2
    {
        // if the killer in team 2 it will increase the Team2Kills by 1
        Team2Kills = Team2Kills + 1; // or you can use "Team2Kills += 1;
    }
    return1;
}
Not really good one, but yeah, good for an example
Reply
#3

Quote:
Originally Posted by UnDetectable
Посмотреть сообщение
Alright, for example we have team 1 & team 2

we will create a variable to store the kills in
Код:
new Team1Kills = 0;
new Team2Kills = 0;
Then as it's a war server, it should increase the team kills after a member of the team kills a member of the other team
so we will use
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    return1;
}
So here we go:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(GetPlayerTeam(killerid) == 1) // Checks if the killer is in team 1
    {
        // if the killer in team 1 it will increase the Team1Kills by 1
        Team1Kills = Team1Kills + 1; // or you can use "Team1Kills += 1;
    }
    else if(GetPlayerTeam(killerid) == 2) // Checks if the killer is in team 2
    {
        // if the killer in team 2 it will increase the Team2Kills by 1
        Team2Kills = Team2Kills + 1; // or you can use "Team2Kills += 1;
    }
    return1;
}
Not really good one, but yeah, good for an example
thanks for the example it really helped here is my code

Код:
new BallasKills = 0;
new GrovesKills = 0;
new VagosKills = 0;
new AztecasKills = 0;
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(IsPlayerCapturing[killerid] == 1)
	{
	    if(gTeam(killerid) == TEAM_BALLAS) 
	    {
	        BallasKills = BallasKills + 1;
	    }
	    else if(gTeam(killerid) == TEAM_GROVES) 
	    {
	        GrovesKills = GrovesKills + 1; 
	    }
	    else if(gTeam(killerid) == TEAM_VAGOS) 
	    {
	        VagosKills = VagosKills + 1; 
	    }
 	    else if(gTeam(killerid) == TEAM_AZTECAS)
	    {
	        AztecasKills = AztecasKills + 1; 
	    }
	}
    return 1;
}
here is my timer (war time):
Код:
SetTimer("TurfWar",100000,0);
so when the war ends i got team kills stored my question is how i can compare between 2 teams and announce higest kill team winner:

Код:
public TurfWar(playerid)
{
    //here ???
    return 1;
}
Reply
#4

PHP код:
if(TEAM_BALLAS MAX_KILL){
        
GameTextForAll"TEAM_BALLAS wins"5000);
    } 
Reply
#5

Quote:
Originally Posted by iTakelot
Посмотреть сообщение
PHP код:
if(TEAM_BALLAS MAX_KILL){
        
GameTextForAll"TEAM_BALLAS wins"5000);
    } 
i have more than one zone so should i do it like this:

Код:
public TurfWarTimer(playerid)
{
 	if(zAttack[Beach] == 1 && BallasKills > MAX_TURF_KILLS)
	{
	    zAttack[Beach] = 0;
            TeamCheck[Beach] == TEAM_BALLAS;
	    SendClientMessageToAll(-1, "{FFD443}[ TurfWar ]: {FFE797}Ballas gang has won");
	    foreach(new i : Player)
	    {
	           if(gTeam[i] == TEAM_BALLAS)
		   {
			SetPlayerScore(i, GetPlayerScore(i) + 5); 
		   }
           }
      }

 	if(zAttack[Beach] == 1 && GrovesKills > MAX_TURF_KILLS)
	{
	    zAttack[Beach] = 0;
            TeamCheck[Beach] == TEAM_GROVES;
	    SendClientMessageToAll(-1, "{FFD443}[ TurfWar ]: {FFE797}Ballas gang has won");
	    foreach(new i : Player)
	    {
	           if(gTeam[i] == TEAM_GROVES)
		   {
			SetPlayerScore(i, GetPlayerScore(i) + 5); 
		   }
           }
      }
    return 1;
}
or is there any other way i can make the code less?
Reply
#6

Anyone can help?
Reply
#7

.....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)