16.03.2016, 13:35
Update.
The create
As you see i got them both... But it's creating but not updating
PHP код:
stock SaveHouse(houseid)
{
new query[2000];
format(query, sizeof(query), "UPDATE `Houses` SET `hInteriorID` = %d, `hInteriorX` = '%f', `hInteriorY` = '%f', `hInteriorZ` = '%f', `hInteriorA` = '%f', `hExteriorID` = %d, `hExteriorX` = '%f', `hExteriorY` = '%f', `hExteriorZ` = '%f', `hExteriorA` = '%f', `hSpawnID` = %d, `hSpawnX` = '%f', `hSpawnY` = '%f', `hSpawnZ` = '%f', `hSpawnA` = '%f', ",
Houses[houseid][hInteriorID],
Houses[houseid][hInteriorX],
Houses[houseid][hInteriorY],
Houses[houseid][hInteriorZ],
Houses[houseid][hInteriorA],
Houses[houseid][hExteriorID],
Houses[houseid][hExteriorX],
Houses[houseid][hExteriorY],
Houses[houseid][hExteriorZ],
Houses[houseid][hExteriorA],
Houses[houseid][hSpawnID],
Houses[houseid][hSpawnX],
Houses[houseid][hSpawnY],
Houses[houseid][hSpawnZ],
Houses[houseid][hSpawnA]);
format(query, sizeof(query), "%s`hOwner` = '%s', `hAddress` = '%s', `HousePrice` = %d, `hLockStatus` = %d, `hType` = '%s', `hLastLoginDate` = %d WHERE `HouseID` = %d",
query,
Houses[houseid][hOwner],
Houses[houseid][hAddress],
Houses[houseid][HousePrice],
Houses[houseid][hLockStatus],
Houses[houseid][hType],
Houses[houseid][hLastLoginDate],
houseid);
mysql_query(query);
return 1;
}
PHP код:
forward SaveHouseCallback(houseid, playerid);
public SaveHouseCallback(houseid, playerid)
{
new
rows;
if(rows == 1)
{
//SendClientMessage(SavingVehiclePlayerID, RED, "This Vehicle already exists");
SendClientMessage(playerid, RED, "This House already exists!");
}
else if(rows == 0)
{
new query[2000];
format(query, sizeof(query), "INSERT INTO `Houses` (`hInteriorID`, `hInteriorX`, `hInteriorY`, `hInteriorZ`, `hInteriorA`, `hExteriorID`, `hExteriorX`, `hExteriorY`, `hExteriorZ`, `hExteriorA`, `hSpawnID`, ");
format(query, sizeof(query), "%s`hSpawnX`, `hSpawnY`, `hSpawnZ`, `hSpawnA`, `hOwner`, `hAddress`, `HousePrice`, `hLockStatus`, `hType`) VALUES ", query);
format(query, sizeof(query), "%s(%d, '%f', '%f', '%f', '%f', %d, '%f', '%f', '%f', '%f', %d, '%f', '%f', '%f', '%f', '%s', '%s', %d, %d, '%s')",
query, Houses[houseid][hInteriorID],
Houses[houseid][hInteriorX],
Houses[houseid][hInteriorY],
Houses[houseid][hInteriorZ],
Houses[houseid][hInteriorA],
Houses[houseid][hExteriorID],
Houses[houseid][hExteriorX],
Houses[houseid][hExteriorY],
Houses[houseid][hExteriorZ],
Houses[houseid][hExteriorA],
Houses[houseid][hSpawnID],
Houses[houseid][hSpawnX],
Houses[houseid][hSpawnY],
Houses[houseid][hSpawnZ],
Houses[houseid][hSpawnA],
Houses[houseid][hOwner],
Houses[houseid][hAddress],
-1,
1,
Houses[houseid][hType]);
mysql_queryM(query, "DefaultCallback");
new query2[400];
format(query2, sizeof(query2), "SELECT * FROM `Houses` WHERE `HouseID` = %d", houseid); // Selects all the information from the table
mysql_queryM(query2,"LoadHousesCallback", "d", houseid);
}
else
{
//SendClientMessage(SavingVehiclePlayerID, COLOR_WHITE, "There was a "#COL_EMB_RED"fatal error "#COL_EMB_WHITE"during registration! Please contact a developer.");
SendClientMessage(playerid, COLOR_WHITE, "There was a "#COL_EMB_RED"fatal error "#COL_EMB_WHITE"during registration! Please contact a developer.");
}
return 1;
}