21.01.2011, 20:11
Another thing that I just could not set up right is the ID which my system store in each vehicle's stats.
This is my LoadVhicles function which gets called OnGameModeInit:
It loads all the vehicles as I want, but something goes wrong with my "VehicleID". There is my enum:
My /getcarid whitch shows me wrong info:
It doesn't show me the right information, for example there is no carid 0 in my server, whitch I just don't understand how is that possible.. Its like everything the command shows is +1, the server vehicle id, and the stats loaded from the database, for example if I enter into my first spawned vehicle witch is ID 4 in my database(and the next vehicle's ID is 7), and the server vehicle ID should be 0, it shows me that the server vehicle id is 1(Instead of 0), and the database vehicle ID is 7(the next one in the list).
Can somebody help me fix this problem? I've been trying for a few hours without any luck.
This is my LoadVhicles function which gets called OnGameModeInit:
pawn Код:
LoadVehicles()
{
totalVehicles = 0;
mysql_query("SELECT * FROM `Vehicles`");
mysql_store_result();
if(mysql_num_rows() > 0)
{
while(mysql_fetch_row(Query))
{
sscanf(Query, "e<p<|>ddffffddddds[10]d>", Vehicles[totalVehicles]);
SetVehicleNumberPlate(CreateVehicle(Vehicles[totalVehicles][Model],Vehicles[totalVehicles][PosX],Vehicles[totalVehicles][PosY],Vehicles[totalVehicles][PosZ],Vehicles[totalVehicles][Angle],Vehicles[totalVehicles][Color1],Vehicles[totalVehicles][Color2], -1), Vehicles[totalVehicles][Plate]);
LinkVehicleToInterior(totalVehicles, 0);
SetVehicleVirtualWorld(totalVehicles, 0);
totalVehicles++;
}
}
mysql_free_result();
print("\n");
printf("SERVER: Loaded %d MySQL vehicles successfully.", totalVehicles);
return 1;
}
pawn Код:
enum VehicleData
{
VehicleID,
Model,
Float: PosX,
Float: PosY,
Float: PosZ,
Float: Angle,
Color1,
Color2,
IsOwned,
OwnerID,
Faction,
Plate,
Locked
};
new Vehicles[MAX_VEHICLES][VehicleData];
new totalVehicles = 0;
pawn Код:
command(getcarid, playerid, params[])
{
#pragma unused params
if(!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, COLOR_BRIGHTRED, "You are not in a vehicle, nothing was gotten!");
new id = GetPlayerVehicleID(playerid);
format(Query, sizeof(Query), "Server Vehicle ID: %d, Database Vehicle ID: %d", id, Vehicles[id][VehicleID]);
SendClientMessage(playerid, COLOR_BRIGHTRED, Query);
return 1;
}
Can somebody help me fix this problem? I've been trying for a few hours without any luck.