Switcharoo sampVehicle ID and mysqlVehicleID?
#1

Okay, I know you're probably sick of seeing my fails around by now already, but I'm having this trouble... and have been the past 2/3 days.

So, the command I'm having trouble with is vehid (To acquire the current player vehicle ID. **THIS WILL ALLOW ME TO DELETE THE VEHICLE FROM THE TABLE AND DestroyVehicle(vehicleid);**).

pawn Код:
CMD:vehid(playerid, params[])
{
    //new msg[156];
    new vID;
    if(pInfo[playerid][pAdmin] < 1) return ErrorMessage(playerid, "You're not authorized to use this command!");
    if(!IsPlayerInAnyVehicle(playerid)) return ErrorMessage(playerid, "You must be in a vehicle to use this command! (HINT : Find THIS Vehicle ID).");

    vID = GetPlayerVehicleID(playerid);
    printf("sampVehicleID : %i = %i", vID, Vehicle[vID]); // THIS NEEDS TO RETURN [EXAMPLE] - sampVehicleID : 2 = mysqlVehicleID : 4
                                                          // THE REAL RETURN AT THE MOMENT IS - sampVehicleID : 2 = mysqlVehicleID : 65556
                                                          // Because it's really doing sampVehicleID : 2 = Vehicle[2] (Whereas, it's saved in Vehicle[4]?)
    return 1;
}
pawn Код:
public CreateVeh(model, Float:X, Float:Y, Float:Z, Float:F, colour1, colour2, playerid)
{
    new qString[512];
    for(new i = 1; i < sizeof(Vehicle); i++)
    {
        if(Vehicle[i] == INVALID_VEHICLE_ID)
        {
            vInfo[i][vModel] = model;
            vInfo[i][vPosX] = X;
            vInfo[i][vPosY] = Y;
            vInfo[i][vPosZ] = Z;
            vInfo[i][vAngle] = F;
            vInfo[i][vColour1] = colour1;
            vInfo[i][vColour2] = colour2;

            mysql_format(mysql, qString, sizeof(qString), "INSERT INTO `vehicles` (`Model`, `posX`, `posY`, `posZ`, `Angle`, `Colour1`, `Colour2`) VALUES ('%i', '%f', '%f', '%f', '%f', '%i', '%i')", vInfo[i][vModel], vInfo[i][vPosX], vInfo[i][vPosY], vInfo[i][vPosZ], vInfo[i][vAngle], vInfo[i][vColour1], vInfo[i][vColour2]);
            mysql_tquery(mysql, qString, "OnVehicleCreate", "i", i);
            break;
         }
    }
    return 1;
}

public OnVehicleCreate(vehicleid, playerid)
{
    new qString[512];
   
    vInfo[vehicleid][ID] = cache_insert_id();

    mysql_format(mysql, qString, sizeof(qString), "SELECT * FROM `vehicles` WHERE `ID` = '%i'", vInfo[vehicleid][ID]);
    mysql_tquery(mysql, qString, "LoadVehicle", "i", vInfo[vehicleid][ID]);
    return 1;
}

public LoadVehicles()
{
    for(new i = 1; i < sizeof(vInfo); i++)
    {
        new qString[512];
        mysql_format(mysql, qString, sizeof(qString), "SELECT * FROM `vehicles` WHERE `ID` = '%i'", i);
        mysql_tquery(mysql, qString, "LoadVehicle", "i", i);
 }
    return 1;
}
public LoadVehicle(vehicleid)
{
    new rows, fields;
    cache_get_data(rows, fields, mysql);

    vInfo[vehicleid][ID] = cache_get_row_int(0, 0);
    vInfo[vehicleid][vModel] = cache_get_row_int(0, 1);
    vInfo[vehicleid][vPosX] = cache_get_row_float(0, 2);
    vInfo[vehicleid][vPosY] = cache_get_row_float(0, 3);
    vInfo[vehicleid][vPosZ] = cache_get_row_float(0, 4);
    vInfo[vehicleid][vAngle] = cache_get_row_float(0, 5);
    vInfo[vehicleid][vColour1] = cache_get_row_int(0, 6);
    vInfo[vehicleid][vColour2] = cache_get_row_int(0, 7);

    Vehicle[vehicleid] = CreateVehicle(vInfo[vehicleid][vModel], vInfo[vehicleid][vPosX], vInfo[vehicleid][vPosY], vInfo[vehicleid][vPosZ], vInfo[vehicleid][vAngle], vInfo[vehicleid][vColour1], vInfo[vehicleid][vColour2], 500000);

    SetVehicleToRespawn(vehicleid);

    if(Vehicle[vehicleid] != INVALID_VEHICLE_ID)
    {
        printf("-> Loading Vehicle ID: %i", vehicleid);
       
        printf("------> %i = %i", Vehicle[vehicleid], vInfo[vehicleid][ID]); //------> sampVehicle ID = mysqlVehicle ID
        //This is where it is  Vehicle[4], vInfo[4][ID] = ------> sampVehicle 2 = mysqlVehicle 4
        //I want it to be this Vehicle[2], vInfo[2][ID] = ------> sampVehicle 2 = mysqlVehicle 4
    }
    return 1;
}



Sorry if I haven't explained what I need properly again... I'm terrible writing explanations down, much better talking it over on voice.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)