Cars sving loading is not working. (MYSQL)
#1

Hello dear samp forum members I need your help despretlly.

So my code is not working fully. My second and 3rd car what I bought is not saving and i dont understand why tried a lot of metods but still got the same thing. So here is my code maybe some one could help me out as it's very important to me.

pawn Код:
public SaveSQLCar(idx,savePark)
{
    print("Car Saving");
    new sql[512],owner[32],oldOwner[32],message[64];
    mysql_real_escape_string(CarInfo[idx][cOwner], owner);
    mysql_real_escape_string(CarInfo[idx][cOldOwner], oldOwner);
    mysql_real_escape_string(CarInfo[idx][cDescription], message);

    format(sql, sizeof(sql), "UPDATE srp_players_cars SET model=%d,color1=%d,color2=%d,owner='%s',oldOwner='%s',type=%d,description='%s',price=%d,owned=%d,locked=%d,status=%d,arme1=%d,arme2=%d,arme3=%d,arme4=%d,arme5=%d,amo1=%d,amo2=%d,amo3=%d,amo4=%d,amo5=%d,drugs=%d WHERE id=%d",
    CarInfo[idx][cModel],
    CarInfo[idx][cColorOne],
    CarInfo[idx][cColorTwo],
    owner,
    oldOwner,
    CarInfo[idx][cType],
    message,
    CarInfo[idx][cValue],
    CarInfo[idx][cOwned],
    CarInfo[idx][cLock],
    CarInfo[idx][cStatus],
    CarInfo[idx][cArme1],
    CarInfo[idx][cArme2],
    CarInfo[idx][cArme3],
    CarInfo[idx][cArme4],
    CarInfo[idx][cArme5],
    CarInfo[idx][cAmo1],
    CarInfo[idx][cAmo2],
    CarInfo[idx][cAmo3],
    CarInfo[idx][cAmo4],
    CarInfo[idx][cAmo5],
    CarInfo[idx][cDrugs],
    idx );
    MySQLCheckconnexion();
    mysql_query(sql);
    //SQLLog(sql);

    format(sql, sizeof(sql), "UPDATE srp_players_cars SET hero=%d,matos=%d,job=%d, faction=%d, house=%d, Stelled=%d, tPaintJob=%d, tExhausts=%d, tFrontBumper=%d, tRearBumper=%d, tRoof=%d, tSpoilers=%d, tSideBumper=%d, tWheels=%d, tHydraulics=%d, tNitro=%d, tSideBumper2=%d, tNeon=%d, plaque='%s', rank=%d, vignette=%d WHERE id=%d",
    CarInfo[idx][cHero],
    CarInfo[idx][cMatos],
    CarInfo[idx][cJob],
    CarInfo[idx][cFaction],
    CarInfo[idx][cHouse],
    CarInfo[idx][cStelled],
    CarInfo[idx][tPaintJob],
    CarInfo[idx][tExhausts],
    CarInfo[idx][tFrontBumper],
    CarInfo[idx][tRearBumper],
    CarInfo[idx][tRoof],
    CarInfo[idx][tSpoilers],
    CarInfo[idx][tSideBumper],
    CarInfo[idx][tWheels],
    CarInfo[idx][tHydraulics],
    CarInfo[idx][tNitro],
    CarInfo[idx][tSideBumper2],
    CarInfo[idx][tNeon],
    CarInfo[idx][cPlaque],
    CarInfo[idx][cRank],
    CarInfo[idx][cVignette],
    idx );
    MySQLCheckconnexion();
    mysql_query(sql);
    //SQLLog(sql);

    if(savePark)
    {
        format(sql,sizeof(sql),"UPDATE srp_players_cars SET x=%f,y=%f,z=%f,angle=%f WHERE id=%d",
        CarInfo[idx][cLocationx],
        CarInfo[idx][cLocationy],
        CarInfo[idx][cLocationz],
        CarInfo[idx][cAngle],
        idx);
        MySQLCheckconnexion();
        mysql_query(sql);
    }
    return 1;
}

public car_changeStatus(carid,status)
{
    if(status==1)
    { // Retour а la normale
        CarInfo[carid][cStatus]=1;
        SaveSQLCar(carid,false);
        return 1;
    }


    new proprioCo=-1,tmpName[MAX_PLAYER_NAME],string[128];
    for(new i=MIN_PLAYERID; i<MAX_PLAYERS_CURRENT+1; i++)
    {
        if(IsPlayerConnected(i) && gPlayerLogged[i])
        {
            GetPlayerName(i,tmpName,MAX_PLAYER_NAME);
            if(strcmp(tmpName,CarInfo[carid][cOwner],true)==0)
                {proprioCo=i; break;}
        }
    }
    if(status==2)
    {
        if(proprioCo!=-1)
        { // Proprio actuellement connectй, on lui envoit un message
            format(string,sizeof(string),"[Vehicule] Votre vйhicule (%s) vient d'кtre mis en fourriиre, utilisez /gps pour y aller.",VehiclesName[GetVehicleModel(carid)-400]);
            SendClientMessage(proprioCo,COLOR_VEHICULE,string);
        }
        else
        { // Sinon, on modifie le status, pour avertir le proprio а sa connexion
            CarInfo[carid][cStatus]=2;
            SaveSQLCar(carid,false);
        }
    }
    else if(status==3)
    {
        if(proprioCo!=-1)
        { // Proprio actuellement connectй, on lui envoit un message
            format(string,sizeof(string),"[Vehicule] Votre vйhicule (%s) a йtй volй ! Allez la rйcupйrer а la fourriиre. (( /gps ))",VehiclesName[GetVehicleModel(carid)-400]);
            SendClientMessage(proprioCo,COLOR_VEHICULE,string);
        }
        else
        { // Sinon, on modifie le status, pour avertir le proprio а sa connexion (si respawn de la caisse, on l'enlve)
            CarInfo[carid][cStatus]=3;
            SaveSQLCar(carid,false);
        }
    }
    return 1;
}

