Код:
YCMD:createvehicle(playerid, params[], help)
{
new Float: Pos[3], Float: Angle, string[256], szQuery[500], modelid, color[2], cv_factionid;
if(PlayerInfo[playerid][pAdmin] < 6) return 1;
if(sscanf(params, "iiii", modelid, color[0], color[1], cv_factionid)) return SCM(playerid, COLOR_WHITE, "{008080}USAGE: {FFFFFF}/createvehicle <model> <color1> <color2> <factionid>");
if(400 <= modelid >= 611) return SCM(playerid, COLOR_GREY, "Invalid vehicle id. (400 - 611)");
if(!(0 <= color[0] <= 255 && 0 <= color[1] <= 255)) return SCM(playerid, COLOR_GREY, "Invalid color id. (0 - 255)");
if(IsPlayerInAnyVehicle(playerid)) return 1;
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Angle);
new carid = GetServerVehicles()+1;
ServerVehicles[carid][vSpawned] = CreateVehicle(modelid, Pos[0], Pos[1], Pos[2], Angle, color[0], color[1], -1);
SetVehicleNumberPlate(ServerVehicles[carid][vSpawned], "NewCar");
PutPlayerInVehicleEx(playerid, ServerVehicles[carid][vSpawned], 0);
ServerVehicles[carid][vID] = carid;
ServerVehicles[carid][vModel] = modelid;
ServerVehicles[carid][vLocation][0] = Pos[0];
ServerVehicles[carid][vLocation][1] = Pos[1];
ServerVehicles[carid][vLocation][2] = Pos[2];
ServerVehicles[carid][vAngle] = Angle;
ServerVehicles[carid][vColor][0] = color[0];
ServerVehicles[carid][vColor][1] = color[1];
ServerVehicles[carid][vFaction] = cv_factionid;
if(ServerVehicles[carid][vFaction] != 0) {
if(ServerVehicles[carid][vModel] == 411) {
new policecar = CreateObject(19327, 1534.2373, -1643.2886, 5.9373, -87.6999, 90.4001, -87.1805);
SetObjectMaterialText(policecar, "POLICE", 0, 50, "Arial", 25, 1, -16777216, 0, 1);
new lspdcar = CreateObject(19419,0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000);
AttachObjectToVehicle(policecar, carid, 0.0, -1.9, 0.3, 270.0, 0.0, 0.0);
AttachObjectToVehicle(lspdcar, carid, 0.0646, 0.1661, 0.6957, 0.0000, 0.0000, 0.0000);
}
if(ServerVehicles[carid][vModel] == 560) {
if(ServerVehicles[carid][vFaction] == 12 || ServerVehicles[carid][vFaction] == 13) {
new tacaridiobj = CreateObject(19308, 0.00000, 0.00000, 0.00000,0.00000, 0.00000, 0.00000);
AttachObjectToVehicle(tacaridiobj, carid, -0.00930, -0.23880, 0.92300,0.00000, 0.00000, 0.00000);
}
}
if(ServerVehicles[carid][vModel] == 541) {
if(ServerVehicles[carid][vFaction] == 2) {
new object1 = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
new object2 = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(object1, carid, 0.375000,0.524999,0.375000,0.000000,0.000000,0.000000);
AttachObjectToVehicle(object2, carid, 0.375000,0.524999,0.375000,0.000000,0.000000,0.000000);
}
}
if(ServerVehicles[carid][vModel] == 525) {
new object1 = CreateObject(19294, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
new object2 = CreateObject(19294, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(object1, carid, -0.600000,-0.485000,1.450000,0.000000,0.000000,0.000000);
AttachObjectToVehicle(object2, carid, 0.600000,-0.485000,1.450000,0.000000,0.000000,0.000000);
}
}
mysql_format(SQL, szQuery, sizeof(szQuery),
"INSERT INTO `svehicles` (vID, vModel, LocationX, LocationY, LocationZ, Angle, Color1, Color2) VALUES ('%d', '%d', '%f', '%f', '%f', '%f', '%d', '%d')", carid, modelid, Pos[0], Pos[1], Pos[2], ServerVehicles[carid][vAngle], color[0], color[1]);
mysql_query(SQL, szQuery);
format(string, sizeof(string), "Ai creat cu succes un %s (vID: %d).", aVehicleNames[modelid - 400], carid);
SCM(playerid, COLOR_LGREEN, string);
format(string, sizeof(string), "Acesta a fost adaugat cu succes in baza de date iar acum sunt in total %d vehicule!", GetServerVehicles());
SCM(playerid, COLOR_LGREEN, string);
SCM(playerid, COLOR_LGREEN, "Daca vrei sa modifici acest vehicul, foloseste comanda /editvehicle.");
return 1;
}