Need help with car system -
ajwar - 28.12.2010
Now it's about 1 month working on vehicle system. When i load vehicles with sscanf from MYSQL every thing works fine and cars spawn's in server, but when i want to check if any car is locked i use enum variables, but enum is empty, it has no information longer. So that's my system i am working on:
pawn Код:
enum Cars
{
Id,
Owner[25],
Model,
Float:X,
Float:Y,
Float:Z,
Float:Angle,
Fuel,
Color1,
Color2,
Lock,
A,
tune0,
tune1,
tune2,
tune3,
tune4,
tune5,
tune6,
tune7,
tune8,
tune9,
tune10,
tune11,
tune12,
tune13,
Paintjob,
Data[20],
Name[20],
}
new vInfo[MAX_VEHICLES][Cars];
Then i load vehicles in OnGameModeInit with this stock:
pawn Код:
stock LoadVehicles()
{
new Query[256];
for(new id; id < MAX_VEHICLES; id++) // Makes an loop so all vehicles get loaded.
{
format(Query, sizeof(Query), "SELECT * FROM vehicles WHERE `ID`= '%d' LIMIT 1", id);
mysql_query(Query); // Querys the "Query" Variable.
mysql_store_result(); // Stores the result from Query
if(mysql_num_rows()) // Checks if theres anyrow.
if(mysql_fetch_row_format(Query,"|"))
{
sscanf(Query, "p<|>e<ds[25]dffffdddddddddddddddddddds[20]s[20]>",vInfo[id]);
new car = CreateVehicle(vInfo[id][Model],vInfo[id][X],vInfo[id][Y],vInfo[id][Z],vInfo[id][Angle],vInfo[id][Color1],vInfo[id][Color2], -1);
ChangeVehiclePaintjob(car,strval(vInfo[ id ][ Paintjob ]));
AddVehicleComponent(car,vInfo[ id ][ tune0 ]);
AddVehicleComponent(car,vInfo[ id ][ tune1 ]);
AddVehicleComponent(car,vInfo[ id ][ tune2 ]);
AddVehicleComponent(car,vInfo[ id ][ tune3 ]);
AddVehicleComponent(car,vInfo[ id ][ tune4 ]);
AddVehicleComponent(car,vInfo[ id ][ tune5 ]);
AddVehicleComponent(car,vInfo[ id ][ tune6 ]);
AddVehicleComponent(car,vInfo[ id ][ tune7 ]);
AddVehicleComponent(car,vInfo[ id ][ tune8 ]);
AddVehicleComponent(car,vInfo[ id ][ tune9 ]);
AddVehicleComponent(car,vInfo[ id ][ tune10 ]);
AddVehicleComponent(car,vInfo[ id ][ tune11 ]);
AddVehicleComponent(car,vInfo[ id ][ tune12 ]);
AddVehicleComponent(car,vInfo[ id ][ tune13 ]);
}
}
}
So, until here it's no problem, but now when i want to check if the car is locked in OnPlayerEnterVehicle Enum has no information. I try to do so:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
printf(vInfo[ vehicleid ][ Locked ]);
printf(vInfo[ vehicleid ][ X ]);
printf(vInfo[ vehicleid ][ Y ]);
printf(vInfo[ vehicleid ][ Z ]);
}
This returns:
0
0.00000
0.00000
0.00000.
Any suggestions ?
Re: Need help with car system -
ajwar - 04.01.2011
Anyone can suggest anything?
Re: Need help with car system -
[BFT]eagles22 - 05.01.2011
i see you lock under you vInfo enum, im assuming that what you are trying to do is to check if the vehicle is locked. I cannot tell exactly what you are asking, but if that is what you are asking you would have to put something like this.
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new vid = GetPlayerVehicleID(playerid);
if(vInfo[vid][Lock] == 1);
{
printf("Vehicle Locked");
}
else
{
printf("Vehicle Unlocked");
}
return 1;
}
than you would have to make a /lock command to set the vInfo[vid][Lock] = 1
and than an /unlock command to set it to 0.
Again im not sure if this is what you were asking for so if it is i hope i helped, if not, please try to clearify a little more on what you are asking for.