pawn Код:
#include <a_samp>
#define COLOR_BLUE 0x2641FEAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
enum hInfo
{
Float:hEntranceX,
Float:hEntranceY,
Float:hEntranceZ,
Float:hEntranceA,
Float:hExitX,
Float:hExitY,
Float:hExitZ,
Float:hExitA,
hOwner[MAX_PLAYER_NAME],
hDescription[MAX_PLAYER_NAME],
hValue,
hRevenue,
hHel,
hArm,
//
nInt,
//
hInt,
hWorld,
hLock,
hOwned,
hRooms,
hRent,
hRentable,
hPickup,
//
hSellprice,
};
new HouseInfo[1000][hInfo];
stock LoadHouse()
{
new arrCoords[24][64];
new szFileStr[1024],
File: file = fopen("houses.cfg", io_read);
if(file)
{
new idx;
while(idx < sizeof(HouseInfo) && fread(file, szFileStr))
{
sscanf(szFileStr, "p<,>ffffffffs[126]s[126]dddddddddddddd");
HouseInfo[idx][hEntranceX] = floatstr(arrCoords[0]);
HouseInfo[idx][hEntranceY] = floatstr(arrCoords[1]);
HouseInfo[idx][hEntranceZ] = floatstr(arrCoords[2]);
HouseInfo[idx][hEntranceA] = floatstr(arrCoords[3]);
HouseInfo[idx][hExitX] = floatstr(arrCoords[4]);
HouseInfo[idx][hExitY] = floatstr(arrCoords[5]);
HouseInfo[idx][hExitZ] = floatstr(arrCoords[6]);
HouseInfo[idx][hExitA] = floatstr(arrCoords[7]);
strmid(HouseInfo[idx][hOwner], arrCoords[8], 0, strlen(arrCoords[8]), 255);
strmid(HouseInfo[idx][hDescription], arrCoords[9], 0, strlen(arrCoords[9]), 255);
HouseInfo[idx][hValue] = strval(arrCoords[10]);
HouseInfo[idx][hRevenue] = strval(arrCoords[11]);
HouseInfo[idx][hHel] = strval(arrCoords[12]);
HouseInfo[idx][hArm] = strval(arrCoords[13]);
HouseInfo[idx][nInt] = strval(arrCoords[14]);
HouseInfo[idx][hInt] = strval(arrCoords[15]);
HouseInfo[idx][hWorld] = strval(arrCoords[16]);
HouseInfo[idx][hLock] = strval(arrCoords[17]);
HouseInfo[idx][hOwned] = strval(arrCoords[18]);
HouseInfo[idx][hRooms] = strval(arrCoords[19]);
HouseInfo[idx][hRent] = strval(arrCoords[20]);
HouseInfo[idx][hRentable] = strval(arrCoords[21]);
HouseInfo[idx][hPickup] = strval(arrCoords[22]);
HouseInfo[idx][hSellprice] = strval(arrCoords[23]);
idx++;
}
for(new h = 0; h < sizeof(HouseInfo); h++)
{
if(HouseInfo[h][hOwned] == 0)
{
new string[126];
format(string, sizeof(string), "Home For Sale \n Price: %d \n Type [/enter] To Go Inside", HouseInfo[h][hValue]);
Create3DTextLabel(string, COLOR_RED, HouseInfo[h][hEntranceX], HouseInfo[h][hEntranceY], HouseInfo[h][hEntranceZ], 10, 0);
HouseInfo[h][hPickup] = CreatePickup(1273,1,HouseInfo[h][hEntranceX],HouseInfo[h][hEntranceY],HouseInfo[h][hEntranceZ],0);
}
if(HouseInfo[h][hOwned] == 1)
{
new string[126];
format(string, sizeof(string), "Home Owner: %s \n Locked: %d \n Type [/enter] To Go Inside", HouseInfo[h][hOwner], HouseInfo[h][hLock]);
Create3DTextLabel(string, COLOR_GREEN, HouseInfo[h][hEntranceX], HouseInfo[h][hEntranceY], HouseInfo[h][hEntranceZ], 10, 0);
HouseInfo[h][hPickup] = CreatePickup(1239,1,HouseInfo[h][hEntranceX],HouseInfo[h][hEntranceY],HouseInfo[h][hEntranceZ],0);
}
}
print(" ");
print("Dynamic Houses");
print("---------------");
fclose(file);
}
return 1;
}
stock SaveHouse()
{
new idx;
new File: file2;
while (idx < sizeof(HouseInfo))
{
new coordsstring[128];
format(coordsstring, sizeof(coordsstring), "%f,%f,%f,%f,%f,%f,%f,%f,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
HouseInfo[idx][hEntranceX],
HouseInfo[idx][hEntranceY],
HouseInfo[idx][hEntranceZ],
HouseInfo[idx][hEntranceA],
HouseInfo[idx][hExitX],
HouseInfo[idx][hExitY],
HouseInfo[idx][hExitZ],
HouseInfo[idx][hExitA],
HouseInfo[idx][hOwner],
HouseInfo[idx][hDescription],
HouseInfo[idx][hValue],
HouseInfo[idx][hRevenue],
HouseInfo[idx][hHel],
HouseInfo[idx][hArm],
//
HouseInfo[idx][nInt],
//
HouseInfo[idx][hInt],
HouseInfo[idx][hWorld],
HouseInfo[idx][hLock],
HouseInfo[idx][hOwned],
HouseInfo[idx][hRooms],
HouseInfo[idx][hRent],
HouseInfo[idx][hRentable],
HouseInfo[idx][hPickup],
//
HouseInfo[idx][hSellprice]);
if(idx == 0)
{
file2 = fopen("houses.cfg", io_write);
}
else
{
file2 = fopen("houses.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
The problem with that is, it doesn't load example one house string and then makes it work, it spawns the max houses, whether they are in "houses.cfg" or not and spawns them, how can I make it work, please help!