SA-MP Forums Archive
Warning 219 Help - 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)
+--- Thread: Warning 219 Help (/showthread.php?tid=452429)



Warning 219 Help - Sanady - 21.07.2013

Hello.In my register and login system shows some strange warnings.It`s warning 219.But really I don`t see any problem in lines 270 and 330 here is code from that lines....Warnings are about string."local variable "string" shadows a variable at a preceding level.
pawn Код:
public LoginUser(query[],playerid,AutoLogin,connectionHandle) // line 270

{ // is line 330



Re: Warning 219 Help - DobbysGamertag - 21.07.2013

it means you have it somewhere as
pawn Код:
new string[SIZE];
Twice,it could be defined as a global, or a local variable. Just change it where its needed.


Re: Warning 219 Help - MP2 - 21.07.2013

don't use generic names like that for variables. You end up polluting the namespace.

Quote:
Originally Posted by ******
Globals are ALWAYS allocated, no matter how often you use them. Locals have memory allocated on, and freed from, the stack as and when (and if) it's needed. What's more, using locals reduces the number of bugs caused by functions accessing the same variables and "pollutes" the global namespace less, making naming collisions less likely. If you really want to statically allocate all your arrays, use static locals rather than full globals.
Quote:
Originally Posted by ******
Locals are always better than globals (you can increase stack space if you need).



Re: Warning 219 Help - Sanady - 21.07.2013

Quote:
Originally Posted by MP2
Посмотреть сообщение
don't use generic names like that for variables. You end up polluting the namespace.
So I should use local variable for this? Right?


Re: Warning 219 Help - Sanady - 21.07.2013

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
it means you have it somewhere as
pawn Код:
new string[SIZE];
Twice,it could be defined as a global, or a local variable. Just change it where its needed.
I don`t have I try searching but nothing found please help me


Re: Warning 219 Help - PrinceKumar - 21.07.2013

it means you have already use new string so don't use it again find for new string in your script if it is under include but before gamemodeinit or fiterscriptinit so delete it
edit: and see line before 270 which have new string , i think there will be a mistake


Re: Warning 219 Help - Sanady - 21.07.2013

Quote:
Originally Posted by PrinceKumar
Посмотреть сообщение
it means you have already use new string so don't use it again find for new string in your script if it is under include but before gamemodeinit or fiterscriptinit so delete it
edit: and see line before 270 which have new string , i think there will be a mistake
Ohh my god.I have only one global variable for string.Search in my script but I didn`t find any " new string " .Problem is somewhere else...


Re: Warning 219 Help - PrinceKumar - 21.07.2013

then post your codes here to get the solution


Re: Warning 219 Help - Sanady - 21.07.2013

Quote:
Originally Posted by PrinceKumar
Посмотреть сообщение
then post your codes here to get the solution
Check top of topic please.


Re: Warning 219 Help - Scenario - 21.07.2013

"string" is probably defined in one of your includes.