07.07.2013, 20:38
Well, it should work like it does to everyone else! It stores the number of rows from everything to the table houses and adds +1, so that would be basically the next ID.
I'd use that like that and it'd work fine.
I'd use that like that and it'd work fine.
pawn Код:
stock CreatePlayerHouse(playerid, sellprice, HouseLvl)
{
new Float:X, Float:Y, Float:Z; GetPlayerPos(playerid, X, Y, Z);
new ID, Query[256], DBResult: result;
format(Query, sizeof(Query), "SELECT * FROM HOUSES");
result = db_query(Database, Query);
ID = db_num_rows(result) + 1;
db_free_result(result);
format(Query, sizeof(Query), "INSERT INTO HOUSES (ID) VALUES(%d)", ID);
db_query(Database, Query);
format(Query, sizeof(Query), "UPDATE HOUSES SET NAME = 'Grad', FOR_SELL = 1, SELL_PRICE = %d, RENTPRICE = 1000, HOUSE_LEVEL = %d, X = %f, Y = %f, Z = %f WHERE ID = %d", sellprice, HouseLvl, X, Y, Z, ID);
db_query(Database, Query);
SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: House has been Successfully created.");
//LoadPlayerHouse(ID);
return true;
}

