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
#2

em.. you tuned vehicle in TransFender/Loco Low Co/another_garage?
Reply
#3

Nop, in a custom made tuning place, but it actualy works just like one of those.
Reply
#4

Have you bothered to check the mysql_log.txt file that is generated if you've told it too.
Reply
#5

Sure.So after buying a car, it saves all the data without any probs.
PHP код:
stock BuyCar(playerididx)
{
    if(
GetPlayerHouse(playerid) == 1)
    {
        new 
Float:xFloat:yFloat:zFloat:fa,cost[MAX_PLAYERS],model[MAX_PLAYERS], GetPVarInt(playerid"PlayerHouse");
        switch(
InShop[playerid])
        {
            case 
1cost[playerid]=GetInflationPrice(carsC[pPressed[playerid]][1]), model[playerid]=carsC[pPressed[playerid]][0], x=542.2341y=-1291.1302z=17.2422fa=0.9819;
            case 
2cost[playerid]=GetInflationPrice(carsB[pPressed[playerid]][1]), model[playerid]=carsB[pPressed[playerid]][0], x=-1957.9304y=305.4497z=35.4688fa=179.9544;
            case 
3cost[playerid]=GetInflationPrice(carsA[pPressed[playerid]][1]), model[playerid]=carsA[pPressed[playerid]][0], x=2200.7061y=1392.0594z=10.8203fa=180.9670;
        }
        if(
PlayerInfo[playerid][pBank] < cost[playerid]) return SendClientMessage(playeridCOLOR_GREYYouDoNotHaveEnoughMoney);
        
InShop[playerid] = 0;
        
TogglePlayerControllable(playerid,true);
        
Exchequer+=cost[playerid];
        
format(query64"UPDATE "TABLE_PICK" SET exchequer = %d"Exchequer);
        
PlayerInfo[playerid][pBank] -= cost[playerid];
        
TextDrawHideForPlayer(playerid,VehNazv[playerid]);
        
TextDrawHideForPlayer(playerid,VehCost[playerid]);
        
TextDrawHideForPlayer(playerid,PressA);
        
TextDrawHideForPlayer(playerid,PressD);
        
TextDrawHideForPlayer(playerid,PressH);
        
TextDrawHideForPlayer(playerid,PressC);
        
TextDrawHideForPlayer(playerid,PressB);
        
TextDrawHideForPlayer(playerid,VehBox);
        
t_SetPlayerPos(playerid,x,y,z);
        
SetPlayerFacingAngle(playerid,fa);
        
AC_BS_SetPlayerInterior(playerid,0);
        
AC_BS_SetPlayerVirtualWorld(playerid,0);
        
SetCameraBehindPlayer(playerid);
        
strmid(CarInfo[idx][cOwner],sendername(playerid),0,strlen(sendername(playerid)),MAX_PLAYER_NAME);
        
CarInfo[idx][cModel]=model[playerid];
        
CarInfo[idx][cCost]=cost[playerid];
        
CarInfo[idx][cLock]=1;
        
CarInfo[idx][cX] = HouseInfo[h][hCarx];
        
CarInfo[idx][cY] = HouseInfo[h][hCary];
        
CarInfo[idx][cZ] = HouseInfo[h][hCarz];
        
CarInfo[idx][cFa] = HouseInfo[h][hCarfa];
        
CarInfo[idx][cHeal] = 1000;
        
CarInfo[idx][cFuel] = 200;
        
CarInfo[idx][cColor][0]=colors[playerid][0];
        
CarInfo[idx][cColor][1]=colors[playerid][1];
        
CarInfo[idx][id] = idx;
        
SetPVarInt(playerid"PlayerCars"CarInfo[idx][id]);
        
format(CarInfo[idx][cColors], 16"%d, %d",CarInfo[idx][cColor][0],CarInfo[idx][cColor][1]);
        
strmid(CarInfo[idx][cOwner],sendername(playerid),0,strlen(sendername(playerid)),MAX_PLAYER_NAME);
        
SendMes(playeridTEAM_BLUE_COLOR"Jus nopirkat transportlidzekli: %s par %d Eiro",VehicleNameS[GetVehicleModel(veh[playerid])-400],CarInfo[idx][cCost]);
        
SendClientMessage(playerid,TEAM_BLUE_COLOR,"Jusu transportlidzeklis piegadats pie majas!");
        
DestroyVehicle(veh[playerid]);
        
format(query,sizeof(query),"UPDATE "TABLE_CARS" SET clock = %i, model = %i,cost = %i,colors = '%s', x = '%f', y='%f', z='%f', fa='%f', fuel = %i, heal = '%f' WHERE id = %i",CarInfo[idx][cLock],CarInfo[idx][cModel],
        
CarInfo[idx][cCost],CarInfo[idx][cColors],CarInfo[idx][cX], CarInfo[idx][cY], CarInfo[idx][cZ], CarInfo[idx][cFa], CarInfo[idx][cFuel], CarInfo[idx][cHeal], idx);
        
mysql_query(query); 
Also, MySQL log shows:
PHP код:
00:53:34] >> mysql_queryConnection handle)
[
00:53:34CMySQLHandler::Query(UPDATE cars SET clock 1model 458,cost 480000,colors '0, 0''1848.738647'y='-1926.755737'z='13.207628'fa='89.873275'fuel 200heal '1000.000000' WHERE id 1) - Successfully executed
BUT, if i change the color in tuning, MySQL log gives no info. It just doesnt record anything.
Reply
#6

Well giving us the buy 'command/function' isn't going to help us, help you now is it.
Also if you translated each of your 'Text' or so on into English such as "exchequer", it'll also help us figure out what is what, and what goes where. (Or post in the language sections at the bottom which corresponds with said language).
Reply
#7

The thing is its in Latvian language.
I will try to explain every thing.

This sets the info into MySQL database:

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);

