23.02.2019, 11:05
Sorry for double post, just tried now. While doing /creategarage i get this in console log:
However, the garage is created and it's ID 0 in database.
Is it normal?
EDIT: Just tried creating 3 garages, the first one with assigned ID 0 works. The last two garages have their X, Y and Z to 0 (so their position is not saved), and their XYZ too replaces the garage ID 0 XYZ, why?
EDIT 2: Edited /creategarage CMD and manage to make it work the position save.
Now there is yet a problem, the last created garage replaces automatically garage with ID 0 (by copying XYZ, price and size), but still gets created normally (and its ID gets assigned correctly).
Quote:
[13:04:22] sscanf warning: Format specifier does not match parameter count. |
Is it normal?
EDIT: Just tried creating 3 garages, the first one with assigned ID 0 works. The last two garages have their X, Y and Z to 0 (so their position is not saved), and their XYZ too replaces the garage ID 0 XYZ, why?
EDIT 2: Edited /creategarage CMD and manage to make it work the position save.
pawn Код:
CMD:creategarage(playerid, params[])
{
if(Player[playerid][AdminLevel] < 5) return 0;
if(Iter_Free(Garages) >= MAX_GARAGES) return SCM(playerid, COLOR_ERROR, "» Server has reached max garages limit.");
new id = Iter_Free(Garages);
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 Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
GarageInfo[id][garagePos][0] = X;
GarageInfo[id][garagePos][1] = Y;
GarageInfo[id][garagePos][2] = Z;
GarageInfo[id][garagePos][3] = A;
GarageInfo[id][garageVW] = GetPlayerVirtualWorld(playerid);
GarageInfo[id][garagePrice] = price;
GarageInfo[id][garageSize] = size;
Iter_Add(Garages, id);
new query[400];
mysql_format(g_SQL, query, sizeof query, "INSERT INTO `garages` (`garageID`, `garagePrice`, `garageSize`, `garageX`, `garageY`, `garageZ`, `garageA`) VALUES ('%d', '%d', '%d', '%.4f', '%.4f', '%.4f', '%.4f')",
id, price, size, X, Y, Z, A);
mysql_tquery(g_SQL, query, "OnGarageCreated", "d", 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);
return 1;
}