Multiple Cars per 'Character'
#1

Title says it all. The gamemode I'm developing has a Masteraccount and characters integrated with it. So, Yeah well. I need multiple Vehicles Per Character. I'll start step by step.

The define having the Maximum car Slots Per character.
pawn Код:
#define     MAX_CARSLOTS    3
The Enumerator having all the vehicles within Characters.
pawn Код:
enum OwnedCarSlot
{
    id,
    bool:loaded
}
new OwnedVehicle[MAX_PLAYERS][MAX_CARSLOTS][OwnedCarSlot];

So, After the Player has Chosen a character and Spawned. The System is supposed to spawn All The 3 Vehicles owned by him. Using this.
pawn Код:
mysql_format(handle, query, sizeof(query), "SELECT * FROM `Vehicles` WHERE `vOwner`='%e'", name);
mysql_tquery(handle, query, "SpawnPlayerVehicle", "i", playerid);
under SpawnPlayervehicle(playerid), I'm spawning the vehicles loaded at Loadvehicle. i.e Above ^
pawn Код:
new rows, fields;
    cache_get_data(rows, fields);
    if(rows) //If the player was found when LoadVehicle() was called
    {
        for(new i; i != MAX_CARSLOTS-1; i++) //-1 because 0 ,1, 2;
        {
            // Spawn the vehicle here.....
               // What am I supposed to do here? It creates the vehicles, but I need help assigning them to the enum I   mentioned above.
//After getting the cache,
VehicleInfo[playerid][vActualID] = CreateVehicle(VehicleInfo[playerid][vModel], VehicleInfo[playerid][vX], VehicleInfo[playerid][vY], VehicleInfo[playerid][vZ], VehicleInfo[playerid][vA], VehicleInfo[playerid][vColor1], VehicleInfo[playerid][vColor2], -1);
Reply
#2

Dang.
Reply
#3

Simply do a loop through the number of rows retrieved and assign the arrays.
pawn Код:
//Once the data is retrieved, loop through the rows:
for(new i = 0; i< rows i++)
{
    VehicleInfo[playerid][i][id] = CreateVehicle(...); // I assume "id" is supposed to store the vehicle ID, so store it.
    VehicleInfo[playerid][i][loaded] = true; //Once if things are done, set "loaded" boolean to true.
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)