06.10.2011, 15:16
Hi, I am currently making my own house system, everything is working correctly apart from the /buyhouse command.
I just don't know what to do, the query is selecting the correct house ID but it isn't actually sending any data to the database which is confusing.
pawn Код:
CMD:buyhouse(playerid, params[])
{
for(new i; i < houses; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 1.5, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]))
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(HouseInfo[i][hOwned] == 1) return SendClientMessage(playerid, COLOR_GREY, "ERROR: This house is already owned");
if(GetPlayerMoney(playerid) < HouseInfo[i][hPrice]) return SendClientMessage(playerid, COLOR_GREY, "ERROR: You don't seem to have enough cash.");
HouseInfo[i][hOwned] = 1;
HouseInfo[i][hOwner] = name;
GivePlayerMoney(playerid, GetPlayerMoney(playerid)-HouseInfo[i][hPrice]);
new string[128];
format(string, sizeof(string), "{FFFFFF}Owner: {009DFF}%s", name);
Update3DTextLabelText(HouseInfo[i][hLabel], COLOR_WHITE, string);
new query[256];
format(query, sizeof(query), "UPDATE `houses` SET `Owner` = '%s', `Owned` = `%d` WHERE `ID` = `%i`", HouseInfo[i][hOwner], HouseInfo[i][hOwned], i);
mysql_query(query);
mysql_store_result();
SendClientMessageToAll(COLOR_WHITE, query);
mysql_free_result();
}
}
return 1;
}