SA-MP Forums Archive
Help With Wierd Warning :S - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help With Wierd Warning :S (/showthread.php?tid=185610)



Help With Wierd Warning :S - <Weponz> - 25.10.2010

I get this warning:

Код:
C:\Users\Weponz\Desktop\Server Files\gamemodes\M-SAIF.pwn(721) : warning 219: local variable "string" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
On This Code:

Код:
        if(!strcmp(cmdtext, "/tc", true))//Team Chat
        {
        new string[128], Player[MAX_PLAYER_NAME];//<-------line 721
        GetPlayerName(playerid, Player, MAX_PLAYER_NAME);
        format(string, 128, "[Team Chat]: %s: %s", Player, cmdtext[2]);
        for(new i=0; i<MAX_PLAYERS; i++) if(gTeam[i]==gTeam[playerid]) SendClientMessage(i, RED, string);
        return 1;
        }
And its really trippn me out :S

Please help..


Re: Help With Wierd Warning :S - JaTochNietDan - 25.10.2010

This is because string is already defined in that scope, so you don't need to initialize it again.

new string[128]; remove it from that piece of code you posted, or else remove the other string that you've created in the higher level scope. Alternatively you could re-name it to something else.


Re: Help With Wierd Warning :S - <Weponz> - 25.10.2010

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
This is because string is already defined in that scope, so you don't need to initialize it again.

new string[128]; remove it from that piece of code you posted, or else remove the other string that you've created in the higher level scope. Alternatively you could re-name it to something else.
Thanks Alot Dude!