ID not valid
#5

@TheToretto:

This is what the debug prints:

Quote:

[16:35:50] Garage is saved for id: 0

Which is not true since the garage ID is saved as ID 1 in database. I dont understand why it says 0.

This is the full /creategarage CMD:

pawn Код:
CMD:creategarage(playerid, params[])
{
    if(Player[playerid][AdminLevel] < 5) return 0;

    new id;

    new price, size;

    if(sscanf(params, "dd(0)", price, size))
    {
        SCM(playerid, COLOR_BELGREEN, "» [USAGE]: /creategarage [price] [size(default 0)]");
        return SCM(playerid, COLOR_BELGREEN, "» Size: 0 - Small Garage , 1 - Medium Garage, 2 - Big Garage.");
    }

    if((size < 0) || (size > 2)) return SCM(playerid, COLOR_ERROR, "» Size must be from 0 to 2.");
    if((price < 1) || (price > 999999)) return SCM(playerid, COLOR_ERROR, "» Invalid price.");
   
    new query[300];
    mysql_format(g_SQL, query, sizeof query, "INSERT INTO `garages` (`garagePrice`, `garageSize`) VALUES ('%d', '%d')", price, size);
    mysql_tquery(g_SQL, query, "OnGarageCreated", "d", id);

    GarageInfo[id][garageExists] = true;

    GetPlayerPos(playerid, GarageInfo[id][garagePos][0], GarageInfo[id][garagePos][1], GarageInfo[id][garagePos][2]);
    GetPlayerFacingAngle(playerid, GarageInfo[id][garagePos][3]);

    GarageInfo[id][garagePos][0] = GarageInfo[id][garagePos][0] + (1.5 * floatsin(-GarageInfo[id][garagePos][3], degrees));
    GarageInfo[id][garagePos][1] = GarageInfo[id][garagePos][1] + (1.5 * floatcos(-GarageInfo[id][garagePos][3], degrees));

    GarageInfo[id][garageVW] = GetPlayerVirtualWorld(playerid);

    GarageInfo[id][garagePrice] = price;
    GarageInfo[id][garageSize] = size;

    RefreshGarage(id);

    SCMEX(playerid, COLOR_YELLOW, "» You have successfully created a garage. ID: %d - Price: %s - Size: %d", id, formatInt(price), size);
   
    printf("Garage is saved for id: %d", id);

    if(id == -1) return SCM(playerid, COLOR_ERROR, "» The server has reached the limit for garages.");
    return 1;
}
pawn Код:
function OnGarageCreated(gid)
{
    if(gid == -1 || !GarageInfo[gid][garageExists]) return 0;

    GarageInfo[gid][garageID] = cache_insert_id();

    SaveGarage(gid);
    return 1;
}
And this is how i load garages when server starts (however the loading and saving part works, it also shows the correct garage ID on the label. Just when i create it shows wrong ID.

pawn Код:
function LoadGarages()
{
    for(new i, j = cache_num_rows(); i != j; i++)
    {
        if(i < MAX_GARAGES)
        {
                GarageInfo[i][garageExists] = true;

                cache_get_value_int(i, "garageID", GarageInfo[i][garageID]);

                cache_get_value_float(i, "garageX", GarageInfo[i][garagePos][0]);
                cache_get_value_float(i, "garageY", GarageInfo[i][garagePos][1]);
                cache_get_value_float(i, "garageZ", GarageInfo[i][garagePos][2]);
                cache_get_value_float(i, "garageA", GarageInfo[i][garagePos][3]);

                cache_get_value_int(i, "garageVW", GarageInfo[i][garageVW]);

                cache_get_value_int(i, "garageOwnerID", GarageInfo[i][garageOwnerID]);
                cache_get_value_int(i, "garageOwned", GarageInfo[i][garageOwned]);

                cache_get_value_int(i, "garagePrice", GarageInfo[i][garagePrice]);
                cache_get_value_int(i, "garagePlayerSellPrice", GarageInfo[i][garagePlayerSellPrice]);

                cache_get_value_int(i, "garageSize", GarageInfo[i][garageSize]);

                RefreshGarage(i);
        }
    }
    return 1;
}
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: 4 Guest(s)