public car_checkStatus(playerid)
{
    new string[MAX_STRING_MSG];
    if(PlayerInfo[playerid][pPcarkey]!=9999)
    {
        new carId=PlayerInfo[playerid][pPcarkey];
        if(CarInfo[carId][cStatus]==2)
        {
            format(string,sizeof(string),"[Vehicule] Votre vйhicule (%s) a йtй mis en fourriиre, utilisez /gps pour y aller.",VehiclesName[GetVehicleModel(carId)-400]);
            SendClientMessage(playerid,COLOR_VEHICULE,string);
            car_changeStatus(carId,1);
        }
        else if(CarInfo[carId][cStatus]==3)
        {
            format(string,sizeof(string),"[Vehicule] Votre vйhicule (%s) a йtй volй ! Allez la rйcupйrer а la fourriиre des voitures volйes (( /gps ))",VehiclesName[GetVehicleModel(carId)-400]);
            SendClientMessage(playerid,COLOR_VEHICULE,string);
            car_changeStatus(carId,1);
        }
    }
    if(PlayerInfo[playerid][pCarKey2]!=9999)
    {
        new carId=PlayerInfo[playerid][pCarKey2];
        if(CarInfo[carId][cStatus]==2)
        {
            format(string,sizeof(string),"[Vehicule] Votre vйhicule (%s) a йtй mis en fourriиre, utilisez /gps pour y aller.",VehiclesName[GetVehicleModel(carId)-400]);
            SendClientMessage(playerid,COLOR_VEHICULE,string);
            car_changeStatus(carId,1);
        }
        else if(CarInfo[carId][cStatus]==3)
        {
            format(string,sizeof(string),"[Vehicule] Votre vйhicule (%s) a йtй volй ! Allez la rйcupйrer а la fourriиre des voitures volйes (( /gps ))",VehiclesName[GetVehicleModel(carId)-400]);
            SendClientMessage(playerid,COLOR_VEHICULE,string);
            car_changeStatus(carId,1);
        }
    }
    if(PlayerInfo[playerid][pCarKey3]!=9999)
    {
        new carId=PlayerInfo[playerid][pCarKey3];
        if(CarInfo[carId][cStatus]==2)
        {
            format(string,sizeof(string),"[Vehicule] Votre vйhicule (%s) a йtй mis en fourriиre, utilisez /gps pour y aller.",VehiclesName[GetVehicleModel(carId)-400]);
            SendClientMessage(playerid,COLOR_VEHICULE,string);
            car_changeStatus(carId,1);
        }
        else if(CarInfo[carId][cStatus]==3)
        {
            format(string,sizeof(string),"[Vehicule] Votre vйhicule (%s) a йtй volй ! Allez la rйcupйrer а la fourriиre des voitures volйes (( /gps ))",VehiclesName[GetVehicleModel(carId)-400]);
            SendClientMessage(playerid,COLOR_VEHICULE,string);
            car_changeStatus(carId,1);
        }
    }
}

public car_setCarOwned(playerid, vehicleid)
{
    if(car_getNbrCars(playerid) >= 3)
        {return 1;}

    new change=false;
    if(PlayerInfo[playerid][pPcarkey] == 9999)
        {PlayerInfo[playerid][pPcarkey] = vehicleid; change=true;}
    else if(PlayerInfo[playerid][pCarKey2] == 9999)
        {PlayerInfo[playerid][pCarKey2] = vehicleid; change=true;}
    else if(PlayerInfo[playerid][pCarKey3] == 9999)
        {PlayerInfo[playerid][pCarKey3] = vehicleid; change=true;}

    if(change)
    {
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, sizeof(playername));
        CarInfo[vehicleid][cOwned] = 1;
        CreateVehicleLabel(vehicleid,playerid);
        check_nameTag(playerid);
        memcpy(CarInfo[vehicleid][cOwner], playername, 0, MAX_PLAYER_NAME*4, MAX_PLAYER_NAME*4);
        SaveSQLCar(vehicleid,false);
        format(proxy_msg, sizeof(debug_msg), "Achat de la voiture : cOwned=%d", CarInfo[vehicleid][cOwned]);
        debug_sendMsg(playerid, debug_msg);
        OnPlayerUpdateSQL(playerid);
    }
    return 1;
}
Thank you for your time.

Respectfully LilBob!
Reply


Messages In This Thread
Cars sving loading is not working. (MYSQL) - by LilBob - 14.04.2013, 13:21
Re: Cars sving loading is not working. (MYSQL) - by Jay_ - 14.04.2013, 13:37
Re: Cars sving loading is not working. (MYSQL) - by LilBob - 14.04.2013, 13:52
Re: Cars sving loading is not working. (MYSQL) - by LilBob - 17.04.2013, 07:55
Re: Cars sving loading is not working. (MYSQL) - by LilBob - 20.04.2013, 08:39
Re: Cars sving loading is not working. (MYSQL) - by LilBob - 21.04.2013, 17:23
Re: Cars sving loading is not working. (MYSQL) - by Knappen - 21.04.2013, 20:38
Re: Cars sving loading is not working. (MYSQL) - by LilBob - 22.04.2013, 09:46
Re: Cars sving loading is not working. (MYSQL) - by LilBob - 26.04.2013, 18:12

Forum Jump:


Users browsing this thread: 1 Guest(s)