11.12.2013, 20:11
Hi,
I've got this strange bug that I can't seem to solve. Ill paste the code
I did create a table insise the database. When i type /createvehicle in game it will create it inside the db. But when i use it again it will repeat the same id over and over again and it doesnt create then. What am i doing wrong?
Typed from my iphone dident even bother fixing spelling mistakes haha
Thanks
I've got this strange bug that I can't seem to solve. Ill paste the code
PHP код:
enum VehicleStats
{
vID,
vModel,
Float:vPosition[4],
vOwner[24],
vColor1,
vColor2,
}
new Vehicle[MAX_VEHICLES][VehicleStats];
COMMAND:createvehicle(playerid, params[])
{
new vModelT, i, Float:posx, Float:posy, Float:posz, Float:posa, vColor1T, vColor2T, query[228], string[128];
if(sscanf(params, "ddd", vModelT, vColor1T, vColor2T)) return SendClientMessage(playerid, COLOR_GREY, "[Command] Usage: /createvehicle [ModelID] [Color1] [Color2]");
GetPlayerPos(playerid, posx, posy, posz);
GetPlayerFacingAngle(playerid, posa);
if(vModelT < 411 || vModelT > 611) return SendClientMessage(playerid, COLOR_GREY, "Model ID Must not be below 411 and not higher than 611");
i = mysql_insert_id();
format(query, sizeof(query), "INSERT INTO vehicles (VehicleID, VehicleModel, VehiclePosx, VehiclePosy, VehiclePosz, VehiclePosa, VehicleColor1, VehicleColor2) VALUES('%d', '%d', '%f', '%f', '%f', '%f', '%d', '%d'", i, vModelT, posx, posy, posz, posa, vColor1T, vColor2T);
mysql_query(query);
Vehicle[i][vID] = i;
Vehicle[i][vModel] = vModelT;
Vehicle[i][vPosition][0] = posx;
Vehicle[i][vPosition][1] = posy;
Vehicle[i][vPosition][2] = posz;
Vehicle[i][vPosition][3] = posa;
Vehicle[i][vColor1] = vColor1T;
Vehicle[i][vColor2] = vColor2T;
format(string, sizeof(string), "Vehicle Created! Vehicle ID : %d | Vehicle ModelID : %d | Vehicle Color1And2 : 5 | Vehicle PosX : %f | Vehicle PosY : %f | Vehicle PosZ : %f | Vehicle PosA : %f", i, vModelT, posx, posy, posz, posa);
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
Typed from my iphone dident even bother fixing spelling mistakes haha
Thanks