• 24 Avril 2025, 03:14:14


Auteur Sujet: Probleme de sauvegarde de vehicule  (Lu 681 fois)

0 Membres et 1 Invité sur ce sujet

Hors ligne Alakzam

  • *
  • Nouveau
  • Messages: 3
    • Voir le profil
Probleme de sauvegarde de vehicule
« le: 09 Novembre 2012, 13:45:13 »
Alors déjà , bonjour a tous/toutes,

Je suis nouveau ici , et j'aimerais un coup de main , car malgrès toutes mes modifications dans le gm etc.. je n'ai rien pu trouver.

Alors j'explique le problème , je script un serveur RP pour le plaisir, et donc j'ai fais un système d'achat de vehicule ( merci MrFredo au passage) qui fais que quand on achète un véhicule , cela en spawn un autre au port de SF ( oui mon serveur est sur sf ^^ ).

Et donc le soucis étant que malgré que j'ai mis la fonction "SauvegardeVeh();" mes véhicules ne se sauvegarde pas.
Par contre quand je tape la commande /vehsave sur ce même véhicule cela le sauvegarde.

Le Code du "acheter"
                else if(strcmp(x_nr,"acheter",true) == 0)
        {
   if(IsPlayerInAnyVehicle(playerid))
   {
            new car = 1;
            new model = GetVehicleModel(idcar);
            new vehicleid = GetPlayerVehicleID(playerid);
            if(IsAnOwnableCar(vehicleid))
            {
                if(PlayerInfo[playerid][pLevel] < 2)
    {
                    SendClientMessage(playerid, COLOR_GREY, "Vous devez etre niveau 2 pour acheter un véhicule !");
                    return 1;
    }
if(GetPlayerMoney(playerid) >= VehiculeInfo[vehicleid][Prix])
{
    if(PlayerInfo[playerid][pCarLic] == 1)
    {
for(new h = 1; h < sizeof(CarInfo); h++)
{
if(VehaInfo[h][cOwner] == 0)
{
car = h;
h = 9999;
}
                       }
                        if(PlayerInfo[playerid][pPcarkey] != 9999) { PlayerInfo[playerid][pPcarkey2] = car; }
else { PlayerInfo[playerid][pPcarkey] = car; }
CarInfo[car][cOwned] = 1;
strmid(CarInfo[car][cOwner], sendername, 0, strlen(sendername), 999);
SafeGivePlayerMoney(playerid,-VehiculeInfo[vehicleid][Prix]);
if(IsAPlane(vehicleid))
{
CarInfo[car][cLocationx] = 1432.6451;
CarInfo[car][cLocationy] = 1378.7216;
CarInfo[car][cLocationz] = 11.5507;
CarInfo[car][cAngle] = 359.2072;
SendClientMessage(playerid, COLOR_YELLOW2, "Votre Avion a étais livré a l'aéroport !");
}
else if(IsABoat(vehicleid))
{
    CarInfo[car][cLocationx] = -1568.9614;
CarInfo[car][cLocationy] = 169.0118;
CarInfo[car][cLocationz] = -0.6016;
CarInfo[car][cAngle] = 208.7506;
SendClientMessage(playerid, COLOR_YELLOW2, "Votre Bateau a étais livré au Docks !");
}
else
{
                                CarInfo[car][cLocationx] = -1589.2644;
CarInfo[car][cLocationy] = 106.9119;
CarInfo[car][cLocationz] = 3.5495;
CarInfo[car][cAngle] = 317.1649;
SendClientMessage(playerid, COLOR_YELLOW2, "Votre Voiture a étais livré au port !");
}

SauvegardeVeh();
CarInfo[car][cModel] = model;
CarInfo[car][cVirWorld] = 0;
CarInfo[car][cPaintjob] = 999;
CarInfo[car][cColorOne] = 1;
CarInfo[car][cColorTwo] = 1;
CarInfo[car][cComponent0] = 0;
CarInfo[car][cComponent1] = 0;
CarInfo[car][cComponent2] = 0;
CarInfo[car][cComponent3] = 0;
CarInfo[car][cComponent4] = 0;
CarInfo[car][cComponent5] = 0;
CarInfo[car][cComponent6] = 0;
CarInfo[car][cComponent7] = 0;
CarInfo[car][cComponent8] = 0;
CarInfo[car][cComponent9] = 0;
CarInfo[car][cComponent10] = 0;
CarInfo[car][cComponent11] = 0;
CarInfo[car][cComponent12] = 0;
CarInfo[car][cComponent13] = 0;
ownedcar[car] = CreateVehicle(CarInfo[car][cModel],CarInfo[car][cLocationx],CarInfo[car][cLocationy],CarInfo[car][cLocationz],90.0,1,1,30000);
SendClientMessage(playerid, COLOR_GRAD2, "Taper /v pour voir les commandes disponibles!");
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "Vous devez avoir le permis de Conduire");
return 1;
}
}
else
{
    SendClientMessage(playerid, COLOR_GREY, "Vous n'avez pas assez d'argent");
    return 1;
}
            }
        }
}

