MySQL not saving data.(somewheres a mistake)
#1

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.
PHP код:
        case D_JOB+79:
        {
            if(!
response) return TuningList(playerid);
              new 
color[2], playerd GetPVarInt(playerid"PlayerTuning"), GetPVarInt(playerd"CREVEH");
            if(
sscanf(inputtext"p<,>ii",color[0], color[1])) return ShowPlayerDialog(playeridD_JOB+791"Krasa""Ievadiet krasu1 un krasu2 transporta caur komatu:""Pienemt""Atpakal");
              if(
color[0] < || color[0] > 252)
              {
                  
ShowPlayerDialog(playeridD_JOB+791"Color""Write in the color1 and color 2 ids""Accept""Back");
                  return 
SendClientMessage(playeridCOLOR_GREY"ID цвета от 0 до 252!");
            }
            if(
color[1] < || color[1] > 252)
            {
                
ShowPlayerDialog(playeridD_JOB+791"Color""Write in the color1 and color2 ids""accept""Decline");
                return 
SendClientMessage(playeridCOLOR_GREY"ID krasai no 0 lidz 252!");
            }
            
ChangeVehicleColor(ccolor[0], color[1]);
            
SetPVarInt(playerid"TuningColor1"color[0]);
            
SetPVarInt(playerid"TuningColor2"color[1]);
            
SendMes(playeridCOLOR_BLUE"You offered %s' to buy this color. Cost: %i eur"sendername(playerd), VEHICLE_COLOR);
            
SendMes(playerdCOLOR_BLUE"Mechanic %s Offered you to buy this color. Cost: %i ls"sendername(playerid), VEHICLE_COLOR);
            
format(string200"Mechanic %s Offered you to buy this color. Cost: %i ls\n\nDo you agree?"sendername(playerid), VEHICLE_COLOR);
            
ShowPlayerDialog(playerdD_JOB+800"Color"string"yes""no");
        } 
The Respray script:
PHP код:
        case D_JOB+80:
        {
            new 
playerd GetPVarInt(playerid"TuningPlayer");
            if(
response)
            {
                if(
GetMoney(playerid) < VEHICLE_COLOR)
                {
                    
SendClientMessage(playeridCOLOR_GREY"Not enough cash!");
                    
SendMes(playerdCOLOR_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(playeridCOLOR_BLUE"You accepted the offer for : %i ls"VEHICLE_COLOR);
                
SendMes(playerdCOLOR_BLUE"%sYou accepted the offer for %i ls"sendername(playerid), VEHICLE_COLOR);
            }
            else
            {
                
SendMes(playerdCOLOR_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");
        } 
This is the script, that saves it into the DB:
PHP код:
stock SetCarsStr(idxstolb[], znach[])
{
    new 
Query[128];
    
format(Querysizeof(Query), "UPDATE "TABLE_CARS" SET  %s = '%s' WHERE id = '%d' LIMIT 1"stolbznachidx);
    return 
mysql_query(Query);

And this is where the " CREVEH" pVar is made:

PHP код:
stock LoadMyCar(playerid)
{
    if(
GetPlayerHouse(playerid) == 0) return 1;
    if(
GetPlayerCar(playerid) == 0) return 1;
     new 
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(caridCarInfo[c][cLock]);
     
Fuel[carid] = CarInfo[c][cFuel];
//     SetVehicleHealth(carid, CarInfo[c][cHeal]);
    
Engine[carid] = false;
    
Lights[carid] = false;
    switch(
CarInfo[c][cLock])
    {
         case 
0IsLocked[carid] = false;
         case 
1IsLocked[carid] = true;
    }
    
SetPVarInt(playerid,"CREVEH",carid); 
This is where the Table "cars" is defined.:
PHP код:
#define TABLE_CARS          "cars" 
And this is a screen shot of the "cars" db.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)