19.12.2011, 06:37
Function where to label is in:
Function with House_AddVehicle
pawn Code:
House_ReplaceVehicle(HouseID, CarSlot) // 263
{
// Setup local variables
new vid, cModel, cPaint, cComponents[14], Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2, Float:Health, cFuel;
new panels, doors, lights, tires;
// Get the data from the already existing vehicle that was parked before
vid = AHouseData[HouseID][VehicleIDs][CarSlot];
cModel = AVehicleData[vid][Model];
cPaint = AVehicleData[vid][PaintJob];
cFuel = AVehicleData[vid][Fuel];
for (new i; i < 14; i++)
cComponents[i] = AVehicleData[vid][Components][i];
Col1 = AVehicleData[vid][Color1];
Col2 = AVehicleData[vid][Color2];
cx = AVehicleData[vid][SpawnX];
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
if(_:AVehicleData[vid][ZaText] != 0) Delete3DTextLabel(AVehicleData[vid][ZaText]);
vid = House_AddVehicle(HouseID, cModel, cPaint, cComponents, cx, cy, cz, crot, Col1, Col2);
new string[50];
format(string, 50, "Owner: {77FF00}%s",AVehicleData[vid][Owner]);
AVehicleData[vid][ZaText] = Create3DTextLabel(string,0xFF0000FF,cx,cy,cz,40,1);
Attach3DTextLabelToVehicle(AVehicleData[vid][ZaText],vid,0.0,0.0,0.4);
// Update the fuel of the vehicle to the previous setting
AVehicleData[vid][Fuel] = cFuel;
// Update the health to what it was before and update the bodywork
SetVehicleHealth(vid, Health);
UpdateVehicleDamageStatus(vid, panels, doors, lights, tires);
return vid;
} //302
pawn Code:
House_AddVehicle(HouseID, cModel, cPaint, cComponents[], Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2) //203
{
// Setup local variables
new vid, CarSlot;
// Get a free carslot from the house
CarSlot = House_GetFreeCarSlot(HouseID);
// Check if there is a free carslot
if (CarSlot != -1)
{
// Create a new vehicle and get the vehicle-id
vid = CreateVehicle(cModel, cx, cy, cz, crot, Col1, Col2, 600);
// Store the vehicle-id in the house's free carslot
AHouseData[HouseID][VehicleIDs][CarSlot] = vid;
// Save the model of the vehicle
AVehicleData[vid][Model] = cModel;
// Save the paintjob of the vehicle and apply it
AVehicleData[vid][PaintJob] = cPaint;
if (cPaint != 0)
ChangeVehiclePaintjob(vid, cPaint - 1);
// Also update the car-color
ChangeVehicleColor(vid, Col1, Col2);
// Save the colors of the vehicle
AVehicleData[vid][Color1] = Col1;
AVehicleData[vid][Color2] = Col2;
// Save the components of the vehicle and apply them
for (new i; i < 14; i++)
{
AVehicleData[vid][Components][i] = cComponents[i];
// Check if the componentslot has a valid component-id
if (AVehicleData[vid][Components][i] != 0)
AddVehicleComponent(vid, AVehicleData[vid][Components][i]); // Add the component to the vehicle
}
// Save the spawn-data of the vehicle
AVehicleData[vid][SpawnX] = cx;
AVehicleData[vid][SpawnY] = cy;
AVehicleData[vid][SpawnZ] = cz;
AVehicleData[vid][SpawnRot] = crot;
// Also set the fuel to maximum
AVehicleData[vid][Fuel] = MaxFuel;
// Also set the owner
AVehicleData[vid][Owned] = true;
format(AVehicleData[vid][Owner], 24, AHouseData[HouseID][Owner]);
// Save the HouseID for the vehicle
AVehicleData[vid][BelongsToHouse] = HouseID;
}
else // No free carslot was found, return 0
return 0;
// Exit the function and return the vehicle-id
return vid;
} //260