Et le code du SauvegardeVeh
public SauvegardeVeh()
{
#if defined USE_MYSQL

    new query[512];
for(new v=1;v<NbVeh;v++)
{
        if(VehiculeInfo[v][VehID] != INVALID_VEH_ID)
        {
format(query, sizeof(query), "UPDATE %s SET Model=%d, XSpawn='%f', YSpawn='%f', ZSpawn='%f', ASpawn='%f', Couleur1=%d, Couleur2=%d, Prix=%d, Status=%d, Alarme=%d, Tuning1=%d, Tuning2=%d, Tuning3=%d, Tuning4=%d, Tuning5=%d, Tuning6=%d, Tuning7=%d, Tuning8=%d, Tuning9=%d, Tuning10=%d, Tuning11=%d, Tuning12=%d, Tuning13=%d, Tuning14=%d, Tuning15=%d, Tuning16=%d, Tuning17=%d, Peinture=%d, MaxEssence=%d, Proprio='%s', Nom='%s' WHERE VehID=%d LIMIT 1",
MYSQL_TB_VEH,VehiculeInfo[v][Model],VehiculeInfo[v][XSpawn],VehiculeInfo[v][YSpawn],VehiculeInfo[v][ZSpawn],
VehiculeInfo[v][ASpawn],VehiculeInfo[v][Couleur1],VehiculeInfo[v][Couleur2],VehiculeInfo[v][Prix],
VehiculeInfo[v][Status],VehiculeInfo[v][Alarme],VehiculeInfo[v][Tuning1],VehiculeInfo[v][Tuning2],
VehiculeInfo[v][Tuning3],VehiculeInfo[v][Tuning4],VehiculeInfo[v][Tuning5],VehiculeInfo[v][Tuning6],
VehiculeInfo[v][Tuning7],VehiculeInfo[v][Tuning8],VehiculeInfo[v][Tuning9],VehiculeInfo[v][Tuning10],
VehiculeInfo[v][Tuning11],VehiculeInfo[v][Tuning12],VehiculeInfo[v][Tuning13],VehiculeInfo[v][Tuning14],
VehiculeInfo[v][Tuning15],VehiculeInfo[v][Tuning16],VehiculeInfo[v][Tuning17],VehiculeInfo[v][Peinture],
VehiculeInfo[v][MaxEssence],VehiculeInfo[v][Proprio],VehiculeInfo[v][Nom],VehiculeInfo[v][VehID]
);
samp_mysql_query(query);
}
}

#else

  new File:VehFile = fopen(VEH_FILENAME, io_write);
new vehstring[256];
for(new v=1;v<NbVeh;v++)
{
    if(VehiculeInfo[v][VehID] != INVALID_VEH_ID)
    {
format(vehstring, sizeof(vehstring), "%d|%d|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%s|%s\r\n",
VehiculeInfo[v][VehID],VehiculeInfo[v][Model],VehiculeInfo[v][XSpawn],VehiculeInfo[v][YSpawn],VehiculeInfo[v][ZSpawn],
VehiculeInfo[v][ASpawn],VehiculeInfo[v][Couleur1],VehiculeInfo[v][Couleur2],VehiculeInfo[v][Prix],
VehiculeInfo[v][Status],VehiculeInfo[v][Alarme],VehiculeInfo[v][Tuning1],VehiculeInfo[v][Tuning2],
VehiculeInfo[v][Tuning3],VehiculeInfo[v][Tuning4],VehiculeInfo[v][Tuning5],VehiculeInfo[v][Tuning6],
VehiculeInfo[v][Tuning7],VehiculeInfo[v][Tuning8],VehiculeInfo[v][Tuning9],VehiculeInfo[v][Tuning10],
VehiculeInfo[v][Tuning11],VehiculeInfo[v][Tuning12],VehiculeInfo[v][Tuning13],VehiculeInfo[v][Tuning14],
VehiculeInfo[v][Tuning15],VehiculeInfo[v][Tuning16],VehiculeInfo[v][Tuning17],VehiculeInfo[v][Peinture],
VehiculeInfo[v][MaxEssence],VehiculeInfo[v][Proprio],VehiculeInfo[v][Nom]
);
fwrite(VehFile, vehstring);
printf("---- Vehicule %d sauvegarder! ----",v);
}
}
fclose(VehFile);

#endif
}

Je remercie encore MrFredo pour son système de vehicule.


Merci d'avance de votre aide

Bonne journée a vous.
« Modifié: 09 Novembre 2012, 18:17:29 par Alakzam »