Why I get those warning? :S
#10

Quote:
Originally Posted by Infinity
Посмотреть сообщение
The warning indicates that a local variable shadows another variable further in the script.
Local means that the vairable is defined within a function.

[...]

But, let's continue. If a variable is shadowing another variable, it means that it is defining a variable which is already defined. A simple example of this would be:
pawn Код:
OnPlayerConnect(playerid){
   new something;
   //some random lines
   new something;
   return 1;
}
The variable is defined twice, which causes the warning.


In your case, I think you've defined "str" somewhere in your own script. You can fix the warning by opening your script, look for something along the lines of "new str;" or "new str[some number here];", and change "str" into something else.
Not necessarily.

I'm positive this code would generate the same warning:
pawn Код:
new str[128];

main()
{
}

public OnPlayerConnect(playerid)
{
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    new str[128]; // <- warning
    format(str, sizeof(str), "Hey, %s!", PlayerName);
    SendClientMessage(playerid, 0xFFFFFFFF, str);
    return true;
}
And renaming is perhaps not the best solution. I'm not familiar with the YSI framework but I can make assumptions str is used there. Switching to use global strings only would be a good call.
Reply


Messages In This Thread
Why I get those warning? :S - by KosmasRego - 21.11.2011, 12:33
Re: Why I get those warning? :S - by THE_KNOWN - 21.11.2011, 12:37
Re: Why I get those warning? :S - by Richie - 21.11.2011, 12:38
Re: Why I get those warning? :S - by KosmasRego - 21.11.2011, 12:40
Re: Why I get those warning? :S - by sleepysnowflake - 21.11.2011, 12:44
Re: Why I get those warning? :S - by KosmasRego - 21.11.2011, 12:46
Re: Why I get those warning? :S - by AndreT - 21.11.2011, 12:46
Re: Why I get those warning? :S - by KosmasRego - 21.11.2011, 12:54
Re: Why I get those warning? :S - by Infinity - 21.11.2011, 12:54
Re: Why I get those warning? :S - by AndreT - 21.11.2011, 12:57

Forum Jump:


Users browsing this thread: 3 Guest(s)