Help with TDM And round
#1

I'm doing a tdm game mode, where there are 2 teams, blue and orange.. Here it some parts of the script

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(round > 0)
	{
	  if(team[killerid] == DMB)
	  {
		  PB++;
			GameTextForPlayer(killerid, "~b~ +1", 2000, 1);
	  }
	  else if(team[killerid] == DMO)
	  {
		  PO++;
		  GameTextForPlayer(killerid, "~y~ +1", 2000, 1);
	  }
	  if(team[killerid] == team[playerid]){
	    if(team[playerid] == DMB) PB--;
	    if(team[playerid] == DMO) PO--;
	    GameTextForPlayer(killerid, "~w~ -1", 2000, 1);
		}
	}
	if(killerid == INVALID_PLAYER_ID)
	{
    SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);

	} else
	{
	  	SendDeathMessage(killerid,playerid,reason);
	}
	return 1;
}
Код:
	if (strcmp("/startcw", cmdtext, true, 10) == 0 && IsPlayerAdmin(playerid))
	{
	  if(round > 0) {
	  
	    SendClientMessage(playerid, RED, "Una cw и giа iniziata");
	    
		} else {
		
			PreparingRound();
		}
		return 1;
	}


	if (strcmp(cmd, "/setrounds", true, 10) == 0 && IsPlayerAdmin(playerid))
	{
	  new tmp[256];
	  new rounds;
		tmp = strtok(cmdtext, idx);
		rounds = strval(tmp);
		
		if(strlen(tmp) == 0) SendClientMessage(playerid, RED, "USA: /setrounds [1-15]");
		
 		if (!IsNumeric2(tmp)) SendClientMessage(playerid, RED, "Il numero di round deve essere compreso tra 1 e 15");
 		
		else if(rounds < 1 || rounds > 15) SendClientMessage(playerid, RED, "Il numero di round deve essere compreso tra 1 e 15");
		
	  else
		{
	  	format(string, sizeof(string), "Numero di round settato a %d", rounds);
			SendClientMessageToAll(GREEN, string);
			MaxRounds = rounds;

		}
		return 1;
	}
Код:
public PreparingRound()
{

	PB = 0;
	PO = 0;
	new string[256];
	if(round < MaxRounds)
	{
		round++;

		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				//SETTING TEAM POSITION
				if(team[i] == DMB)
				{
					if(round == 1) SetPlayerPos(i,241.2442,1817.7256,17.6406);
					if(round == 2) SetPlayerPos(i,1216.0854,2799.9041,10.8203);
					if(round == 3) SetPlayerPos(i,2081.3088,2414.8938,74.5786);
					if(round == 4) SetPlayerPos(i,1714.7217,-1911.3442,13.5666);
					if(round == 5) SetPlayerPos(i,2704.1973,906.5118,10.5942);
					if(round == 6) SetPlayerPos(i,1409.3176,2123.4229,12.0156);
					if(round == 7) SetPlayerPos(i,2617.5596,2719.1956,36.5386);
					if(round == 8) SetPlayerPos(i,815.3414,-1102.5481,25.7898);
					if(round == 9) SetPlayerPos(i,2777.4817,-2379.0042,16.2244);
					if(round == 10) SetPlayerPos(i,1614.3787,950.1139,10.6892);
					if(round == 11) SetPlayerPos(i,-583.9959,-82.5619,64.9246);
					if(round == 12) SetPlayerPos(i,-28.2044,92.9659,3.1172);
					if(round == 13) SetPlayerPos(i,-459.9643,2223.8311,43.5393);
					if(round == 14) SetPlayerPos(i,-1304.7231,2557.1741,86.9873);
					if(round == 15) SetPlayerPos(i,-2119.7852,251.3441,35.7451);
				}
				if(team[i] == DMO)
				{
					if(round == 1) SetPlayerPos(i,128.2351,1921.3809,19.1034);
					if(round == 2) SetPlayerPos(i,1401.8285,2774.6309,10.8203);
					if(round == 3) SetPlayerPos(i,2188.2720,2416.8738,73.0339);
					if(round == 4) SetPlayerPos(i,1763.0464,-1920.6128,13.5742);
					if(round == 5) SetPlayerPos(i,2612.3774,791.5310,10.9545);
					if(round == 6) SetPlayerPos(i,1330.5277,2210.1230,12.0156);
					if(round == 7) SetPlayerPos(i,2746.3167,2782.1453,10.8203);
					if(round == 8) SetPlayerPos(i,936.6701,-1103.1526,24.3156);
					if(round == 9) SetPlayerPos(i,2772.5820,-2524.0115,16.2244);
					if(round == 10) SetPlayerPos(i,1743.1304,1118.2189,10.6806);
					if(round == 11) SetPlayerPos(i,-467.6872,-175.6100,78.2176);
					if(round == 12) SetPlayerPos(i,-100.3243,-61.4496,3.1172);
					if(round == 13) SetPlayerPos(i,-345.8914,2241.3804,42.4844);
					if(round == 14) SetPlayerPos(i,-1311.6449,2485.2610,87.1569);
					if(round == 15) SetPlayerPos(i,-2038.5171,250.5813,35.1514);
				}
					//FREZZING & PREPARING TO START
				if(team[i] == DMO || team[i] == DMB)
				{
					TogglePlayerControllable(i,0);
					format(string, sizeof(string), "~r~ ROUND %d ~w~ STARTING", round);
					GameTextForPlayer(i, string, 1500, 0);
				}

	      SetTimerEx("StartRound", 3000, false, "i", i);
			}
		}
	}
	else
	{
	FineCW();
	}
	return 1;
}
public StartRound(i)
{
	TogglePlayerControllable(i,1);
	GameTextForPlayer(i,"~r~ FIGHT", 2500, 0);
	endround = SetTimerEx("EndRound", RoundTime*60000, false, "i", i);
	GivePlayerWeapon(i, 24, 5000);
	if(GunSet[i] == M4) GivePlayerWeapon(i, 31, 5000);
	if(GunSet[i] == SNIPER) GivePlayerWeapon(i, 34, 5000);
	if(GunSet[i] == AK47) GivePlayerWeapon(i, 30, 5000);
	SetPlayerHealth(i, 100);
	return 1;
}

