I am really out of ideas
#1

My mind is clustering at the moment trying to figure out how to make load vehicles. I would appreciate, if someone can help me out of this troublesome.

This is what my vehicle system currently.

pawn Код:
#define MAX_VEHICLES                                (1000)

enum cInfo
{
    model,
    Float: spawnX, Float: spawnY, Float: spawnZ, Float: spawnAngle,
    color1,
    color2,
    respawn,
    owner
}
new CI[MAX_VEHICLES][cInfo];

stock GetVehicleFreeSlot()
{
    for(new i = 0; i < sizeof(validcar); i++)
    {
        if(!validcar[i]) return i;
    }
    return -1;
}
stock CreateVehicleEx(modelid, Float:x, Float:y, Float:z, Float:angle, cl1, cl2, respawndelay, ownername[MAX_PLAYER_NAME])
{
    new carid = GetVehicleFreeSlot();
    CI[carid][model] = modelid;
    CI[carid][spawnX] = x;
    CI[carid][spawnY] = y;
    CI[carid][spawnZ] = z;
    CI[carid][spawnAngle] = angle;
    CI[carid][color1] = cl1;
    CI[carid][color2] = cl2;
    CI[carid][respawn] = respawndelay;
    CI[carid][owner] = ownername;
    validcar[carid] = true;
    CreateVehicle(modelid, x, y, z, angle, cl1, cl2, respawndelay);
    return carid;
}
stock SaveVehicle(vehicle)
{
    format(largestr, sizeof(largestr), "INSERT INTO `vehicles`(\
        `modelid`, \
        `x`, \
        `y`, \
        `z`, \
        `angle`, \
        `color1`, \
        `color2`, \
        `respawn`, \
        `owner` \
        ) VALUES (\
        %d, \
        %f, \
        %f, \
        %f, \
        %f, \
        %d, \
        %d, \
        %d, \
        '%s' \
        )"
,
        CI[vehicle][model],
        CI[vehicle][spawnX],
        CI[vehicle][spawnY],
        CI[vehicle][spawnZ],
        CI[vehicle][spawnAngle],
        CI[vehicle][color1],
        CI[vehicle][color2],
        CI[vehicle][respawn],
        CI[vehicle][owner]
    );
    mysql_query(largestr);
    mysql_free_result();
}
stock SaveAllVehicles()
{
    new saveindex = 0;
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        if(validcar[i])
        {
            SaveVehicle(i)
            saveindex++;
        }
    }
}
I couldn't figure out how to make the LoadVehicle as I cannot use my mind. Any help will be appreciated.
Reply
#2

eehm you got any errors with this? and i dont really understand you... can you explain some more of what you want? do you just want to let the vehicles load at the server start or somewhere else?
Reply
#3

Quote:
Originally Posted by niels44
Посмотреть сообщение
eehm you got any errors with this? and i dont really understand you... can you explain some more of what you want? do you just want to let the vehicles load at the server start or somewhere else?
After saving the vehicles he wants to know what code should he put to LoadVehicles?
Reply
#4

Quote:
Originally Posted by niels44
Посмотреть сообщение
eehm you got any errors with this? and i dont really understand you... can you explain some more of what you want? do you just want to let the vehicles load at the server start or somewhere else?
Quote:

I couldn't figure out how to make the LoadVehicle

I am finding a way to make LoadVehicle function.
Reply
#5

Want an example of my loadcars?

In onGameModeInit I have:

LoadCars();


and this somewhere in script:

pawn Код:
forward LoadCars();
public LoadCars()
{
    for(new i = 1; i < sizeof(CarInfo); i++)
    {
    format(file4,sizeof(file4), "realityrp/vehicles/%d.ini", i);
    if(fexist(file4))
    {
        CarInfo[i][model] = dini_Int(file4, "model");
        CarInfo[i][owner] = dini_Int(file4, "owner");
        CarInfo[i][forsale] = dini_Int(file4, "forsale");
        CarInfo[i][vehx] = dini_Int(file4, "vehx");
        CarInfo[i][vehy] = dini_Int(file4, "vehy");
        CarInfo[i][vehz] = dini_Int(file4, "vehz");
        CarInfo[i][rot] = dini_Int(file4, "rot");
        CarInfo[i][vcol1] = dini_Int(file4, "vcol1");
        CarInfo[i][vcol2] = dini_Int(file4, "vcol2");
        CarInfo[i][Carid] = dini_Int(file4, "Carid");
        Pcar = CreateVehicle(CarInfo[i][model],CarInfo[i][vehx],CarInfo[i][vehy],CarInfo[i][vehz],CarInfo[i][rot],CarInfo[i][vcol1],CarInfo[i][vcol2],30000000);
        vehown[Pcar] = CarInfo[i][owner];
        ispr[Pcar] = 1;
        }
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by milanosie
Посмотреть сообщение
Want an example of my loadcars?

In onGameModeInit I have:

LoadCars();


and this somewhere in script:

pawn Код:
forward LoadCars();
public LoadCars()
{
    for(new i = 1; i < sizeof(CarInfo); i++)
    {
    format(file4,sizeof(file4), "realityrp/vehicles/%d.ini", i);
    if(fexist(file4))
    {
        CarInfo[i][model] = dini_Int(file4, "model");
        CarInfo[i][owner] = dini_Int(file4, "owner");
        CarInfo[i][forsale] = dini_Int(file4, "forsale");
        CarInfo[i][vehx] = dini_Int(file4, "vehx");
        CarInfo[i][vehy] = dini_Int(file4, "vehy");
        CarInfo[i][vehz] = dini_Int(file4, "vehz");
        CarInfo[i][rot] = dini_Int(file4, "rot");
        CarInfo[i][vcol1] = dini_Int(file4, "vcol1");
        CarInfo[i][vcol2] = dini_Int(file4, "vcol2");
        CarInfo[i][Carid] = dini_Int(file4, "Carid");
        Pcar = CreateVehicle(CarInfo[i][model],CarInfo[i][vehx],CarInfo[i][vehy],CarInfo[i][vehz],CarInfo[i][rot],CarInfo[i][vcol1],CarInfo[i][vcol2],30000000);
        vehown[Pcar] = CarInfo[i][owner];
        ispr[Pcar] = 1;
        }
    }
    return 1;
}
Thanks but that didn't really helped much in MySQL.
Reply
#7

Have you tried anything so far so we can help you with it?
Reply
#8

Quote:
Originally Posted by Xtra Softs
Посмотреть сообщение
Have you tried anything so far so we can help you with it?
I really cannot think of something.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)