11.03.2016, 11:19
Hello SA-MP Forums, week before, I made a load and save system for house system which I want to use, I am using mySQL. But there is a problem like a always. When I want to create house with command, error shows up to me that there is not free slot in mySQL database. Here is command:
Also I will post my function which is checking if mysql have free slot:
pawn Код:
ADMCMD:createhouse(playerid, params[], 5)
{
new price, Query[500];
if(sscanf(params,"d", price)) return SendServer(playerid, "/createhouse [price]");
new houseid = GetHouseFreeSlot();
if(houseid == -1) return SendError(playerid, "There is no free slot on server for house at the moment. Please try again later.");
format(Query, sizeof(Query), "INSERT INTO `houses` SET `ID` = '%d', `PosX` = '%f', `PosY` = '%f', `PosZ` = '%f', `Price` = '%d', `Owner` = '-1'", houseid, hInfo[houseid][hPosX], hInfo[houseid][hPosY], hInfo[houseid][hPosZ], price);
mysql_query(Query);
hInfo[houseid][hID] = mysql_insert_id();
hInfo[houseid][hPrice] = price;
SendMessage(playerid, -1, embed_housecolor"[House - #%d] "embed_white"You have succssesfully created house!", houseid);
return 1;
}
pawn Код:
stock GetHouseFreeSlot()
{
for(new i = 0; i < MAX_HOUSES; i++)
{
if(hInfo[i][hID] == INVALID_HOUSE_ID) return i;
}
return -1;
}