public EndRound(i)
{
	new string[256];
	GameTextForPlayer(i,"~r~ FINE ROUND", 2000, 1);
	format(string, sizeof(string), "~b~ TEAM BLU: %d ~y~ TEAM ORANGE: %d", PB, PO);
	GameTextForPlayer(i, string, 2500, 0);

	if(PB > PO) {
		GameTextForPlayer(i, "~b~ TEAM BLU VINCE IL ROUND", 2500, 0);
		RB++;
	}
	
	else if(PB < PO) {
		GameTextForPlayer(i, "~b~ TEAM ORANGE VINCE IL ROUND", 2500, 0);
		RO++;
	}
	
	else if(PB == PO) {
		GameTextForPlayer(i, "~w~ PARITA'", 2500, 0);
	}

	SetTimer("PreparingRound", 10000, false);
	return 1;
}


public FineCW()
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
		  if(team[i] == DMB || team[i] == DMO)
			{
				SetTimerEx("Respawn", 10000, false, "i", i);
				new string[256];
				GameTextForPlayer(i,"~r~ ~h~ FINE CW", 2000, 1);
				if(RB > RO) {
					format(string, sizeof(string), "~b~ TEAM BLU: %d ~y~ TEAM ORANGE~n~ ~b~ TEAM BLU VINCE LA CW", RB, RO);
					GameTextForPlayer(i, string, 2500, 0);
				}

				else if(RB < RO) {
					format(string, sizeof(string), "~b~ TEAM BLU: %d ~y~ TEAM ORANGE~n~ ~y~ TEAM ORANGE VINCE LA CW", RB, RO);
					GameTextForPlayer(i, string, 2500, 0);
				}

				else if(RB == RO) {
					format(string, sizeof(string), "~b~ TEAM BLU: %d ~y~ TEAM ORANGE: %d ~n~ ~w~ PARITA'", RB, RO);
					GameTextForPlayer(i, string, 2500, 0);
				}
			}
		}
	}
	KillTimer(endround);
	RB = 0;
	RO = 0;
	PB = 0;
	PO = 0;
	round = 0;
	
	return 1;
}

public Respawn(i)
{
SetPlayerHealth(i, 0);
ForceClassSelection(i);
}
The first round works fine, but the others rounds don't work.. Some times it go from the round 1 to round 3.. Some times the cw finish with no reason.. Why?

Full code http://pastebin.com/BndhzJnh
Reply
#2

The publics you have like:

