https://sampwiki.blast.hk/wiki/SetVehicleHealth
Be sure to read the wiki. How are the vehicles spawned on the server first off? |
AddStaticVehicleEx(522, 378.1269, 2527.1470, 16.0750, 200.0000, -1, -1, 600);
AddStaticVehicleEx(522, 376.6887, 2527.2148, 16.0750, 200.0000, -1, -1, 600);
AddStaticVehicleEx(522, 375.0460, 2527.2148, 16.0750, 200.0000, -1, -1, 600);
AddStaticVehicleEx(522, 373.3409, 2527.1785, 16.0750, 200.0000, -1, -1, 600);
AddStaticVehicleEx(522, 371.4434, 2527.2744, 16.0750, 200.0000, -1, -1, 600);
AddStaticVehicleEx(522, 405.8875, 2527.3479, 16.0750, 200.0000, -1, -1, 600);
AddStaticVehicleEx(522, 404.4044, 2527.3074, 16.0750, 200.0000, -1, -1, 600);
AddStaticVehicleEx(522, 402.9237, 2527.3257, 16.0750, 200.0000, -1, -1, 600);
AddStaticVehicleEx(522, 401.3574, 2527.2078, 16.0750, 200.0000, -1, -1, 600);
AddStaticVehicleEx(557, 363.9923, 2532.1865, 16.8347, 180.0000, -1, -1, 600);
AddStaticVehicleEx(557, 363.9495, 2538.8718, 16.8347, 180.0000, -1, -1, 600);
AddStaticVehicleEx(557, 363.9165, 2545.2625, 16.8347, 180.0000, -1, -1, 600);
AddStaticVehicleEx(411, 381.2227, 2480.5186, 16.2194, 20.8200, -1, -1, 600);
//And more
new vehiclesid[2];
vehiclesid[0] = AddStaticVehicleEx(522, 378.1269, 2527.1470, 16.0750, 200.0000, -1, -1, 600);
vehiclesid[1] = AddStaticVehicleEx(522, 376.6887, 2527.2148, 16.0750, 200.0000, -1, -1, 600);
SetVehicleHealth(vehiclesid[0], 50.0);
SetVehicleHealth(vehiclesid[1], 110.0);
Ok, it's fine. But when one of the vehicles reappears or simply destroys (explodes) it will have the same health that was placed in 'OnGameModeInit?
|
new g_Object[2];
new g_Vehicle[2];
g_Object[0] = CreateObject(18646, -1973.4848, 725.1199, 46.2467, 0.0000, 0.0000, -90.2997); //PoliceLight1
g_Object[1]= CreateObject(18646, -1942.7042, 723.6320, 46.0806, 0.0000, 0.0000, -91.9000); //PoliceLight1
g_Vehicle[0] = CreateVehicle(490, -1975.2310, 723.7282, 45.6867, -90.2997, 0, 0, -1); //FBI Rancher
g_Vehicle[1] = CreateVehicle(490, -1996.2443, 704.9424, 45.6868, -0.0998, 0, 0, -1); //FBI Rancher
AttachObjectToVehicle(g_Object[0], g_Vehicle[1], 0.0000, 1.7398, 0.5598, 0.0000, 0.0000, 0.0000);
AttachObjectToVehicle(g_Object[1, g_Vehicle[1], 0.0000, 1.2199, 0.2500, 0.0000, 0.0000, 0.0000);
new _vehicleid, g_Object;
//1
_vehicleid = CreateVehicle(597, -1610.5964, 651.7884, 8.0504, 0.0000, 0, 1, -1);
g_Object = CreateObject(18646, -1958.4755, 724.2902, 48.7286, 0.0000, 0.0000, 0.0000);
AttachObjectToVehicle(g_Object, _vehicleid, 0.0000, 1.7398, 0.5598, 0.0000, 0.0000, 0.0000);
//2
_vehicleid = CreateVehicle(597, -1610.5964, 651.7884, 8.0504, 0.0000, 0, 1, -1);
g_Object = CreateObject(18646, -1958.4755, 724.2902, 48.7286, 0.0000, 0.0000, 0.0000);
AttachObjectToVehicle(g_Object, _vehicleid, 0.0000, 1.7398, 0.5598, 0.0000, 0.0000, 0.0000);
//3
_vehicleid = CreateVehicle(597, -1610.5964, 651.7884, 8.0504, 0.0000, 0, 1, -1);
g_Object = CreateObject(18646, -1958.4755, 724.2902, 48.7286, 0.0000, 0.0000, 0.0000);
AttachObjectToVehicle(g_Object, _vehicleid, 0.0000, 1.7398, 0.5598, 0.0000, 0.0000, 0.0000);
enum Example_Enum
{
Model,
Float:PX,
Float:PY,
Float:PZ,
Float:ANGLE,
COLOR1,
COLOR2
};
new Example[][Example_Enum] =
{
{420, 1783.2333, -1932.4965, 13.0518, 0.0000, -1, -1},
{438, 1775.7085, -1916.0463, 13.2772, 0.0000, -1, -1},
{420, 1805.3810, -1917.4658, 13.1195, 0.0000, -1, -1}
};
//OnGameModeInit
for(new i = 0; i != sizeof Example; i ++)
{
new vehicleid = INVALID_VEHICLE_ID_
vehicleid = CreateVehicle(Example[i][Model], Example[i][PX], Example[i][PY], Example[i][PZ], Example[i][ANGLE], Example[i][COLOR1], Example[i][COLOR2], 200, false);
if(vehicleid == INVALID_VEHICLE_ID) continue;
}