small warning, but how to remove it?
#1

Does anyone know how to remove this warning??

Код:
	
public OnPlayerText(playerid, text[])
{
if(text[0] == ';')
	{
		new string[256],name[24];
		GetPlayerName(playerid,name,24);
 		format(string, sizeof(string),"*** [TPM] %s(%d): %s", name, playerid, text[1]);
		for (new i = 0; i < MAX_PLAYERS; i++) --> This is line 9462
		{
			if(IsPlayerConnected(i))
			{
            if(gTeam[i] == gTeam[playerid])
			SendClientMessage(i, COLOR_TPM, string);
			}
		}
		return 0;
	}

  return 1;
}
This is the error

Код:
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\WorldTurfFun.pwn(9462) : warning 219: local variable "i" shadows a variable at a preceding level
Thanks for helping!!
Reply
#2

Search through the rest of the OnPlayerText callback for the same loop. If you don't see it, look through your script for new i; as a global variable. If so, you will have to change the variable you are using (in this case 'i') do something else, like 'j'.
Reply
#3

Quote:
Originally Posted by smokey104
Does anyone know how to remove this warning??

Код:
	
public OnPlayerText(playerid, text[])
{
if(text[0] == ';')
	{
		new string[256],name[24];
		GetPlayerName(playerid,name,24);
 		format(string, sizeof(string),"*** [TPM] %s(%d): %s", name, playerid, text[1]);
		for (new i = 0; i < MAX_PLAYERS; i++) --> This is line 9462
		{
			if(IsPlayerConnected(i))
			{
            if(gTeam[i] == gTeam[playerid])
			SendClientMessage(i, COLOR_TPM, string);
			}
		}
		return 0;
	}

  return 1;
}
This is the error

Код:
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\WorldTurfFun.pwn(9462) : warning 219: local variable "i" shadows a variable at a preceding level
Thanks for helping!!
Try this:
Код:
public OnPlayerText(playerid, text[])
{
  if(text[0] == ';')
  {
  new string[256],name[24];
  GetPlayerName(playerid,name,24);
  format(string, sizeof(string),"*** [TPM] %s(%d): %s", name, playerid, text[1]);
  if(IsPlayerConnected(i))
  {
  if(gTeam[i] == gTeam[playerid])
  SendClientMessage(i, COLOR_TPM, string);
  }
  return 0;
  }
  return 1;
}
Reply
#4

All you jsut did is delete the loop, meaning it will give him errors saying there is no defined symbol of 'i' and the IsPlayerConnected(i)) and gTeam[i] functions won't work correctly.
Reply
#5

Quote:
Originally Posted by Swift_
All you jsut did is delete the loop, meaning it will give him errors saying there is no defined symbol of 'i' and the IsPlayerConnected(i)) and gTeam[i] functions won't work correctly.
I think he already have the loop...
Reply
#6

It still wont' be affective unless inside the callback he wishes to use it.
Reply
#7

Quote:
Originally Posted by Swift_
Search through the rest of the OnPlayerText callback for the same loop. If you don't see it, look through your script for new i; as a global variable. If so, you will have to change the variable you are using (in this case 'i') do something else, like 'j'.
Thanks this worked
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)