06.08.2011, 12:35
Well, I'm using this code to try to access information from my database to spawn vehicles:
On one vehicle, is the stats like this:
ID: 2
MODEL: 596
Color 1: 1
Color 2: 1
X: 1558.734619
Y: -1711.563110
Z: 5.611854
ZAngle: 0.445877
Owner: 0
Ownertype: 2
Health: 1000.0000
Panels: 0
Doors: 0
Lights: 0
Tires: 0
Siren: 1
Faction: 1
But, it returns different values on some. What I have figured this far (wrong values marked with red):
ID: 2
MODEL: 596
Color 1: 1
Color 2: 1
X: 1558.734619
Y: -1711.563110
Z: 5.611854
ZAngle: 0.445877
Owner: 0
Ownertype: 0
Health: 1000.0000
Panels: 0
Doors: 0
Lights: 0
Tires: 0
Siren: 0
Faction: 0
Does anyone know what I may do with this problem?
EDIT:
Adding the enum stuff:
pawn Код:
InitVehicles(){
for (new i = 0; i < MAX_VEHICLES; i++)
{
new Query[200];
format(Query, sizeof(Query), "SELECT * FROM `vehicles` WHERE `id` = '%d'", i);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() != 0){
new line[1500];
if(mysql_fetch_row(line))
{
sscanf(line, "p|ddddffffsdfdddddd", Vehicle[i][vID], Vehicle[i][Model], Vehicle[i][Color1], Vehicle[i][Color2], Vehicle[i][X], Vehicle[i][Y],
Vehicle[i][Z], Vehicle[i][ZAngle], Vehicle[i][Owner], Vehicle[i][OwnerType], Vehicle[i][Health], Vehicle[i][Panels],
Vehicle[i][Doors], Vehicle[i][Lights], Vehicle[i][Tires], Vehicle[i][Siren], Vehicle[i][vFaction]); //Splits the line with sscanf
Vehicle[i][GameID] = AddStaticVehicleEx(Vehicle[i][Model], Vehicle[i][X], Vehicle[i][Y], Vehicle[i][Z], Vehicle[i][ZAngle], Vehicle[i][Color1], Vehicle[i][Color2], 3600);
Vehicle[i][SirenOn] = 0;
if(Vehicle[i][OwnerType] > 0)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(Vehicle[i][GameID], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(Vehicle[i][GameID], engine, lights, alarm, 1, bonnet, boot, objective);
}
printf("InitVehicles: Vehicle %d was spawned from the database. Ownertype: %d, Faction: %d", i, Vehicle[i][OwnerType], Vehicle[i][vFaction]);
}
}
mysql_free_result();
}
return 1;
}
ID: 2
MODEL: 596
Color 1: 1
Color 2: 1
X: 1558.734619
Y: -1711.563110
Z: 5.611854
ZAngle: 0.445877
Owner: 0
Ownertype: 2
Health: 1000.0000
Panels: 0
Doors: 0
Lights: 0
Tires: 0
Siren: 1
Faction: 1
But, it returns different values on some. What I have figured this far (wrong values marked with red):
ID: 2
MODEL: 596
Color 1: 1
Color 2: 1
X: 1558.734619
Y: -1711.563110
Z: 5.611854
ZAngle: 0.445877
Owner: 0
Ownertype: 0
Health: 1000.0000
Panels: 0
Doors: 0
Lights: 0
Tires: 0
Siren: 0
Faction: 0
Does anyone know what I may do with this problem?
EDIT:
Adding the enum stuff:
pawn Код:
enum VehicleStatistics{
vID,
Model,
Color1,
Color2,
Float:X,
Float:Y,
Float:Z,
Float:ZAngle,
Owner[24],
OwnerType,
GameID,
Float:Health,
Panels,
Doors,
Lights,
Tires,
Siren,
SirenOn,
Siren1,
Siren2,
Siren3,
vFaction,
};
new Vehicle[MAX_VEHICLES][VehicleStatistics];

