29.09.2012, 06:06
pawn Код:
stock AddVehicle(Carid, Carmodel, Carcolor1, Carcolor2, Float:Carx, Float:Cary, Float:Carz, Float:Cara, CarCost, CarSell)
{
new data[256], query[400];
format(query, sizeof(query), "SELECT * FROM `vehicles` WHERE CarID = '%d';", Carid);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() > 0)
{
mysql_fetch_field("CarID", data);
VehicleSystem[Carid][CarID] = strval(data);
mysql_fetch_field("Model", data);
VehicleSystem[Carid][Model] = strval(data);
mysql_fetch_field("Locked", data);
VehicleSystem[Carid][Locked] = strval(data);
mysql_fetch_field("CarX", data);
VehicleSystem[Carid][CarX] = strval(data);
mysql_fetch_field("CarY", data);
VehicleSystem[Carid][CarY] = strval(data);
mysql_fetch_field("CarZ",data);
VehicleSystem[Carid][CarZ]=strval(data);
mysql_fetch_field("CarA",data);
VehicleSystem[Carid][CarA]=strval(data);
mysql_fetch_field("Color1",data);
VehicleSystem[Carid][Color1]=strval(data);
mysql_fetch_field("Color2",data);
VehicleSystem[Carid][Color2]=strval(data);
mysql_fetch_field("Price",data);
VehicleSystem[Carid][Price]=strval(data);
mysql_fetch_field("Sell",data);
VehicleSystem[Carid][Sell]=strval(data);
mysql_fetch_field("Owner",data);
strmid(VehicleSystem[Carid][Owner],data,0,20,20);
new carr = CreateVehicle(VehicleSystem[Carid][Model],VehicleSystem[Carid][Carx],VehicleSystem[Carid][Cary],VehicleSystem[Carid][Carz]+5,VehicleSystem[Carid][Cara],VehicleSystem[Carid][Color1],VehicleSystem[Carid][Color2],600000);
IsBuyableCar[carr]=Carid;
}
else
{
printf("");
printf(" ::::::::::::::::::::::: Car Created :::::::::::::::::::::::");
printf("");
VehicleSystem[Carid][CarID] = Carid;
VehicleSystem[Carid][Model] = Carmodel;
VehicleSystem[Carid][Locked] = 0;
VehicleSystem[Carid][CarX] = CarX;
VehicleSystem[Carid][CarY] = CarY;
VehicleSystem[Carid][CarZ] = CarZ;
VehicleSystem[Carid][CarA] = CarA;
VehicleSystem[Carid][Color1] = Carcolor1;
VehicleSystem[Carid][Color2] = Carcolor2;
VehicleSystem[Carid][Price] = CarCost;
VehicleSystem[Carid][Sell] = CarSell;
strmid(VehicleSystem[Carid][Owner], "Unbought", 0, 20, 20);
format(query, sizeof(query),"INSERT INTO `vehicles` (`CarID` ,`Model` ,`Locked` ,`CarX` ,`CarY` ,`CarZ` ,`CarA` ,`Color1` ,`Color2` ,`Price` ,`Sell` ,`Owner`) VALUES ('%d', '%d', '0', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%d', 'Unbought');",Carid, Carmodel, Carx, Cary, Carz, Cara, Carcolor1, Carcolor2, CarCost, CarSell);
mysql_query(query);
new Carr = CreateVehicle(VehicleSystem[Carid][Model], VehicleSystem[Carid][CarX], VehicleSystem[Carid][CarY], VehicleSystem[Carid][CarZ] + 5, VehicleSystem[Carid][CarA], VehicleSystem[Carid][Color1], VehicleSystem[Carid][Color2], 600000);
IsBuyableCar[Carr] = Carid;
}
mysql_free_result();
return 1;
}