Warning
#1

gamemodes\GameMode.pwn(21255) : warning 219: local variable "string" shadows a variable at a preceding level

Lines:
Код:
(The Warning Line)public LoginLog(string[])
{
	new entry[256];
	format(entry, sizeof(entry), "%s\n",string);
	new File:hFile;
	hFile = fopen("login.log", io_append);
	fwrite(hFile, entry);
	fclose(hFile);
}
Here is the forward
Код:
forward LoginLog(string[]);
If anyone know how can I fix it, please tell me in reply...
Reply
#2

Don't create globals named "string". Actually don't create globals at all unless they're absolutely necessary.
Reply
#3

So you want to tell me that it is not necessary to have string[] in public and in forward to save text into the log file?
Reply
#4

Quote:
Originally Posted by CarlosScripter
Посмотреть сообщение
So you want to tell me that it is not necessary to have string[] in public and in forward to save text into the log file?
he means use like "PLog[]" instead of "String[]" dont use string word

"Dont forget to not use the names same as functions or defined General Callback's names "
Reply
#5

No, I mean that there is a global variable called string (which is bad practice). The compiler is complaining that the parameter (that's what you call these things between brackets after a function's name) "string" has the same name as a variable defined on a preceding (higher) level. The only preceding (higher) level is the global scope, ergo a variable name "string" exists in the global scope. It's something like:
PHP код:
new string[128];

// probably 1000 lines of code

public LoginLog(string[])
{
    print(string);

Now the compiler can't tell which instance of "string" you're trying to display. The one in the local scope or the one in the global scope? And that is what it is complaining about.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)