This is where the Pvar CREVEH 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(caridCarInfo[c][cHeal]);
    
Engine[carid] = false;
    
Lights[carid] = false;
    switch(
CarInfo[c][cLock])
    {
         case 
0IsLocked[carid] = false;
         case 
1IsLocked[carid] = true;
    }
    
SetPVarInt(playerid,"CREVEH",carid);
    if(
CarInfo[c][cVehcoms][0]!=0AddVehicleComponent(caridCarInfo[c][cVehcoms][0]);
    if(
CarInfo[c][cVehcoms][1]!=0AddVehicleComponent(caridCarInfo[c][cVehcoms][1]);
    if(
CarInfo[c][cVehcoms][2]!=0AddVehicleComponent(caridCarInfo[c][cVehcoms][2]);
    if(
CarInfo[c][cVehcoms][3]!=0AddVehicleComponent(caridCarInfo[c][cVehcoms][3]);
    if(
CarInfo[c][cVehcoms][4]!=0AddVehicleComponent(caridCarInfo[c][cVehcoms][4]);
    if(
CarInfo[c][cVehcoms][5]!=0AddVehicleComponent(caridCarInfo[c][cVehcoms][5]);
    if(
CarInfo[c][cVehcoms][6]!=0AddVehicleComponent(caridCarInfo[c][cVehcoms][6]);
    if(
CarInfo[c][cVehcoms][7]!=0AddVehicleComponent(caridCarInfo[c][cVehcoms][7]);
    if(
CarInfo[c][cVehcoms][8]!=0AddVehicleComponent(caridCarInfo[c][cVehcoms][8]);
    if(
CarInfo[c][cVehcoms][9]!=0AddVehicleComponent(caridCarInfo[c][cVehcoms][9]);
    if(
CarInfo[c][cVehcoms][10]!=0AddVehicleComponent(caridCarInfo[c][cVehcoms][10]);
    if(
CarInfo[c][cVehcoms][11]!=0AddVehicleComponent(caridCarInfo[c][cVehcoms][11]);
    if(
CarInfo[c][cVehcoms][12]!=0AddVehicleComponent(caridCarInfo[c][cVehcoms][12]);
    if(
CarInfo[c][cVehcoms][13]!=0AddVehicleComponent(carid,CarInfo[c][cVehcoms][13]);
    if(
CarInfo[c][cPaintjob]!=0ChangeVehiclePaintjob(caridCarInfo[c][cPaintjob]);
    return 
true;

the ccolors:
PHP код:
enum cInfo
{
    
id,
    
cModel,
    
Float:cX,
    
Float:cY,
    
Float:cZ,
    
Float:cFa,
    
Float:cHeal,
    
cFuel,
    
cColors[16],
    
cColor[2],
    
cOwner[MAX_PLAYER_NAME],
    
cLock,
    
cCost,
    
cVehcom[127],
    
cVehcoms[14],
    
cPaintjob
}; 
Ugh i guess there are tons of things to copy.
Heres the whole gamemode. If theres anything i need to translate or if theres anything in the script that you dont know what its ment for, il explain it. http://www.mediafire.com/view/sd6esp...d0/newmode.pwn
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)