08.04.2014, 16:01
Sorry, I think you may have mistaken how it works.
The variable that holds CreateVehicle(); can be anything, however it doesn't make the vehicle owned by the player.
To make the vehicle owned by player, you need to add the vehicle details to the vehicle enum.
so it would look like this
Then when you call the load information, you need to stick it in the enum with the player information.
Hopefully this should help,
There is an issue to why you are limiting the amount of queries being retrieved by the query?
You have limited it to 15? that means there will only be 15 vehicles loaded in to the server, whether they are owned by one or 2 people.
The variable that holds CreateVehicle(); can be anything, however it doesn't make the vehicle owned by the player.
To make the vehicle owned by player, you need to add the vehicle details to the vehicle enum.
so it would look like this
pawn Код:
enum pVehicles
{
vID,
vOwner[24],
vModel,
vColor[2],
Float:vPos[4],
vLocked
}
new PlayerVehicles[MAX_PLAYERS][pVehicles];
pawn Код:
stock CreateVehicles()
{
new CQuery[200];
//--------------------------------------------------------------------------
format(CQuery, sizeof(CQuery), "SELECT * FROM `Cars` ORDER BY `ID` DESC LIMIT 15");
Result = db_query(Database, CQuery);
//--------------------------------------------------------------------------
for(new i; i < db_num_rows(Result); i++)
{
new vehid, vehModel, vehOwner[30], Float:vehPos[4], vehColor[2];
//----------------------------------------------------------------------
db_get_field_assoc(Result, "CarOwner", vehOwner, 30);
db_get_field_assoc(Result, "CarID", vehid, 30);
// You Need To Add A Vehicle Model Here //
db_get_field_assoc(Result, "CarModel", vehModel, 30);
// Above This //
db_get_field_assoc(Result, "CarPosX", vehPos[0], 30);
db_get_field_assoc(Result, "CarPosY", vehPos[1], 30);
db_get_field_assoc(Result, "CarPosZ", vehPos[2], 30);
db_get_field_assoc(Result, "color1", vehColor[0], 30);
db_get_field_assoc(Result, "color2", vehColor[1], 30);
PlayerVehicles[i][vModel] = vehModel;
PlayerVehicles[i][vOwner] = vehOwner;
PlayerVehicles[i][vColor][0] = vehColor[0];
PlayerVehicles[i][vColor][1] = vehColor[1];
PlayerVehicles[i][vPos][0] = vehPos[0];
PlayerVehicles[i][vPos][1] = vehPos[1];
PlayerVehicles[i][vPos][2] = vehPos[2];
PlayerVehicles[i][vPos][3] = vehPos[3];
PlayerVehicles[i][vLocked] = 0; // Change This Depending on your settings //
//----------------------------------------------------------------------
PlayerVehicles[i][vID] = CreateVehicle(vehModel, vehPos[0], vehPos[1], vehPos[2], vehPos[3], vehColor[0], vehColor[1], -1);
//----------------------------------------------------------------------
db_next_row(Result);
}
db_free_result(Result);
return 1;
}
There is an issue to why you are limiting the amount of queries being retrieved by the query?
You have limited it to 15? that means there will only be 15 vehicles loaded in to the server, whether they are owned by one or 2 people.