House Problems - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: House Problems (
/showthread.php?tid=288131)
House Problems -
Luis- - 06.10.2011
Hi, I am currently making my own house system, everything is working correctly apart from the /buyhouse command.
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;
}
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.
Re: House Problems -
[NoV]LaZ - 06.10.2011
If you look carefully, you will notice there are some mistakes in your syntax. You should have ' instead of ` around your data. Also, it's not required to use ' around integers, use only for strings or float values.
Код:
UPDATE `houses` SET `Owner` = '%s', `Owned` = %d WHERE `ID` = %i