array sizes do not match, or destination array is too small -
ATomas - 05.05.2016
Hi,
i have little problem with array inicialization
Код:
#include <a_samp>
new Neco[10] = {0,...};//work fine
public OnFilterScriptInit()
{
Neco = {0,0,0,0,0,0,0,0,0,0};//work fine too, but its hard way
Neco = {0,...};//error, how to write this ?
return 1;
}
C:\Users\A\Desktop\samp037\filterscripts\test.pwn(

: error 029: invalid expression, assumed zero
C:\Users\A\Desktop\samp037\filterscripts\test.pwn(

: error 047: array sizes do not match, or destination array is too small
I don't want to use for, while, do or anything like this.
Thanks for any help.
Re: array sizes do not match, or destination array is too small -
Konstantinos - 05.05.2016
Initialization is done on declaring only which the values are set to 0 by default anyway. For resetting, a loop would be what you need but you don't seem to want to do it for whatever reasons.
You can use memcpy instead:
pawn Код:
new tmp[sizeof Neco];
memcpy(Neco, tmp, 0, sizeof tmp * 4, sizeof Neco);
Re: array sizes do not match, or destination array is too small -
ATomas - 05.05.2016
Thanks for tip, but this
Код:
Neco = {0,0,0,0,0,0,0,0,0,0};
is still faster then
Код:
memcpy(Neco, tmp, 0, sizeof tmp * 4, sizeof Neco);
I looking for a very fast method
Re: array sizes do not match, or destination array is too small -
Dayrion - 05.05.2016
This way ?
PHP код:
new Neco[10] = {0,...};//work fine
public OnFilterScriptInit()
{
Neco = {0,0,0,0,0,0,0,0,0,0};//work fine too, but its hard way
Neco[10] = {0,...};//Like this?
return 1;
}
I tried and there is no error message.
Re: array sizes do not match, or destination array is too small -
ATomas - 05.05.2016
Quote:
Originally Posted by Dayrion
This way ?
PHP код:
new Neco[10] = {0,...};//work fine
public OnFilterScriptInit()
{
Neco = {0,0,0,0,0,0,0,0,0,0};//work fine too, but its hard way
Neco[10] = {0,...};//Like this?
return 1;
}
I tried and there is no error message.
|
Something like that, bud error message is
C:\Users\A\Desktop\samp037\filterscripts\test.pwn(

: error 032: array index out of bounds (variable "Neco")
C:\Users\A\Desktop\samp037\filterscripts\test.pwn(

: error 006: must be assigned to an array
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Re: array sizes do not match, or destination array is too small -
Nero_3D - 05.05.2016
PHP код:
new Neco[10] = {0,...};//work fine
new dNeco[sizeof Neco];
public OnFilterScriptInit()
{
Neco = dNeco;
}
Re: array sizes do not match, or destination array is too small -
ATomas - 05.05.2016
Quote:
Originally Posted by Nero_3D
PHP код:
new Neco[10] = {0,...};//work fine
new dNeco[sizeof Neco];
public OnFilterScriptInit()
{
Neco = dNeco;
}
|
Its good idea.
Why
Neco = {0,...};
work only in 'new' and not work in code ?
Re: array sizes do not match, or destination array is too small -
Dayrion - 05.05.2016
Quote:
Originally Posted by ATomas
Something like that, bud error message is
C:\Users\A\Desktop\samp037\filterscripts\test.pwn(  : error 032: array index out of bounds (variable "Neco")
C:\Users\A\Desktop\samp037\filterscripts\test.pwn(  : error 006: must be assigned to an array
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
|
I get no error...
EDIT : I got those errors on my main GM.