case DIALOG_BUYHOUSE:
{
new hid = GetHouseID(playerid);
new query[200];
if(!response) return SendClientMessage(playerid, -1, ""COL_RED"SERVER"COL_WHITE": You decided not to buy a house. The house sale got cancelled!");
if(strlen(inputtext) > 30) return SendClientMessage(playerid, -1, ""COL_RED"SERVER"COL_WHITE"You must set a name less than 30 characters!");
mysql_format(mysql,query,sizeof(query),"UPDATE `houses` SET `HName` = '%s' WHERE `hID` = %d",inputtext,HouseInfo[hid][hID]);
mysql_tquery(mysql,query);
inputtext[30] = HouseInfo[hid][HName];
BuyHouse(playerid);
}
function BuyHouse(playerid)
{
new query[400],label[150];
new houseid = GetHouseID(playerid);
HouseInfo[houseid][HOwned] = true;
mysql_format(mysql,query,sizeof(query), "UPDATE `houses` SET `HOwned` = 1",HouseInfo[houseid][HOwned]);
mysql_query(mysql, query);
mysql_format(mysql,query,sizeof(query),"UPDATE `houses` SET `HOwnerID`= (SELECT `ID` FROM `players` WHERE `Username` = '%s') WHERE `HID` = '%d'",Name[playerid],HouseInfo[houseid][hID]);
mysql_query(mysql,query);
format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE":%s\n"COL_GREEN"",HouseInfo[houseid][HName]);
UpdateDynamic3DTextLabelText(HouseInfo[houseid][H3D],COLOR_YELLOW,label);
return 1;
}
5:08:58] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE from `houses` SET `HName` = 'blah' WHERE `hID` = 0", callback: "(null)", format: "(null)"
[15:08:58] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[15:08:58] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'from `houses` SET `HName` = 'blah' WHERE `hID` = 0' at line 1
[15:08:58] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError
[15:08:58] [DEBUG] Calling callback "OnQueryError"..
stock GetHouseID(playerid)
{
for(new i=0; i<MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 1, HouseInfo[i][XExit], HouseInfo[i][YExit], HouseInfo[i][ZExit]))
{
return i;
}
else if(IsPlayerInRangeOfPoint(playerid, 1, HouseInfo[i][XEnt], HouseInfo[i][YEnt], HouseInfo[i][ZEnt]))
{
return i;
}
}
return INVALID_HOUSE_ID;
}
inputtext[30] = HouseInfo[hid][HName];
format(HouseInfo[hid][HName],sizeof(HouseInfo[hid][HName]),"%s",inputtext);
strcat((HouseInfo[hid][HName][0] = EOS, HouseInfo[hid][HName]), inputtext, /*length goes here*/);
Or
Code:
strcat((HouseInfo[hid][HName][0] = EOS, HouseInfo[hid][HName]), inputtext, /*length goes here*/); |
case DIALOG_BUYHOUSE:
{
new hid = GetHouseID(playerid);
new query[200];
if(!response) return SendClientMessage(playerid, -1, ""COL_RED"SERVER"COL_WHITE": You decided not to buy a house. The house sale got cancelled!");
if(strlen(inputtext) > 30) return SendClientMessage(playerid, -1, ""COL_RED"SERVER"COL_WHITE"You must set a name less than 30 characters!");
mysql_format(mysql,query,sizeof(query),"UPDATE `houses` SET `HName` = '%s' WHERE `hID` = %d",inputtext,HouseInfo[hid][hID]);
mysql_tquery(mysql,query,"BuyHouse","i",playerid);
format(HouseInfo[hid][HName],sizeof(HouseInfo[hid][HName]),"%s",inputtext);
}
}
return 1;
}
Yes that's how I meant it, did you test it?
What this format does is basically HName = inputtext now. EOS stands for End-Of-String, but I dont understand why he used that in his context, maybe he can explain it himself. |
mysql.pwn(7468) : error 001: expected token: "]", but found "-identifier-"
mysql.pwn(7468) : warning 215: expression has no effect
mysql.pwn(7468) : error 001: expected token: ";", but found "]"
mysql.pwn(7468) : error 029: invalid expression, assumed zero
mysql.pwn(7468) : fatal error 107: too many error messages on one line
case DIALOG_BUYHOUSE:
{
new hid = GetHouseID(playerid);
new query[200];
if(!response) return SendClientMessage(playerid, -1, ""COL_RED"SERVER"COL_WHITE": You decided not to buy a house. The house sale got cancelled!");
if(strlen(inputtext) > 30) return SendClientMessage(playerid, -1, ""COL_RED"SERVER"COL_WHITE"You must set a name less than 30 characters!");
mysql_format(mysql,query,sizeof(query),"UPDATE `houses` SET `HName` = '%s' WHERE `hID` = %d",inputtext,HouseInfo[hid][hID]);
mysql_tquery(mysql,query,"BuyHouse","i",playerid);
---> error format(HouseInfo[hid][HName],sizeof(HouseInfo[hid][HName]),"%s",inputtext);
}
Seems to be a problem with sizeof(HouseInfo[hid][HName]). Replace it with 30, since you deny inputs longer than 30 characters anyway.
|
case DIALOG_BUYHOUSE:
{
new hid = GetHouseID(playerid);
new query[200];
if(!response) return SendClientMessage(playerid, -1, ""COL_RED"SERVER"COL_WHITE": You decided not to buy a house. The house sale got cancelled!");
if(strlen(inputtext) > 30) return SendClientMessage(playerid, -1, ""COL_RED"SERVER"COL_WHITE"You must set a name less than 30 characters!");
mysql_format(mysql,query,sizeof(query),"UPDATE `houses` SET `HName` = '%s' WHERE `hID` = %d",inputtext,HouseInfo[hid][hID]);
mysql_tquery(mysql,query,"BuyHouse","i",playerid);
format(HouseInfo[hid][HName],30,"%s",inputtext);
}