House system problem
#1

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:
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;
}
Also I will post my function which is checking if mysql have free slot:
pawn Код:
stock GetHouseFreeSlot()
{
    for(new i = 0; i < MAX_HOUSES; i++)
    {
        if(hInfo[i][hID] == INVALID_HOUSE_ID) return i;
    }
    return -1;
}
Reply


Messages In This Thread
House system problem - by Sanady - 11.03.2016, 11:19
Re: House system problem - by dominik523 - 11.03.2016, 11:30
Re: House system problem - by Sanady - 11.03.2016, 11:39
Re: House system problem - by dominik523 - 11.03.2016, 11:42
Re: House system problem - by Sanady - 11.03.2016, 11:45
Re: House system problem - by Runn3R - 11.03.2016, 11:53
Re: House system problem - by dominik523 - 11.03.2016, 11:53
Re: House system problem - by Sanady - 11.03.2016, 12:54
Re: House system problem - by Runn3R - 11.03.2016, 13:00
Re: House system problem - by Sanady - 11.03.2016, 13:08

Forum Jump:


Users browsing this thread: 1 Guest(s)