25.02.2019, 13:05
Ok forget my last post. Managed to fix garage creation. Now they start with ID 1, IG and in table are saved correctly.
There is a problem now, with the /buygarage command, it doesn't want update new owner ID (associated with Player[playerid][ID]), because it saves the new garage ownership info on ID 0. (This fuckin' ID 0 is a nightmare).
Mysql log:
EDIT: Fixed by removing SaveGarage on /buygarage and adding:
And in THREAD_SAVE_GARAGE i just added SaveGarage. Now everything works.
There is a problem now, with the /buygarage command, it doesn't want update new owner ID (associated with Player[playerid][ID]), because it saves the new garage ownership info on ID 0. (This fuckin' ID 0 is a nightmare).
pawn Код:
CMD:buygarage(playerid, params[])
{
new id = GetNearestGarage(playerid);
if(id == -1) return SCM(playerid, COLOR_ERROR, "» There are no garages near you.");
if(GarageInfo[id][garageOwnerID] == Player[playerid][ID]) return SCM(playerid, COLOR_ERROR, "» This garage is already yours.");
if(GarageInfo[id][garageOwned]) return SCM(playerid, COLOR_ERROR, "» This garage has been already bought.");
if(GetPlayerMoney(playerid) < GarageInfo[id][garagePrice])
return SCMEX(playerid, COLOR_ERROR, "» You can't afford to buy this garage. You need %s.", formatInt(GarageInfo[id][garagePrice]));
SCMEX(playerid, COLOR_YELLOW, "» [GARAGE] You've bought this garage for %s!", formatInt(GarageInfo[id][garagePrice]));
SCM(playerid, COLOR_YELLOW, "» [GARAGE] Garage keys and ownership have been transferred to you.");
GivePlayerMoney(playerid, -GarageInfo[id][garagePrice]);
GarageInfo[id][garageOwned] = 1;
GarageInfo[id][garagePrice] = 0;
GarageInfo[id][garagePlayerSellPrice] = 0;
GarageInfo[id][garageOwnerID] = Player[playerid][ID];
RefreshGarage(id);
SaveGarage(id);
GameTextForPlayer(playerid, "~w~Garage ~g~bought~w~!", 3000, 3);
return 1;
}
Quote:
[15:01:59] [DEBUG] mysql_query(1, "UPDATE `garages` SET `garageOwnerID` = '1', `garageOwned` = '1', `garagePrice` = '0', `garagePlayerSellPrice` = '0', `garageSize` = '2', `garageCustomName` = 'e' WHERE `garageID` = '0'", 1) (C:\test\gamemodes\server.pwn:2602 -> C:\test\gamemodes\server.pwn:6480) [15:01:59] [DEBUG] CHandle::Execute(this=0x23df80, type=3, query=0x2a932 [15:01:59] [DEBUG] CConnection::Execute(query=0x2a9328, this=0x23f4d8, connection=0x2007f0) [15:01:59] [DEBUG] CQuery::Execute(this=0x2a9328, connection=0x2007f0) [15:01:59] [INFO] query "UPDATE `garages` SET `garageOwnerID` = '1', `garageOwned` = '1', `garagePrice` = '0', `garagePlayerSellPrice` = '0', `garageSize` = '2', `garageCustomName` = 'e' WHERE `garageID` = '0'" successfully executed within 0.800 milliseconds [15:01:59] [DEBUG] CResultSet::Create(connection=0x2007f0, query_str='UPDATE `garages` SET `garageOwnerID` = '1', `garageOwned` = '1', `garagePrice` = '0', `garagePlayerSellPrice` = '0', `garageSize` = '2', `garageCustomName` = 'e' WHERE `garageID` = '0'') |
pawn Код:
new query[300];
mysql_format(g_SQL, query, sizeof query, "UPDATE `garages` SET `garageOwned` = 1, `garagePrice` = 0, `garagePlayerSellPrice` = 0, `garageOwnerID` = '%d'",
Player[playerid][ID]);
mysql_tquery(g_SQL, query, "OnQueryFinished", "dd", id, THREAD_SAVE_GARAGE);