PDA

View Full Version : House system.


HY
28/01/2015, 05:37 PM
: error 047: array sizes do not match, or destination array is too small

- Enums:

enum cInfo
{
cPret,
cInterior,
cLocked,
cWorld,
cOwned,
cOwner[24],
cPick,
Text3D:cLabel,
Float:cX,
Float:cY,
Float:cZ
}

new CasaInfo[MAX_CASE][cInfo];

- Stock:

stock LoadCase()
{
new file[50], labelstring[144], stringlabel[144];
for(new i = 0; i < MAX_CASE; i++)
{
format(file, sizeof(file), "Case/%d.ini", i);
if(fexist(file))
{
CasaInfo[i][cPret] = dini_Int(file, "Pret");
CasaInfo[i][cInterior] = dini_Int(file, "Interior");
CasaInfo[i][cOwned] = dini_Int(file, "Cumparata");
CasaInfo[i][cWorld] = dini_Int(file, "World");
CasaInfo[i][cOwner] = dini_Get(file, "Owner");
CasaInfo[i][cX] = dini_Float(file, "Pozitie X");
CasaInfo[i][cY] = dini_Float(file, "Pozitie Y");
CasaInfo[i][cZ] = dini_Float(file, "Pozitie Z");
format(labelstring, sizeof(labelstring), "{15FF00}Casă ID: {FFFFFF}%d\n{15FF00}Pret: {FFFFFF}%i\n\n{15FF00}Scrie {FFFFFF}/Cumpara {15FF00}pentru a cumpara casa.", i, CasaInfo[i][cPret]);
format(stringlabel, sizeof(stringlabel), "{15FF00}Casă ID: {FFFFFF}%d\n{15FF00}Proprietar: {FFFFFF}%s", i, CasaInfo[i][cPret], CasaInfo[casaid][cOwner]);
if(CasaInfo[i][cOwned] == 0)
{
CasaInfo[i][cPick] = CreatePickup(1273, 1, CasaInfo[i][cX], CasaInfo[i][cY], CasaInfo[i][cZ], CasaInfo[i][cWorld]);
CasaInfo[i][cLabel] = Create3DTextLabel(labelstring, 0xFFFFFFFF, CasaInfo[i][cX], CasaInfo[i][cY], CasaInfo[i][cZ], 25.0, 0, 0);
}
else if(CasaInfo[i][cOwned] == 1)
{
CasaInfo[i][cPick] = CreatePickup(1272, 1, CasaInfo[i][cX], CasaInfo[i][cY], CasaInfo[i][cZ], CasaInfo[i][cWorld]);
CasaInfo[i][cLabel] = Create3DTextLabel(stringlabel, 0xFFFFFFFF, CasaInfo[i][cX], CasaInfo[i][cY], CasaInfo[i][cZ], 25.0, 0, 0);
}
casaid++;
}
}
printf("LOADED CASE: %d", casaid);
return 1;
}

- Creating file:

new Float:X, Float:Y, Float:Z, file[50], string[128], labelstring[144], World;
World = GetPlayerVirtualWorld(playerid);
GetPlayerPos(playerid, X, Y, Z);
CasaInfo[casaid][cInterior] = strval(inputtext);
CasaInfo[casaid][cOwned] = 0;
CasaInfo[casaid][cWorld] = World;
CasaInfo[casaid][cX] = X;
CasaInfo[casaid][cY] = Y;
CasaInfo[casaid][cZ] = Z;
format(file, sizeof(file), "Case/%d.ini", casaid);
if(!fexist(file))
{
dini_Create(file);
dini_IntSet(file, "Pret", CasaInfo[casaid][cPret]);
dini_IntSet(file, "Interior", CasaInfo[casaid][cInterior]);
dini_IntSet(file, "Cumparata", CasaInfo[casaid][cOwned]);
dini_IntSet(file, "World", CasaInfo[casaid][cWorld]);
dini_Set(file, "Owner", CasaInfo[casaid][cOwner]);
dini_FloatSet(file, "Pozitie X", X);
dini_FloatSet(file, "Pozitie Y", Y);
dini_FloatSet(file, "Pozitie Z", Z);
}
format(labelstring, sizeof(labelstring), "{15FF00}Casă ID: {FFFFFF}%d\n{15FF00}Pret: {FFFFFF}%i\n\n{15FF00}Scrie {FFFFFF}/Cumpara {15FF00}pentru a cumpara casa.", casaid, CasaInfo[casaid][cPret]);
CasaInfo[casaid][cPick] = CreatePickup(1273, 1, X, Y, Z, World);
CasaInfo[casaid][cLabel] = Create3DTextLabel(labelstring, 0xFFFFFFFF, X, Y, Z, 25.0, 0, 0);
format(string, sizeof(string), "{FF0000}[CASA]: {FFFFFF}Casă: {FF0000}%d {FFFFFF}creata.", casaid);
SendClientMessage(playerid, -1, string);
casaid++;

This error appear only when I add this:

CasaInfo[i][cOwner] = dini_Get(file, "Owner");

under LoadCase(); (in english LoadHouses();) function.

Sorry for bad identitation.

+Rep for helper. :)

GGW
28/01/2015, 05:48 PM
replace it with this:

strmid(CasaInfo[i][cOwner], dini_Get(file, "OWNER"), false, strlen(dini_Get(file, "OWNER")), MAX_PLAYER_NAME);