21.02.2019, 21:55
Hello, it's me again with my garage system, i don't know how to fix this. I debugged and reworked code for over 1 hour without fixing anything. Basically, with /creategarage command, the garage is created, their position saved and so on.
BUT, it doesn't store "price" and "size" in the table!
CreateGarage:
When i create a garage automatically a textlabel is created where it shows the price, and guess what? The price is correct! Only on DB table while creating doesn't insert nothing.
BUT, it doesn't store "price" and "size" in the table!
pawn Code:
CMD:creategarage(playerid, params[])
{
if(Player[playerid][AdminLevel] < 5) return 0;
new id;
new price, size;
if(sscanf(params, "iI(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.");
id = CreateGarage(playerid, price, size);
if(id == -1) return SCM(playerid, COLOR_ERROR, "» The server has reached the limit for garages.");
SCMEX(playerid, COLOR_YELLOW, "» You have successfully created a garage. ID: %d - Price: %d - Size: %d", id, price, size);
return 1;
}
pawn Code:
stock CreateGarage(playerid, price, size)
{
for(new i = 0; i != MAX_GARAGES; i ++) if(!GarageInfo[i][garageExists])
{
GarageInfo[i][garageExists] = true;
GetPlayerPos(playerid, GarageInfo[i][garagePos][0], GarageInfo[i][garagePos][1], GarageInfo[i][garagePos][2]);
GetPlayerFacingAngle(playerid, GarageInfo[i][garagePos][3]);
GarageInfo[i][garagePos][0] = GarageInfo[i][garagePos][0] + (1.5 * floatsin(-GarageInfo[i][garagePos][3], degrees));
GarageInfo[i][garagePos][1] = GarageInfo[i][garagePos][1] + (1.5 * floatcos(-GarageInfo[i][garagePos][3], degrees));
GarageInfo[i][garageVW] = GetPlayerVirtualWorld(playerid);
GarageInfo[i][garagePrice] = price;
GarageInfo[i][garageSize] = size;
RefreshGarage(i);
mysql_tquery(g_SQL, "INSERT INTO `garages` (`garageVW`) VALUES(0)", "OnGarageCreated", "d", i);
return 1;
}
return -1;
}
pawn Code:
function OnGarageCreated(gid)
{
if(gid == -1 || !GarageInfo[gid][garageExists]) return 0;
GarageInfo[gid][garageID] = cache_insert_id();
SaveGarage(gid);
return 1;
}