[AJUDA] Veiculos VIPS
#5

o loop, й para pegar todos os veiculos da pasta scriptfiles....

TOPO
pawn Код:
enum cInfo
{
    cModel,
    Float:cLocationx,
    Float:cLocationy,
    Float:cLocationz,
    Float:cAngle,
    cColorOne,
    cColorTwo,
    cOwner[MAX_PLAYER_NAME],
    cDescription[MAX_PLAYER_NAME],
    cValue,
    cLicense,
    cOwned,
    cLock,
    ownedvehicle,
    Float:lx,
    Float:ly,
    Float:lz,
    Float:langle,
    cGrana,
    cID,
};
pawn Код:
new CarInfo[50][cInfo];
pawn Код:
public OnGameModeInit()
{
        LoadCar();
        for(new i = 1; i < sizeof(CarInfo); i++)
    {
        CarInfo[i][ownedvehicle] = AddStaticVehicleEx(CarInfo[i][cModel],CarInfo[i][cLocationx],CarInfo[i][cLocationy],CarInfo[i][cLocationz],CarInfo[i][cAngle],CarInfo[i][cColorOne],CarInfo[i][cColorTwo],-1);
        //SetVehicleToRespawn(CarInfo[i][ownedvehicle]);
    }
PARA CARREGAR E SALVAR OS CARROS VIPS
pawn Код:
forward LoadCar();
public LoadCar()
{
    new arrCoords[14][64];
    new strFromFile2[256];
    new File: file = fopen("Configs/Carros.cfg", io_read);
    if (file)
    {
        new idx = 1;
        while (idx < sizeof(CarInfo))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, ',');
            CarInfo[idx][cModel] = strval(arrCoords[0]);
            CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
            CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
            CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
            CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
            CarInfo[idx][cColorOne] = strval(arrCoords[5]);
            CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
            strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
            strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
            CarInfo[idx][cValue] = strval(arrCoords[9]);
            CarInfo[idx][cLicense] = strval(arrCoords[10]);
            CarInfo[idx][cOwned] = strval(arrCoords[11]);
            CarInfo[idx][cLock] = strval(arrCoords[12]);
            CarInfo[idx][cGrana] = strval(arrCoords[13]);
            CarInfo[idx][cID] = totalveiculosc+idx;
            //printf("Carro: %d Dono:%s[%d] LicensePlate %s ID[%d]",idx,CarInfo[idx][cOwner],CarInfo[idx][cOwned],CarInfo[idx][cLicense],CarInfo[idx][cID]);
            idx++;
        }
        printf(" %d Carros Carregados", idx);
    }
    return true;
}
forward SaveCars();
public SaveCars()
{
    new idx;
    new File: file2;
    while (idx < sizeof(CarInfo))
    {
        new coordsstring[256];
        format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d,%d\n",
        CarInfo[idx][cModel],
        CarInfo[idx][cLocationx],
        CarInfo[idx][cLocationy],
        CarInfo[idx][cLocationz],
        CarInfo[idx][cAngle],
        CarInfo[idx][cColorOne],
        CarInfo[idx][cColorTwo],
        CarInfo[idx][cOwner],
        CarInfo[idx][cDescription],
        CarInfo[idx][cValue],
        CarInfo[idx][cLicense],
        CarInfo[idx][cOwned],
        CarInfo[idx][cLock],
        CarInfo[idx][cGrana]);
        if(idx == 1)
        {
            file2 = fopen("Configs/Carros.cfg", io_write);
        }
        else
        {
            file2 = fopen("Configs/Carros.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}
O que poderia ser ?
Reply


Messages In This Thread
[AJUDA] Veiculos VIPS - by EditPawn - 01.06.2012, 20:12
Re: [AJUDA] Veiculos VIPS - by leonardo1434 - 01.06.2012, 22:45
Re: [AJUDA] Veiculos VIPS - by EditPawn - 02.06.2012, 02:28
Re: [AJUDA] Veiculos VIPS - by leonardo1434 - 02.06.2012, 09:09
Re: [AJUDA] Veiculos VIPS - by EditPawn - 02.06.2012, 14:56
Re: [AJUDA] Veiculos VIPS - by leonardo1434 - 02.06.2012, 18:27
Re: [AJUDA] Veiculos VIPS - by EditPawn - 02.06.2012, 18:31
Re: [AJUDA] Veiculos VIPS - by EditPawn - 02.06.2012, 20:36
Re: [AJUDA] Veiculos VIPS - by leonardo1434 - 02.06.2012, 20:43
Re: [AJUDA] Veiculos VIPS - by EditPawn - 02.06.2012, 20:47

Forum Jump:


Users browsing this thread: 2 Guest(s)