Help lol.
#1

So I'm trying to fix bugs on a released gamemode.
The bug wasn't existing back when I downloaded gamemode
I haven't touched that part of code at all, and suddenly there's this weird bug.
I've matched the code in updated script to the downloaded script and it's all same?
I don't know what else can cause this.

Код:
CMD:teams(playerid,params[])
	{
	    new sstr[ 200 ];
		new dialog[ 1000 ];
		new p[MAX_TEAMS],m;
		for(new i; i<MAX_PLAYERS; i++)
		{
		    if(GetPlayerTeam(i)==NO_TEAM)
		    {
				m++;
			}
		    for(new g; g<MAX_TEAMS; g++)
		    {
				if(GetPlayerTeam(i) == g)
				{
				    p[g]++;
				}
		    }
		}

		for(new h; h<MAX_TEAMS; h++)
		{
			format(sstr,sizeof(sstr),"Team: %s %s Players: %d\n",TeamInfo[h][TeamName],RandomColor1(),p[h]);
		    strcat(dialog,sstr);
		}

		ShowPlayerDialog(playerid,1234,DIALOG_STYLE_LIST,"Teams Info.:",dialog,"Close","");
		return 1;
	}
This dialog is supposed to show the number of players in each team. But the issue is only for the first team. For some reason, it shows 99 players already present in the team, so if 1 person is present in that team it will show 100 players. I'm not sure what can cause this? I haven't touched this part of code at all since it was bug free when I downloaded the script. It only happens for the first team in the game.


This issue is also existing in the textdraw which the player sees when he logins, it's supposed to show the number of player per team but here too, only the #1 team has 99 players already? Mind you, this code isn't really faulty cause I did not touch this at all. It's the same as it was in the downloaded game.

Код:
public Timer_5000()
{
	new string[100];
	new p[MAX_TEAMS],m;
	for(new i; i<MAX_PLAYERS; i++)
	{
	    if(GetPlayerTeam(i)==NO_TEAM)
	    {
			m++;
		}
	    for(new g; g<MAX_TEAMS; g++)
	    {
			if(GetPlayerTeam(i) == g)
			{
			    p[g]++;
			}
	    }
	}
	for (new teams=0; teams<MAX_TEAMS; teams++) OwnedTurfs2( teams );
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 0 ],TeamInfo[ 0 ][ TeamScore ],TeamInfo[ 0 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw4,string);
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 1 ],TeamInfo[ 1 ][ TeamScore ],TeamInfo[ 1 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw7,string);
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 2 ],TeamInfo[ 2 ][ TeamScore ],TeamInfo[ 2 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw10,string);
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 3 ],TeamInfo[ 3 ][ TeamScore ],TeamInfo[ 3 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw13,string);
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 4 ],TeamInfo[ 4 ][ TeamScore ],TeamInfo[ 4 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw16,string);
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 5 ],TeamInfo[ 5 ][ TeamScore ],TeamInfo[ 5 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw19,string);
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 6 ],TeamInfo[ 6 ][ TeamScore ],TeamInfo[ 6 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw22,string);
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 7 ],TeamInfo[ 7 ][ TeamScore ],TeamInfo[ 7 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw25,string);
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 8 ],TeamInfo[ 8 ][ TeamScore ],TeamInfo[ 8 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw28,string);
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 9 ],TeamInfo[ 9 ][ TeamScore ],TeamInfo[ 9 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw31,string);
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 10 ],TeamInfo[ 10 ][ TeamScore ],TeamInfo[ 10 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw34,string);
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 11 ],TeamInfo[ 11 ][ TeamScore ],TeamInfo[ 11 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw37,string);
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 12 ],TeamInfo[ 12 ][ TeamScore ],TeamInfo[ 12 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw40,string);
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 13 ],TeamInfo[ 13 ][ TeamScore ],TeamInfo[ 13 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw43,string);
	format(string,sizeof(string),"Players: %d~n~Team-Score: %d~n~Turfs: %d/"#MAX_TURFS"",p[ 14 ],TeamInfo[ 14 ][ TeamScore ],TeamInfo[ 14 ][ TeamTurfs ]);
	TextDrawSetString(Textdraw46,string);
	return 1;
}
The issue is specifically with P[0]

I used foreach instead of for loop and it worked.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)