ID not valid
#25

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).

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;
}
Mysql log:

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'')

EDIT: Fixed by removing SaveGarage on /buygarage and adding:

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);
And in THREAD_SAVE_GARAGE i just added SaveGarage. Now everything works.
Reply


Messages In This Thread
ID not valid - by SymonClash - 22.02.2019, 10:19
Re: ID not valid - by CherryMond - 22.02.2019, 14:14
Re: ID not valid - by SymonClash - 22.02.2019, 14:17
Re: ID not valid - by TheToretto - 22.02.2019, 14:30
Re: ID not valid - by SymonClash - 22.02.2019, 14:38
Re: ID not valid - by TheToretto - 22.02.2019, 15:05
Re: ID not valid - by SymonClash - 22.02.2019, 19:06
Re: ID not valid - by TheToretto - 22.02.2019, 19:51
Re: ID not valid - by SymonClash - 22.02.2019, 20:39
Re: ID not valid - by TheToretto - 22.02.2019, 21:40
Re: ID not valid - by Pottus - 22.02.2019, 21:54
Re: ID not valid - by TheToretto - 22.02.2019, 22:12
Re: ID not valid - by Pottus - 22.02.2019, 22:58
Re: ID not valid - by SymonClash - 22.02.2019, 23:30
Re: ID not valid - by TheToretto - 23.02.2019, 09:36
Re: ID not valid - by SymonClash - 23.02.2019, 11:05
Re: ID not valid - by TheToretto - 23.02.2019, 12:23
Re: ID not valid - by SymonClash - 23.02.2019, 12:34
Re: ID not valid - by TheToretto - 23.02.2019, 13:46
Re: ID not valid - by SymonClash - 23.02.2019, 14:20
Re: ID not valid - by SymonClash - 24.02.2019, 19:09
Re: ID not valid - by JasonRiggs - 24.02.2019, 19:40
Re: ID not valid - by SymonClash - 24.02.2019, 21:06
Re: ID not valid - by JasonRiggs - 24.02.2019, 21:36
Re: ID not valid - by SymonClash - 25.02.2019, 13:05

Forum Jump:


Users browsing this thread: 1 Guest(s)