team wins
#1

Hi, I have two teams, Red and Blue.

I thought I should do:
pawn Code:
new bluecount = 0;
new redcount = 0;
pawn Code:
public OnPlayerSpawn()
{
     if(gTeam[playerid] == TEAM_BLUE)
     {
          bluecount++;
     }
     else(gTeam[playerid] == TEAM_RED)
     {
          redcount++;
      }
      return 1;
}
But i have a command to start a tdm round, so I do /start and it starts

But how do i make the round end? I tried setting a timer to detect if(bluecount == 0) red wins but didnt work
Reply
#2

help anyone?
Reply
#3

This way everytime a player spawns you are increasing the value of redcount or bluecount depending on the team..
So even with a timer to check if the count goes to 0, the count will never go at this point (0)
Reply
#4

You're just commenting on this for the post count, you provided no help to this question at all. Please don't reply if you can't help me.

I obviously have OnPlayerDisconnect bluecount-- if they are blue team and they leave.

I just need help, how would I get a round to end if everyone died?
Reply
#5

No need to declare a timer you can use the callbacks OnPlayerDeath (Called when a player dies) and OnPlayerDisconnect (Called when a player disconnects), example (Read the comments):

pawn Code:
#include <a_samp>

// Let's make a stock to check for a winner team so we can use it anywhere we want
stock CheckForWinnerTeam()
{
    if(bluecount < 1) // if the blue team count equals to anything below 1 (0, -1, -2 ... etc)
    {
        // The red team won. Do something!
        return 1;
    }
    if(redcount < 1) // if the red team count equals to anything below 1 (0, -1, -2 ... etc)
    {
        // The blue team won. Do something!
        return 1;
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    switch(gTeam[playerid])
    {
        case TEAM_BLUE: // if player in the blue team
        {
            bluecount --; // decrease the blue team count
            break;
        }
        case TEAM_RED: // if player in the red team
        {
            redcount --; // decrease the red team count
            break;
        }
        default:
            break;
    }
    CheckForWinnerTeam(); // Here comes the stock we made ABOVE
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    switch(gTeam[playerid])
    {
        case TEAM_BLUE: // if player in the blue team
        {
            bluecount --; // decrease the blue team count
            break;
        }
        case TEAM_RED: // if player in the red team
        {
            redcount --; // decrease the red team count
            break;
        }
        default:
            break;
    }
    CheckForWinnerTeam(); // Here comes the stock we made ABOVE
    return 1;
}
Reply
#6

@HellSphinX:
There's no reason to add a break and what's the point to decrease the counter when a player die and disconnect?

you must make four vars to do it right, you'll count how many players are in the same by creating 2 new vars and making 2 new ones to increase the kills/deaths which means the point earned / point lost.

pawn Code:
new
blueplayers= 0,
redplayers = 0,
bluepoints = 0,
redpoints = 0;

// it should be onplayerrequestclass, cause onplayerspawn is called every time you spawn, so it would give //you wrong values, since onplayerrequestclass is called once, is the best choise.
public OnPlayerRequestClass(playerid,classid)
{
    if(gTeam[playerid] == TEAM_BLUE) {
        blueplayers++;
    }
    else if(gTeam[playerid] == TEAM_RED) {
        redplayers++;
    }
    return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID) {
        if(gTeam[killerid] == TEAM_BLUE) {
            bluepoints++;
        }
        else if(gTeam[killerid] == TEAM_RED) {
            redpoints++;
        }
    }
}
With this, you can start with your business, you'll just have to make some value's and use some logic, i'll give you a tip.

pawn Code:
checkp()
{
     if(bluepoints > redpoints)
     {
      // here means the blue team is the winner.
     }
     else if(redpoints > bluepoints)
     {
     // here mean the red team is the winner
     }
     else if(redpoints == bluepoints)
     {
     // here we got a draw.
     }
}
See, it's not too hard, you'll just have to think a little bit.
Reply
#7

Quote:
Originally Posted by leonardo1434
View Post
@HellSphinX:
There's no reason to add a break and what's the point to decrease the counter when a player die and disconnect?
You just did it in another way (Score points) while mine (Which I don't see anything wrong with it) works with the amount of a team members like when a team gets 0 members in it the another team wins that's why I decreased the count in OnPlayerDeath and OnPlayerDisconnect.
Reply
#8

Quote:
Originally Posted by (_AcE_)
View Post
You're just commenting on this for the post count, you provided no help to this question at all. Please don't reply if you can't help me.

I obviously have OnPlayerDisconnect bluecount-- if they are blue team and they leave.

I just need help, how would I get a round to end if everyone died?
/offtopic
Seriously you think i commented for the post count?
You bumped your own topic in the next 20 minutes of the time you created it, you was desperately looking for help.
I just wanted to show you your logical mistake as you never provided the whole code, but only the code as is.
When someone is trying to help you, try to be more kind please.
Thank you.
Reply
#9

Quote:
Originally Posted by (_AcE_)
View Post
You're just commenting on this for the post count, you provided no help to this question at all. Please don't reply if you can't help me.

I obviously have OnPlayerDisconnect bluecount-- if they are blue team and they leave.

I just need help, how would I get a round to end if everyone died?
It's not obvious, in fact your question isn't even obvious since you're failing to mention a few things such as the winning conditions.
He was pointing out that when you re-spawn you'll be increasing the team count anyway so checking if it equals 0 is strange.

ie.
2 teams of 2 players each
team member from A team dies.
team member from A team dies.
team member from B team dies.

your variables would now be 4 for team A and 3 for team B seeing as it increases when they spawn.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)