25.08.2017, 15:00
I am trying to add a vehicle plate to cars, but it isn't working properly. It is saving 5 characters to 'carPlate' in the database, but it is also setting the values of 'carLocked', 'carParked' and 'carWorld' to random numbers between 10-99. I can't figure out why it's doing this, it was working just fine before but now, all of a sudden, it's setting stuff it shouldn't be.
This is the function which creates cars and sets its values...
It's inserting everything into the database fine, except the plate... here's a screenshot...
Am I using INSERT INTO wrong?
This is the function which creates cars and sets its values...
PHP код:
PlayerCar_Create(ownerid, modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2)
{
for (new i = 0; i != MAX_DYNAMIC_CARS; i ++)
{
if (!CarData[i][carExists])
{
if (color1 == -1)
color1 = random(127);
if (color2 == -1)
color2 = random(127);
CarData[i][carExists] = true;
CarData[i][carModel] = modelid;
CarData[i][carOwner] = ownerid;
CarData[i][carPos][0] = x;
CarData[i][carPos][1] = y;
CarData[i][carPos][2] = z;
CarData[i][carPos][3] = angle;
CarData[i][carColor1] = color1;
CarData[i][carColor2] = color2;
CarData[i][carPaintjob] = -1;
CarData[i][carLocked] = false;
CarData[i][carParked] = 0;
CarData[i][carWorld] = 0;
CarData[i][carImpounded] = -1;
CarData[i][carImpoundPrice] = 0;
new str[8];
format(str, sizeof(str), "%s%s%d%d%s%s%s", LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], random(10), random(10), LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]);
SetVehicleNumberPlate(i, str);
format(CarData[i][carPlate], 11, "%s", str);
mysql_function_query(g_iHandle, "INSERT INTO `playercars` (`carModel`) VALUES(0)", false, "OnPlayerCarCreated", "d", i);
return i;
}
}
return -1;
}
forward OnPlayerCarCreated(carid);
public OnPlayerCarCreated(carid)
{
if (carid == -1 || !CarData[carid][carExists])
return 0;
CarData[carid][carID] = mysql_insert_id();
PlayerCar_Save(carid);
return 1;
}
Am I using INSERT INTO wrong?