Problem with a loop
#1

------
Reply
#2

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.

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);
}
Your query was wrong as well.
Reply
#3

Hmm I think I should get some sleep seriously haha.

Thanks lad +rep of course
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)