26.07.2016, 12:47
Hello everyone, I've made houses system, it's based on a MySQL table. It loads the house and everything is going well, so my problem is in /createhouse. The command (/createhouse) inserts a new row on the mysql database, but I have to restart the server to load the new house, and this is a really bad idea to restart the server whenever I want to make a new house. Also, I don't want to reload ALL houses whenever I create a house, because if a player is in a house and the houses get reloaded, he'll get fucked.
So, how to get the ID of the house that I made using /createhouse (from the mysql table)? Help fast please.
My /createhouse command:
CreateHouse function:
So, how to get the ID of the house that I made using /createhouse (from the mysql table)? Help fast please.
My /createhouse command:
PHP код:
CMD:createhouse(playerid, params[])
{
if(!IsAdminLevel(playerid, 5)) return NoPermsMSG(playerid);
new price;
if(sscanf(params, "i", price)) return SendUsageMSG(playerid, "/createhouse [PRICE]");
if(price < 666) return SendErrorMSG(playerid, "Invalid house price.");
new Float:X, Float:Y, Float:Z, string[128];
GetPlayerPos(playerid, X, Y, Z);
CreateHouse(price, X, Y, Z);
SendAdminMSG(playerid, "You have created a new house.");
format(string, sizeof(string), "%s(%d) has created a new house.", PlayerName(playerid), playerid);
SendALogMSG(string);
return 1;
}
PHP код:
stock CreateHouse(price, Float:x, Float:y, Float:z)
{
new query[128];
mysql_format(mysql, query, sizeof(query), "INSERT INTO `houses` (`EnterX`, `EnterY`, `EnterZ`, `Price`) VALUES ('%f', '%f', '%f', '%d')", x, y, z, price);
mysql_tquery(mysql, query, "", "");
}