Vehicles.
#1

Hello, I have the following code under OnGameModeInit and it loads EVERY owned vehicle in one.

How could I make it possible that it only loads the owned vehicle per player when they connect and when they disconnect, it deletes them?

Here:

pawn Код:
stock LoadOwnedVehicles()
{
    new
        Query[1024],
        vModel2,
        vC[2],
        vPrice2,
        vOwner2[MAX_PLAYER_NAME],
        Float:Pos[4],
        vID,
        PlateNum[32],
        vPaint_Job,
        vLock,
        vMoney,
        vMats,
        vCocaine,
        vMoonshine,
        CarFuel;

    mysql_query("SELECT * FROM `OwnedVehicles` WHERE `OwnedVehicleID` < "#MAX_BUYABLE_VEH" ORDER BY OwnedVehicleID");
    mysql_store_result();

    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(Query))
        {
            sscanf(Query, "p<|>iiiiis[24]ffffs[32]iiiiiii",
            vID, vModel2, vC[0], vC[1], vPrice2, vOwner2, Pos[0], Pos[1], Pos[2], Pos[3], PlateNum, vPaint_Job,
             vLock, vMoney, vMats, vCocaine, vMoonshine, CarFuel);

            Vehicles[vID][vModel] = vModel2;
            Vehicles[vID][vColor1] = vC[0];
            Vehicles[vID][vColor2] = vC[1];
            Vehicles[vID][vPrice] = vPrice2;
            strmid(Vehicles[vID][VehicleOwner], vOwner2, 0, 24, 24);
            Vehicles[vID][vPosX] = Pos[0];
            Vehicles[vID][vPosY] = Pos[1];
            Vehicles[vID][vPosZ] = Pos[2];
            Vehicles[vID][vPosA] = Pos[3];
            strmid(Vehicles[vID][VehiclePlate], PlateNum, 0, 32, 32);
            Vehicles[vID][VehiclePaintJob] = vPaint_Job;
            Vehicles[vID][vLocked] = vLock;
            Vehicles[vID][vTrunkMoney] = vMoney;
            Vehicles[vID][vTrunkMats] = vMats;
            Vehicles[vID][vTrunkCocaine] = vCocaine;
            Vehicles[vID][vTrunkMoonshine] = vMoonshine;
            Vehicles[vID][vFuel] = CarFuel;
           
            if(Vehicles[vID][vLocked] == 1)
            {
                SetVehicleParamsEx(vID, 0, 0, 0, 1, 0, 0, 0);
            }

            new
                vCarID = CreateVehicle(Vehicles[vID][vModel], Vehicles[vID][vPosX], Vehicles[vID][vPosY], Vehicles[vID][vPosZ], Vehicles[vID][vPosA], Vehicles[vID][vColor1], Vehicles[vID][vColor2], 500000);
            SetVehicleNumberPlate(vCarID, Vehicles[vID][VehiclePlate]);
            ChangeVehiclePaintjob(vCarID, Vehicles[vID][VehiclePaintJob]);

            OwnedCar(vCarID) = vID;

            ++ TotalVehiclesCreated;
        }
    }
    mysql_free_result();
    printf("%d owned vehicles loaded from the MySQL Database.", TotalVehiclesCreated);

    return TotalVehiclesCreated;
}
Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)