array sizes do not match, or destination array is too small
#1

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.
Reply
#2

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);
Reply
#3

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
Reply
#4

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.
Reply
#5

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.
Reply
#6

PHP код:
new Neco[10] = {0,...};//work fine
new dNeco[sizeof Neco];
public 
OnFilterScriptInit()
{
    
Neco dNeco;

Reply
#7

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 ?
Reply
#8

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)