dini_Get
#1

Hi

I have this code:
pawn Код:
// ===== HOUSES
  for(new i = 0; i <= MAX_HOUSES; i++)
    {
        format(HouseFile, sizeof(HouseFile), hFile, i);
        HouseInfo[i][id]        = dini_Int(HouseFile,   "id");
        HouseInfo[i][x]         = dini_Float(HouseFile, "x");
        HouseInfo[i][y]         = dini_Float(HouseFile, "y");
        HouseInfo[i][z]         = dini_Float(HouseFile, "z");
        HouseInfo[i][rot]       = dini_Float(HouseFile, "rot");
        HouseInfo[i][x_int]     = dini_Float(HouseFile, "x_int");
        HouseInfo[i][y_int]     = dini_Float(HouseFile, "y_int");
        HouseInfo[i][z_int]     = dini_Float(HouseFile, "z_int");
        HouseInfo[i][rot_int]   = dini_Float(HouseFile, "rot_int");
        HouseInfo[i][int_id]  = dini_Int(HouseFile,     "int_id");
        HouseInfo[i][carid]     = dini_Int(HouseFile,   "carid");
        HouseInfo[i][carmodel]  = dini_Int(HouseFile,   "carmodel");
        HouseInfo[i][car_x]     = dini_Float(HouseFile, "car_x");
        HouseInfo[i][car_y]     = dini_Float(HouseFile, "car_y");
        HouseInfo[i][car_z]     = dini_Float(HouseFile, "car_z");
        HouseInfo[i][car_rot]   = dini_Float(HouseFile, "car_rot");
        HouseInfo[i][carcol1]   = dini_Int(HouseFile,   "carcol1");
        HouseInfo[i][carcol2]   = dini_Int(HouseFile,   "carcol2");
        HouseInfo[i][owner]     = dini_Get(HouseFile,   "owner"); // <= Line with error
        HouseInfo[i][price]     = dini_Int(HouseFile,   "price");
      printf("LOADED: House %02i", i);
   
        HouseInfo[i][id] = CreatePickup(1239, 23, HouseInfo[i][x], HouseInfo[i][y], HouseInfo[i][z]);
        HouseInfo[i][carid] = CreateVehicle(HouseInfo[i][carmodel], HouseInfo[i][car_x], HouseInfo[i][car_y], HouseInfo[i][car_z], HouseInfo[i][car_rot], HouseInfo[i][carcol1], HouseInfo[i][carcol2], 3600);
  }
    return 1;
}
And this error:
Код:
D:\Documents and Settings\Vince\Mijn Documenten\SA-MP SERVER\gamemodes\rr.pwn(270) : error 047: array sizes do not match, or destination array is too small
How to fix?
Reply
#2

Is ''owner'' in enum defined as a string?
Reply
#3

Yeah

pawn Код:
owner[MAX_PLAYER_NAME],
EDIT:
Fixed it

pawn Код:
format(HouseInfo[i][owner], 24, dini_Get(HouseFile, "owner"));
Reply
#4

IT doesn't match because dini_Get returns a DINI_MAX_STRING not MAX_PLAYER_NAME
Reply
#5

Quote:
Originally Posted by Vince
Fixed it

pawn Код:
format(HouseInfo[i][owner], 24, dini_Get(HouseFile, "owner"));
Correct.

But secure:
pawn Код:
format(HouseInfo[i][owner], 24, "%s", dini_Get(HouseFile, "owner"));
Since sometimes % are in strings, so you should always use "%s" if you want to do that.

- Draco
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)