07.12.2015, 02:37
Your for loop max value is MAX_HOUSES, simply change <= MAX_HOUSES to < MAX_HOUSES.
One more thing that has caught my attention, what if not all 255 houses are being used? You need to check if the house exists.
Your query was wrong as well.
One more thing that has caught my attention, what if not all 255 houses are being used? You need to check if the house exists.
pawn Код:
SaveAllHouses()
{
new HousesSaved = 0, query[600];
for(new i = 0; i < MAX_HOUSES; i++)
{
if(HouseInfo[i][HID] != 0)
{
mysql_format(mysql, query, sizeof(query), "UPDATE `houses` SET `Price` = %d, `EnterX` = %f ,`EnterY` = %f, `EnterZ` = %f, `ExitX` = %f, `ExitY` = %f, `ExitZ` = %f, `Owned` = %d, `Locked` = %d, `HouseBank` = %d WHERE `ID`= %d",\
HouseInfo[i][HousePrice],HouseInfo[i][EnterX],HouseInfo[i][EnterY],HouseInfo[i][EnterZ],HouseInfo[i][ExitX],HouseInfo[i][ExitY],HouseInfo[i][ExitZ],HouseInfo[i][Owned],HouseInfo[i][Locked],HouseInfo[i][HouseBank],HouseInfo[i][HID]);
mysql_pquery(mysql, query);
HousesSaved++;
}
}
printf("Total of %i houses saved",HousesSaved);
}