sscanf2 Error when compiling script -
JonnyDeath - 01.01.2018
So I am trying to help someone on here by translating a script to english to have posted for others on here and when I compile the script now I cam getting this error for sscanf2:
Код:
C:\Users\Jon\Desktop\New folder (3)\GTA samp test server\pawno\include\sscanf2.inc(143) : warning 219: local variable "name" shadows a variable at a preceding level
C:\Users\Jon\Desktop\New folder (3)\GTA samp test server\pawno\include\sscanf2.inc(187) : warning 219: local variable "name" shadows a variable at a preceding level
C:\Users\Jon\Desktop\New folder (3)\GTA samp test server\pawno\include\sscanf2.inc(230) : warning 219: local variable "name" shadows a variable at a preceding level
C:\Users\Jon\Desktop\New folder (3)\GTA samp test server\pawno\include\sscanf2.inc(255) : warning 219: local variable "reason" shadows a variable at a preceding level
C:\Users\Jon\Desktop\New folder (3)\GTA samp test server\pawno\include\sscanf2.inc(336) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Jon\Desktop\New folder (3)\GTA samp test server\pawno\include\sscanf2.inc(396) : warning 219: local variable "string" shadows a variable at a preceding level
Lines 143, 187, 230 are:
Код:
name[MAX_PLAYER_NAME];
Line 255:
Код:
public OnPlayerDisconnect(playerid, reason)
Line 336, 396:
Код:
SSCANF:weapon(string[])
I don't know how to make them not shadow the other lines, if anyone would be kind enough to help me a bit, it'd be greatly appreciated. Thanks.
Re: sscanf2 Error when compiling script -
MEW273 - 01.01.2018
This error simply means that you have defined those variables twice, somewhere in your script preceding these lines those variables have all been defined, you cannot define the same variable twice.
You can try renaming this variables to something unique, or alternatively find where they are already defined and check whether or not you need them and if you can change their name.
It is likely that you have somewhere defined these variables as global variables, so you cannot re-define them anywhere again in your script (callbacks, functions, commands etc).
Re: sscanf2 Error when compiling script -
JonnyDeath - 01.01.2018
Hm, well I know there are multiple of these in the lines, but I don't know how exactly I can change up that variable to not be in there twice.
Код:
public OnFilterScriptInit()
{
new
143 name[MAX_PLAYER_NAME];
144
145 SSCANF_Init(GetMaxPlayers(), INVALID_PLAYER_ID, MAX_PLAYER_NAME);
146 SSCANF_gInit = true;
147
148 // Check if there are any players that aren't initialized.
149 for (new i = 0; i < MAX_PLAYERS; i ++)
150 {
151 if (IsPlayerConnected(i) && !SSCANF_IsConnected(i))
152 {
153 GetPlayerName(i, name, MAX_PLAYER_NAME);
154 SSCANF_Join(i, name, IsPlayerNPC(i));
155 }
156 }
Adding the line numbers in on this.
This is what the code is shadowing
Код:
public OnGameModeInit()
{
if (!SSCANF_gInit)
{
new
187 name[MAX_PLAYER_NAME];
188
189 SSCANF_Init(GetMaxPlayers(), INVALID_PLAYER_ID, MAX_PLAYER_NAME);
190 SSCANF_gInit = true;
191
192 // Check if there are any players that aren't initialized.
193 for (new i = 0; i < MAX_PLAYERS; i ++)
194 {
195 if (IsPlayerConnected(i) && !SSCANF_IsConnected(i))
196 {
197 GetPlayerName(i, name, MAX_PLAYER_NAME);
198 SSCANF_Join(i, name, IsPlayerNPC(i));
199 }
}
The main line here is MAX_PLAYER_NAME which I don't see anyway of changing that without causing anymore problems. I know for some variables you can change them slightly to insure no shadowing. But I'm not sure about this... I've tried changing the variable, and made sure to define the variables ( I think anyways) But still get the same error. I feel like I'm missing something....
Re: sscanf2 Error when compiling script -
MEW273 - 01.01.2018
In your gamemode or another filterscript, have you globally defined those variables name, reason or string?
Re: sscanf2 Error when compiling script -
RogueDrifter - 01.01.2018
Rename those declared variables (new) to some random like stringix instead of string and if you get any "ERROR UNDEFINED SYMBOL" go to that line and rename the used variable to the declared one you renamed. IE. Instead of:
PHP код:
new name[26];
public OnPlayerConnect(playerid)
{
new name[26];
GetPlayerName(playerid,name,26);
return 1;
}
Do this
PHP код:
new name[26];
public OnPlayerConnect(playerid)
{
new playername[26];//changed
GetPlayerName(playerid,playername,26);//changed
return 1;
}
Re: sscanf2 Error when compiling script -
rfr - 01.01.2018
there's already a variable with this name so use
Re: sscanf2 Error when compiling script -
Logic_ - 01.01.2018
Are you compiling sscanf2?
Re: sscanf2 Error when compiling script -
JonnyDeath - 01.01.2018
Quote:
Originally Posted by Logic_
Are you compiling sscanf2?
|
No, compiling the Script, and the error was within the sscanf2
<-- for you good sir smh. Lol