11.02.2014, 14:15
I am sorry.
House_ReplaceVehicle:
House_AddVehicle:
House_ReplaceVehicle:
pawn Код:
House_ReplaceVehicle(HouseID, CarSlot, playerid)
{
new vid, cModel, Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2, Float:Health, cFuel, _CarID, cComponents[14];
new panels, doors, lights, tires;
vid = AHouseData[HouseID][VehicleIDs][CarSlot];
_CarID = AVehicleData[vid][SaveID];
cModel = AVehicleData[vid][CarModel];
cFuel = AVehicleData[vid][FuelData];
Col1 = AVehicleData[vid][Color1];
Col2 = AVehicleData[vid][Color2];
cx = AVehicleData[vid][SpawnX];
for (new i; i < 14; i++)
cComponents[i] = GetVehicleComponentInSlot(vid, i);
printf("%s", cComponents);
cy = AVehicleData[vid][SpawnY];
cz = AVehicleData[vid][SpawnZ];
crot = AVehicleData[vid][SpawnRot];
GetVehicleHealth(vid, Health);
GetVehicleDamageStatus(vid, panels, doors, lights, tires);
// Delete the vehicle and clear the data
Vehicle_Delete(vid);
// Create a new vehicle in the same carslot
vid = House_AddVehicle(HouseID, cModel, Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2, _CarID, playerid, cComponents);
// Update the fuel of the vehicle to the previous setting
AVehicleData[vid][FuelData] = cFuel;
// Update the health to what it was before and update the bodywork
SetVehicleHealth(vid, Health);
UpdateVehicleDamageStatus(vid, panels, doors, lights, tires);
return vid;
}
pawn Код:
House_AddVehicle(HouseID, cModel, Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2, CarID, playerid, cComponents[])
{
new vid, CarSlot, pName[MAX_PLAYER_NAME], string[126], modelid, a[14];//, string2[128];
GetPlayerName(playerid, pName, sizeof(pName));
CarSlot = House_GetFreeCarSlot(HouseID);
printf("House_AddVehicle::CarSlot = %d", CarSlot);
if (CarSlot != -1)
{
vid = Vehicle_Create(cModel, cx, cy, cz, crot, Col2, Col1, 600);
printf("House_AddVehicle::vid= %d", vid);
AHouseData[HouseID][VehicleIDs][CarSlot] = vid;
printf("House_AddVehicle::AHouseData[%d][VehicleIDs][%d]= %d", HouseID, CarSlot, AHouseData[HouseID][VehicleIDs][CarSlot]);
AVehicleData[vid][CarModel] = cModel;
AVehicleData[AHouseData[HouseID][VehicleIDs][CarSlot]][SaveID] = CarID;
// Save the spawn-data of the vehicle
AVehicleData[vid][SpawnX] = cx;
AVehicleData[vid][SpawnY] = cy;
AVehicleData[vid][SpawnZ] = cz;
AVehicleData[vid][SpawnRot] = crot;
AVehicleData[vid][Color1] = Col2;
AVehicleData[vid][Color2] = Col1;
sscanf(cComponents, "p<,>a<i>[14]", a);
for (new s; s != 14; ++s)
{
// AVehicleData[vid][Components][s] = cComponents[s];
if (cComponents[s]) AddVehicleComponent(vid, cComponents[s]);
}
// Apply the given parameters to the vehicle
AVehicleData[vid][FuelData] = MaxFuel;
AVehicleData[vid][Owned] = true;
ChangeVehicleColor(vid, AVehicleData[vid][Color1], AVehicleData[vid][Color2]);
format(AVehicleData[vid][Owner], 24, pName);
AVehicleData[vid][BelongsToHouse] = HouseID;
modelid = GetVehicleModel(vid);
format(string, sizeof(string), "%s's %s", pName, VehicleNames2[modelid-400]);
VehText[vid] = Create3DTextLabel(string,0xFFFFFFFF,0,0,0,100.0,0);
Attach3DTextLabelToVehicle(VehText[vid], vid, 0,0,0);
print("Vehicle loaded");
}
else
{
print ("No free carslot");// No free carslot was found, return 0
return 0;
}
// Exit the function and return the vehicle-id
return vid;
}