05.07.2018, 08:02
Hello, I made this command.. but when i buy a house, and try to buy another, it says this house is already owned, but it isn't.. also, the label isn't updating, and the Owner isn't being updated in MySQL
and MySQL LOGS
Thanks in advance
Код:
CMD:buy(playerid,params[]) { for(new i = 0; i < MAX_HOUSES;i++)//Loop threw all houses. { if(!IsPlayerInRangeOfPoint(playerid,8.0,hInfo[i][HouseEX],hInfo[i][HouseEY],hInfo[i][HouseEZ])) continue;//Check if the player is near a house checkpoint //if(GetPlayerMoney(playerid) < HInfo[i][Price]) return SendClientMessage(playerid,-1,"You don't have enough money");//Checking the players money, to see if he has enough to buy the house. if(hInfo[i][HouseOwned] == 1) return SendClientMessage(playerid,-1,"This house is already owned");//Checking if the house is already owned. hInfo[i][HouseOwned] = 1;//Setting the house owned var to 1. new hName[24],string[145], query[100];//Creating the necessary vars. GetPlayerName(playerid,hName,sizeof(hName));//Retrieving the player's name. format(query, sizeof(query), "UPDATE * `houses` SET `HouseOwner` = '%s', `HouseOwned` = '1' WHERE `HouseEX` = '%f'", hName, hInfo[playerid][HouseEX]); mysql_tquery(dbHandle, query); format(string, 145, "{FFD700}House Title(%i): {FFFFFF}%s\n{FFD700}House Owner: {FFFFFF}%s\n {FFD700}House Price: {FFFFFF}$%d", hInfo[i][HouseID], hInfo[i][HouseTitle], hInfo[i][HousePrice]); Update3DTextLabelText(hInfo[i][HouseDetails],0xFF0000FF,string);//Updating the label with a red color GivePlayerMoney(playerid,-hInfo[i][HousePrice]); return 1; } SendClientMessage(playerid,-1,"You aren't near a house!"); return 1; }
Код:
[13:26:26] [ERROR] CMySQLQuery::Execute[] - (error #1062) Duplicate entry '1' for key 'PRIMARY' [13:26:36] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* `houses` SET `HouseOwner` = 'g__htc1', `HouseOwned` = '1' WHERE `HouseEX` = '-' at line 1