SA-MP Forums Archive
forech - 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: forech (/showthread.php?tid=651428)



forech - Thanks - 20.03.2018

How to fix this warring?

Код:
warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
PHP код:
foreach(Houses, hid) 



Re: forech - kovac - 20.03.2018

Use this:

PHP код:
for(new hid = 0; hid < Houses; hid++)
{
  
// ...
} 



Re: forech - Thanks - 20.03.2018

Why they are given me this error? after put it?
Is there something wrong with your code?
PHP код:
error 017: undefined symbol "Houses" 
The code is

PHP код:
CMD:houseinfo(playerid, params[])
{
    for(new 
hid = 0; hid < Houses; hid++)
       { 



Re: forech - jasperschellekens - 20.03.2018

Quote:
Originally Posted by Thanks
Посмотреть сообщение
Why they are given me this error? after put it?
Is there something wrong with your code?
PHP код:
error 017: undefined symbol "Houses" 
The code is

PHP код:
CMD:houseinfo(playerid, params[])
{
    for(new 
hid = 0; hid < Houses; hid++)
       { 
Because houses does not exist.
use:
Код:
#define Houses 1000
Above will loop 1000 times


Re: forech - iKarim - 20.03.2018

Quote:
Originally Posted by kovac
Посмотреть сообщение
Use this:

PHP код:
for(new hid = 0; hid < Houses; hid++)
{
  
// ...
} 
Quote:
Originally Posted by jasperschellekens
Посмотреть сообщение
Because houses does not exist.
use:
Код:
#define Houses 1000
Above will loop 1000 times
No. That's completely wrong, iterator is not a number.


This is an old foreach syntax, you need to replace it with the newest one:

PHP код:
foreach(new hid : Houses) 



Re: forech - Thanks - 20.03.2018

Thanks @iKarim