Код:
public StartRound(i)
Tbh i dont think putting a "i" in it will loop it, as a loop dosen't have to be "i" and you haven't made stock for it (i guess) So that wouldn't work i think.. That's waht i can come up with atm.
Reply
#3

? i didn't understand
Reply
#4

Your making publics like "public Startround(i)" but "i" isen't looped by default you have to make a loop inside the public
Reply
#5

Код:
public StartRound(i)
{

	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(team[i] == DMB || team[i] == DMO)
			{
	        TogglePlayerControllable(i,1);
	        GameTextForPlayer(i,"~r~ FIGHT", 2500, 0);
	        endround = SetTimerEx("EndRound", RoundTime*60000, false, "i", i);
	        GivePlayerWeapon(i, 24, 5000);
	        if(GunSet[i] == M4) GivePlayerWeapon(i, 31, 5000);
	        if(GunSet[i] == SNIPER) GivePlayerWeapon(i, 34, 5000);
	        if(GunSet[i] == AK47) GivePlayerWeapon(i, 30, 5000);
	        SetPlayerHealth(i, 100);
            }
         }
     }
	return 1;
}
Like this?
Reply
#6

No change..
Reply
#7

Maybe:

pawn Код:
public StartRound(playerid)
{

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(team[i] == DMB || team[i] == DMO)
            {
            TogglePlayerControllable(i,1);
            GameTextForPlayer(i,"~r~ FIGHT", 2500, 0);
            endround = SetTimerEx("EndRound", RoundTime*60000, false, "i", i);
            GivePlayerWeapon(i, 24, 5000);
            if(GunSet[i] == M4) GivePlayerWeapon(i, 31, 5000);
            if(GunSet[i] == SNIPER) GivePlayerWeapon(i, 34, 5000);
            if(GunSet[i] == AK47) GivePlayerWeapon(i, 30, 5000);
            SetPlayerHealth(i, 100);
            }
         }
     }
    return 1;
}
Reply
#8

But if the first round works fine i don't think that the problem is here.. Right?
Reply
#9

Anyway, i've tryed with no "i" and putting a for loop in the public.. I've replaced all the TimerEx with some simple Timer..

Код:
//FORWARD
forward StartCW();
forward FineCW();
forward PreparingRound();
forward StartRound();
forward EndRound();
forward Respawn();
Here it is:

pawn Код:
public PreparingRound()
{

    PB = 0;
    PO = 0;
    new string[256];
    if(round < MaxRounds)
    {
        round++;

        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                //SETTING TEAM POSITION
                if(team[i] == DMB)
                {
                    if(round == 1) SetPlayerPos(i,241.2442,1817.7256,17.6406);
                    if(round == 2) SetPlayerPos(i,1216.0854,2799.9041,10.8203);
                    if(round == 3) SetPlayerPos(i,2081.3088,2414.8938,74.5786);
                    if(round == 4) SetPlayerPos(i,1714.7217,-1911.3442,13.5666);
                    if(round == 5) SetPlayerPos(i,2704.1973,906.5118,10.5942);
                    if(round == 6) SetPlayerPos(i,1409.3176,2123.4229,12.0156);
                    if(round == 7) SetPlayerPos(i,2617.5596,2719.1956,36.5386);
                    if(round == 8) SetPlayerPos(i,815.3414,-1102.5481,25.7898);
                    if(round == 9) SetPlayerPos(i,2777.4817,-2379.0042,16.2244);
                    if(round == 10) SetPlayerPos(i,1614.3787,950.1139,10.6892);
                    if(round == 11) SetPlayerPos(i,-583.9959,-82.5619,64.9246);
                    if(round == 12) SetPlayerPos(i,-28.2044,92.9659,3.1172);
                    if(round == 13) SetPlayerPos(i,-459.9643,2223.8311,43.5393);
                    if(round == 14) SetPlayerPos(i,-1304.7231,2557.1741,86.9873);
                    if(round == 15) SetPlayerPos(i,-2119.7852,251.3441,35.7451);
                }
                if(team[i] == DMO)
                {
                    if(round == 1) SetPlayerPos(i,128.2351,1921.3809,19.1034);
                    if(round == 2) SetPlayerPos(i,1401.8285,2774.6309,10.8203);
                    if(round == 3) SetPlayerPos(i,2188.2720,2416.8738,73.0339);
                    if(round == 4) SetPlayerPos(i,1763.0464,-1920.6128,13.5742);
                    if(round == 5) SetPlayerPos(i,2612.3774,791.5310,10.9545);
                    if(round == 6) SetPlayerPos(i,1330.5277,2210.1230,12.0156);
                    if(round == 7) SetPlayerPos(i,2746.3167,2782.1453,10.8203);
                    if(round == 8) SetPlayerPos(i,936.6701,-1103.1526,24.3156);
                    if(round == 9) SetPlayerPos(i,2772.5820,-2524.0115,16.2244);
                    if(round == 10) SetPlayerPos(i,1743.1304,1118.2189,10.6806);
                    if(round == 11) SetPlayerPos(i,-467.6872,-175.6100,78.2176);
                    if(round == 12) SetPlayerPos(i,-100.3243,-61.4496,3.1172);
                    if(round == 13) SetPlayerPos(i,-345.8914,2241.3804,42.4844);
                    if(round == 14) SetPlayerPos(i,-1311.6449,2485.2610,87.1569);
                    if(round == 15) SetPlayerPos(i,-2038.5171,250.5813,35.1514);
                }
                    //FREZZING & PREPARING TO START
                if(team[i] == DMO || team[i] == DMB)
                {
                    TogglePlayerControllable(i,0);
                    format(string, sizeof(string), "~r~ ROUND %d ~w~ STARTING", round);
                    GameTextForPlayer(i, string, 1500, 0);
                }

          SetTimer("StartRound", 3000, false);
            }
        }
    }
    else
    {
    FineCW();
    }
    return 1;
}
public StartRound()
{

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(team[i] == DMB || team[i] == DMO)
            {
                TogglePlayerControllable(i,1);
          GameTextForPlayer(i,"~r~ FIGHT", 2500, 0);
          endround = SetTimer("EndRound", RoundTime*60000, false);
          GivePlayerWeapon(i, 24, 5000);
          if(GunSet[i] == M4) GivePlayerWeapon(i, 31, 5000);
          if(GunSet[i] == SNIPER) GivePlayerWeapon(i, 34, 5000);
          if(GunSet[i] == AK47) GivePlayerWeapon(i, 30, 5000);
          SetPlayerHealth(i, 100);
       }
     }
  }
    return 1;
}

