21.06.2014, 22:23
Creating the house is done by using "INSERT INTO" function:
Since INSERT INTO already auto increments the ID.
pawn Код:
CMD:createhouse(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 3)
{
new Float:X, Float:Y, Float:Z, Float:X2, Float:Y2, Float:Z2, price, interior;
GetPlayerPos(playerid, X2, Y2, Z2);
if(sscanf(params, "fffdd", X, Y, Z, interior, price)) return SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" /createhouse [IntX] [IntY] [IntZ] [InteriorID] [Price]");
format(query, sizeof(query), "INSERT INTO `houses` (IntX, IntY, IntZ, ExtX, ExtY, ExtZ, Price, Interior) VALUES ('%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d')", X, Y, Z, X2, Y2, Z2, price, interior);
mysql_query(sqldb, query);
SendClientMessage(playerid, COLOR_GREEN, "Houses has been created and inserted into the database.");
}
return true;
}