It gives the code related to the VID.
Code:
SetupVehicleTable()
{
new query[200];
strcat(query, "CREATE TABLE IF NOT EXISTS `vehicles` ( \
`vehicle_id` int(11) NOT NULL AUTO_INCREMENT, \
`vehicle_model` int(11) default '0', \
PRIMARY KEY (`vehicle_id`))");
mysql_tquery(g_SQL, query);
return 1;
}
enum vInfo
{
vID,
vModel,
Text3D:vLabel,
};
new VehicleInfo[MAX_VEHICLES][vInfo];
new Veh[MAX_VEHICLES];
CreateVehicleCV(model, price, Float:posx, Float:posy, Float:posz, Float:posa, color1, color2)
{
new id, query[300], str[150];
VehicleInfo[id][vID] = CreateVehicle(model, posx, posy, posz, posa, color1, color2, -1);
Veh[VehicleInfo[id][vID]] = id;
VehicleInfo[id][vModel] = model;
SetVehicleToRespawn(VehicleInfo[id][vID]);
format(query, sizeof(query), "INSERT INTO `vehicles` (`vehicle_id`, `vehicle_model`) VALUES ('%d', '%d')", id, model);
mysql_tquery(g_SQL, query);
format(str, sizeof(str), "%s (UID: %d)", GetVehicleNameFromModel(VehicleInfo[id][vModel]), VehicleInfo[id][vID]);
VehicleInfo[id][vLabel] = Create3DTextLabel(str, -1, 0.0, 0.0, 0.0, 50.0, 0);
Attach3DTextLabelToVehicle(VehicleInfo[id][vLabel], VehicleInfo[id][vID], 0.0, 0.0, 1.0);
return VehicleInfo[id][vID];
}
SaveVehicle(xvehid)
{
new query[200];
mysql_format(g_SQL, query, sizeof query, "UPDATE `vehicles` SET `vehicle_model` = %d WHERE `vehicle_id` = %d LIMIT 1", VehicleInfo[xvehid][vModel], xvehid);
mysql_tquery(g_SQL, query);
return 1;
}
forward LoadVehicle();
public LoadVehicle()
{
new rows = cache_num_rows();
new id, loaded;
new str[150];
if(rows)
{
while(loaded < rows)
{
cache_get_value_name_int(loaded, "vehicle_id", id);
cache_get_value_name_int(loaded, "vehicle_model", VehicleInfo[id][vModel]);
VehicleInfo[id][vID] = CreateVehicle(VehicleInfo[id][vModel], 0.0, 0.0, 0.0, 0.0, -1, -1, -1);
Veh[VehicleInfo[id][vID]] = id;
SetVehicleToRespawn(VehicleInfo[id][vID]);
loaded++;
format(str, sizeof(str), "%s (UID: %d)", GetVehicleNameFromModel(VehicleInfo[id][vModel]), VehicleInfo[id][vID]);
VehicleInfo[id][vLabel] = Create3DTextLabel(str, -1, 0.0, 0.0, 0.0, 50.0, 0);
Attach3DTextLabelToVehicle(VehicleInfo[id][vLabel], VehicleInfo[id][vID], 0.0, 0.0, 1.0);
}
}
printf("%d loaded vehicles.", loaded);
return 1;
}
case 777:
{
if(response)
{
new veh, xid;
veh = CreateVehicleCV(VehicleInfo[xid][vModel], strval(inputtext), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
xid = Veh[veh];
PutPlayerInVehicle(playerid, veh, 0);
new str[50];
format(str, sizeof(str), "UID: %d", VehicleInfo[xid][vID]);
SendClientMessage(playerid, -1, str);
}
}
}