SA-MP Forums Archive
local variable "Pos" shadows a variable at a preceding level - 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: local variable "Pos" shadows a variable at a preceding level (/showthread.php?tid=635679)



local variable "Pos" shadows a variable at a preceding level - s3ek - 12.06.2017

http://forum.sa-mp.com/showpost.php?...2&postcount=52

pleas help


Re: local variable "Pos" shadows a variable at a preceding level - Toroi - 12.06.2017

Change the name of the variable?


Re: local variable "Pos" shadows a variable at a preceding level - s3ek - 12.06.2017

what value ?


Re: local variable "Pos" shadows a variable at a preceding level - Toroi - 12.06.2017

What value what?

Rename the variable

PHP код:
 new Float:Pos[3]; 
to
PHP код:
 new Float:fPos[3]; 
or whatever you want and make sure the rest of the code that involves that variable gets its name changed aswell, like the following code:
PHP код:
GetPlayerPos(playeridPos[0], Pos[1], Pos[2]); 
would be
PHP код:
GetPlayerPos(playeridfPos[0], fPos[1], fPos[2]); 



Re: local variable "Pos" shadows a variable at a preceding level - s3ek - 12.06.2017

Quote:
Originally Posted by Toroi
Посмотреть сообщение
What value what?

Rename the variable

PHP код:
 new Float:Pos[3]; 
to
PHP код:
 new Float:fPos[3]; 
or whatever you want and make sure the rest of the code that involves that variable gets its name changed aswell, like the following code:
PHP код:
GetPlayerPos(playeridPos[0], Pos[1], Pos[2]); 
would be
PHP код:
GetPlayerPos(playeridfPos[0], fPos[1], fPos[2]); 
ichange but probleme still .. now i change Pos to pos and thiis fixed!! thanx


Re: local variable "Pos" shadows a variable at a preceding level - Vince - 12.06.2017

Quote:
Originally Posted by Toroi
Посмотреть сообщение
What value what?

Rename the variable

PHP код:
 new Float:Pos[3]; 
to
PHP код:
 new Float:fPos[3]; 
or whatever you want and make sure the rest of the code that involves that variable gets its name changed aswell, like the following code:
PHP код:
GetPlayerPos(playeridPos[0], Pos[1], Pos[2]); 
would be
PHP код:
GetPlayerPos(playeridfPos[0], fPos[1], fPos[2]); 
This is really a bad workaround because it implies that there exists a global variable simply named "Pos", which is very bad practice.