SA-MP Forums Archive
array sizes do not match, or destination array is too small - 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: array sizes do not match, or destination array is too small (/showthread.php?tid=653618)



array sizes do not match, or destination array is too small - Auri - 08.05.2018

hi, i need help with my code.

Код:
forward CreateActors(playerid, name[32], desc[128], skin, type, anim);
public CreateActors(playerid, name[32], desc[128], skin, type, anim)
{
	new uid;
	
	new Float:PosX, Float:PosY, Float:PosZ, Float:Angle;
	GetPlayerPos(playerid, PosX, PosY, PosZ);
	GetPlayerFacingAngle(playerid, Angle);
	
	ForeachEx(i, MAX_ACTORS)
	{
		if(ActorCache[i][aCUID] == 0 && i != 0)
		{
			uid = i;
			break;
		}
	}
	mysql_real_escape_string(name,name);
	new query[512];
	format(query, sizeof(query), "INSERT INTO `srv_actors` (`actor_uid`, `actor_name`, `actor_desc`, `actor_skin`, `actor_type`, `actor_posx`, `actor_posy`, `actor_posz`, `actor_posa`, `actor_vw`, `actor_int`, `actor_anim`) VALUES ('%d', '%s', '%s', '%d', '%d', '%f', '%f', '%f', '%f', '%d', '%d', '%d')", uid, name, desc, skin, type, anim, ActorCache[uid][aCPosX], ActorCache[uid][aCPosY], ActorCache[uid][aCPosZ], ActorCache[uid][aCPosA], ActorCache[uid][aCVW], ActorCache[uid][aCInt], ActorCache[uid][aCAnim]);
	mysql_query(query);
	
	ActorCache[uid][aCUID] = uid;
	ActorCache[uid][aCName] = name;
	ActorCache[uid][aCDesc] = desc;
	ActorCache[uid][aCSkin] = skin;
	ActorCache[uid][aCType] = type;
	ActorCache[uid][aCPosX] = PosX;
	ActorCache[uid][aCPosY] = PosY;
	ActorCache[uid][aCPosZ] = PosZ;
	ActorCache[uid][aCPosA] = Angle;
	ActorCache[uid][aCVW] = GetPlayerVirtualWorld(playerid);
	ActorCache[uid][aCInt] = GetPlayerInterior(playerid);
	ActorCache[uid][aCAnim] = anim;
	ActorCache[uid][aCNickColor] = COLOR_DO;

	
	return uid;
}
Error information

Код:
modules/actors.inc(19) : error 075: input line too long (after substitutions)
modules/actors.inc(25) : error 047: array sizes do not match, or destination array is too small
and

Line 19
Код:
new query[512];
Line 25

Код:
ActorCache[uid][aCDesc] = desc;
I need help because it's been boring for 2 hours


Re: array sizes do not match, or destination array is too small - TadePoleMG - 08.05.2018

Hi
FOR ERROR IN LINE 19 - Try to increasing your query length, if it does not work use then strcat to give some space to your lines because there is a limit.

FOR ERROR IN LINE 25 -error is in this -
PHP код:
forward CreateActors(playeridname[32], desc[128], skintypeanim);
public 
CreateActors(playeridname[32], desc[128], skintypeanim)

// Try that
forward CreateActors(playeridname[32], descskintypeanim);
public 
CreateActors(playeridname[32], descskintypeanim
You can save desc now as integer from above but if you want to save it as string(like desc[128]) then use format.

thank You.


Re: array sizes do not match, or destination array is too small - NaS - 08.05.2018

If you assign an Array to another Array directly, they must have the exact same size.

desc is 128 cells, how big is aCDesc?

If it is 128 cells too, it might be because it's an enum (I think this was fixed in ZeeX' Compiler Patches).

Otherwise use memcpy, format or strcat.


Re: array sizes do not match, or destination array is too small - kovac - 08.05.2018

PHP код:
forward CreateActors(playeridname[], desc[], skintypeanim);
public 
CreateActors(playeridname[], desc[], skintypeanim