01.12.2014, 11:04
Hello.
So the thing is, after buying a car ingame, there is an option to change cars color. After changing the color, it saves the color data into database. Everythings fine with that. But after respraying my car into mechanics garage, it does not save anything and i can't find to seem whats wrong with the code. Also, in tuning, after Mechanic offers me to respray my veh, it shows the new color. If i decline it does not change it back to the old one. The problem is, after tuning if i restart my client, it does not save the tuned color although it should. Il just copy the whole code down here.
:Offering to respray my car.
The Respray script:
This is the script, that saves it into the DB:
And this is where the " CREVEH" pVar is made:
This is where the Table "cars" is defined.:
And this is a screen shot of the "cars" db.
So the thing is, after buying a car ingame, there is an option to change cars color. After changing the color, it saves the color data into database. Everythings fine with that. But after respraying my car into mechanics garage, it does not save anything and i can't find to seem whats wrong with the code. Also, in tuning, after Mechanic offers me to respray my veh, it shows the new color. If i decline it does not change it back to the old one. The problem is, after tuning if i restart my client, it does not save the tuned color although it should. Il just copy the whole code down here.
:Offering to respray my car.
PHP код:
case D_JOB+79:
{
if(!response) return TuningList(playerid);
new color[2], playerd = GetPVarInt(playerid, "PlayerTuning"), c = GetPVarInt(playerd, "CREVEH");
if(sscanf(inputtext, "p<,>ii",color[0], color[1])) return ShowPlayerDialog(playerid, D_JOB+79, 1, "Krasa", "Ievadiet krasu1 un krasu2 transporta caur komatu:", "Pienemt", "Atpakal");
if(color[0] < 0 || color[0] > 252)
{
ShowPlayerDialog(playerid, D_JOB+79, 1, "Color", "Write in the color1 and color 2 ids", "Accept", "Back");
return SendClientMessage(playerid, COLOR_GREY, "ID цвета от 0 до 252!");
}
if(color[1] < 0 || color[1] > 252)
{
ShowPlayerDialog(playerid, D_JOB+79, 1, "Color", "Write in the color1 and color2 ids", "accept", "Decline");
return SendClientMessage(playerid, COLOR_GREY, "ID krasai no 0 lidz 252!");
}
ChangeVehicleColor(c, color[0], color[1]);
SetPVarInt(playerid, "TuningColor1", color[0]);
SetPVarInt(playerid, "TuningColor2", color[1]);
SendMes(playerid, COLOR_BLUE, "You offered %s' to buy this color. Cost: %i eur", sendername(playerd), VEHICLE_COLOR);
SendMes(playerd, COLOR_BLUE, "Mechanic %s Offered you to buy this color. Cost: %i ls", sendername(playerid), VEHICLE_COLOR);
format(string, 200, "Mechanic %s Offered you to buy this color. Cost: %i ls\n\nDo you agree?", sendername(playerid), VEHICLE_COLOR);
ShowPlayerDialog(playerd, D_JOB+80, 0, "Color", string, "yes", "no");
}
PHP код:
case D_JOB+80:
{
new playerd = GetPVarInt(playerid, "TuningPlayer");
if(response)
{
if(GetMoney(playerid) < VEHICLE_COLOR)
{
SendClientMessage(playerid, COLOR_GREY, "Not enough cash!");
SendMes(playerd, COLOR_BLUE, " %s Not enough cash", sendername(playerid));
ChangeVehicleColor(GetPVarInt(playerid, "CREVEH"), CarInfo[GetPVarInt(playerid, "CREVEH")][cColor][0], CarInfo[GetPVarInt(playerid, "CREVEH")][cColor][1]);
DeletePVar(playerd, "TuningColor1");
DeletePVar(playerd, "TuningColor2");
return 1;
}
GiveMoney(playerid, -VEHICLE_COLOR);
FracBank[11] += VEHICLE_COLOR;
SetOtherInt("mechbank", FracBank[11]);
SetPVarInt(playerd, "TuningMoney", GetPVarInt(playerd, "TuningMoney") + VEHICLE_COLOR);
CarInfo[GetPVarInt(playerid, "CREVEH")][cColor][0] = GetPVarInt(playerd, "TuningColor1");
CarInfo[GetPVarInt(playerid, "CREVEH")][cColor][1] = GetPVarInt(playerd, "TuningColor2");
format(CarInfo[GetPVarInt(playerid, "CREVEH")][cColors], 16, "%d, %d", CarInfo[GetPVarInt(playerid, "CREVEH")][cColor][0], CarInfo[GetPVarInt(playerid, "CREVEH")][cColor][1]);
SetCarsStr(CarInfo[GetPVarInt(playerid, "CREVEH")][id], "colors", CarInfo[GetPVarInt(playerid, "CREVEH")][cColors]);
SendMes(playerid, COLOR_BLUE, "You accepted the offer for : %i ls", VEHICLE_COLOR);
SendMes(playerd, COLOR_BLUE, "%sYou accepted the offer for %i ls", sendername(playerid), VEHICLE_COLOR);
}
else
{
SendMes(playerd, COLOR_BLUE, "%s declinde the offer", sendername(playerid));
ChangeVehicleColor(GetPVarInt(playerid, "CREVEH"), CarInfo[GetPVarInt(playerid, "CREVEH")][cColor][0], CarInfo[GetPVarInt(playerid, "CREVEH")][cColor][1]);
}
DeletePVar(playerd, "TuningColor1");
DeletePVar(playerd, "TuningColor2");
}
PHP код:
stock SetCarsStr(idx, stolb[], znach[])
{
new Query[128];
format(Query, sizeof(Query), "UPDATE "TABLE_CARS" SET %s = '%s' WHERE id = '%d' LIMIT 1", stolb, znach, idx);
return mysql_query(Query);
}
PHP код:
stock LoadMyCar(playerid)
{
if(GetPlayerHouse(playerid) == 0) return 1;
if(GetPlayerCar(playerid) == 0) return 1;
new c = GetPVarInt(playerid, "PlayerCars");
new carid = CreateVehicle(CarInfo[c][cModel], CarInfo[c][cX], CarInfo[c][cY], CarInfo[c][cZ], CarInfo[c][cFa], CarInfo[c][cColor][0], CarInfo[c][cColor][1], 90000);
CarDoors(carid, CarInfo[c][cLock]);
Fuel[carid] = CarInfo[c][cFuel];
// SetVehicleHealth(carid, CarInfo[c][cHeal]);
Engine[carid] = false;
Lights[carid] = false;
switch(CarInfo[c][cLock])
{
case 0: IsLocked[carid] = false;
case 1: IsLocked[carid] = true;
}
SetPVarInt(playerid,"CREVEH",carid);
PHP код:
#define TABLE_CARS "cars"