public EndRound()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(team[i] == DMB || team[i] == DMO)
            {
            new string[256];
            GameTextForPlayer(i,"~r~ FINE ROUND", 2000, 1);
            format(string, sizeof(string), "~b~ TEAM BLU: %d ~y~ TEAM ORANGE: %d", PB, PO);
            GameTextForPlayer(i, string, 2500, 0);

            if(PB > PO) {
                GameTextForPlayer(i, "~b~ TEAM BLU VINCE IL ROUND", 2500, 0);
                RB++;
            }

            else if(PB < PO) {
                GameTextForPlayer(i, "~b~ TEAM ORANGE VINCE IL ROUND", 2500, 0);
                RO++;
            }

            else if(PB == PO) {
                GameTextForPlayer(i, "~w~ PARITA'", 2500, 0);
            }

            SetTimer("PreparingRound", 10000, false);
            }
        }
    }
    return 1;
}


public FineCW()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
          if(team[i] == DMB || team[i] == DMO)
            {
                SetTimer("Respawn", 10000, false);
                new string[256];
                if(RB > RO) {
                    format(string, sizeof(string), "~b~ TEAM BLU: %d ~y~ TEAM ORANGE~n~ ~b~ TEAM BLU VINCE LA CW", RB, RO);
                    GameTextForPlayer(i, string, 2500, 0);
                }

                else if(RB < RO) {
                    format(string, sizeof(string), "~b~ TEAM BLU: %d ~y~ TEAM ORANGE~n~ ~y~ TEAM ORANGE VINCE LA CW", RB, RO);
                    GameTextForPlayer(i, string, 2500, 0);
                }

                else if(RB == RO) {
                    format(string, sizeof(string), "~b~ TEAM BLU: %d ~y~ TEAM ORANGE: %d ~n~ ~w~ PARITA'", RB, RO);
                    GameTextForPlayer(i, string, 2500, 0);
                }
            }
        }
    }
    KillTimer(endround);
    RB = 0;
    RO = 0;
    PB = 0;
    PO = 0;
    round = 0;
   
    return 1;
}

public Respawn()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
          if(team[i] == DMB || team[i] == DMO)
            {
                SetPlayerHealth(i, 0);
                ForceClassSelection(i);
            }
        }
    }
}
But i've the same problems
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)