Personalized health of the vehicles
#1

I'm doing a 'survival' mode in which the map will have cars. My question is: How can I make the health of the cars be '50%', and the health of the other cars be '110%'?

I already placed the cars on the map, and the health of all the vehicles is '100' by default, but I want them to have a personalized health.
Reply
#2

https://sampwiki.blast.hk/wiki/SetVehicleHealth

Be sure to read the wiki. How are the vehicles spawned on the server first off?
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
SetVehicleHealth

And the default is 1000, not 100.
'1000' when there is no one inside the vehicle and '100' when a player gets on it, am I wrong?

Quote:
Originally Posted by Damian
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/SetVehicleHealth

Be sure to read the wiki. How are the vehicles spawned on the server first off?
PHP код:
AddStaticVehicleEx(522378.12692527.147016.0750200.0000, -1, -1600);
AddStaticVehicleEx(522376.68872527.214816.0750200.0000, -1, -1600);
AddStaticVehicleEx(522375.04602527.214816.0750200.0000, -1, -1600);
AddStaticVehicleEx(522373.34092527.178516.0750200.0000, -1, -1600);
AddStaticVehicleEx(522371.44342527.274416.0750200.0000, -1, -1600);
AddStaticVehicleEx(522405.88752527.347916.0750200.0000, -1, -1600);
AddStaticVehicleEx(522404.40442527.307416.0750200.0000, -1, -1600);
AddStaticVehicleEx(522402.92372527.325716.0750200.0000, -1, -1600);
AddStaticVehicleEx(522401.35742527.207816.0750200.0000, -1, -1600);
AddStaticVehicleEx(557363.99232532.186516.8347180.0000, -1, -1600);
AddStaticVehicleEx(557363.94952538.871816.8347180.0000, -1, -1600);
AddStaticVehicleEx(557363.91652545.262516.8347180.0000, -1, -1600);
AddStaticVehicleEx(411381.22272480.518616.219420.8200, -1, -1600);
//And more 
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
AddStaticVehicleEx returns an ID, use that in SetVehicleHealth.
You mean this?

PHP код:
new vehiclesid[2];
vehiclesid[0] = AddStaticVehicleEx(522378.12692527.147016.0750200.0000, -1, -1600);
vehiclesid[1] = AddStaticVehicleEx(522376.68872527.214816.0750200.0000, -1, -1600);
SetVehicleHealth(vehiclesid[0], 50.0);
SetVehicleHealth(vehiclesid[1], 110.0); 
Reply
#5

I’m on the phone so excuse me but you’d need to do.

new _vehicleid;
_vehicleid = AddStaticVehicle()
SetVehicleHealth( _vehicleid, 1000.0 )
_vehicleid = AddStaticVehicle

So on and so on. I suggest you read around the wiki more to find more conventional ways of doing it.
Reply
#6

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?
Reply
#7

Quote:
Originally Posted by Volumen
Посмотреть сообщение
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?
Nope. Which is why I suggested you read the wiki. You’re going to need to incorporate OnVehicleSpawn. Don’t let us tell you how to do it. Read and trial & errors.
Reply
#8

I'm using this "https://sampforum.blast.hk/showthread.php?tid=648101" editor, and the cars are added like this:

PHP код:
new g_Object[2];
new 
g_Vehicle[2];
g_Object[0] = CreateObject(18646, -1973.4848725.119946.24670.00000.0000, -90.2997); //PoliceLight1
g_Object[1]= CreateObject(18646, -1942.7042723.632046.08060.00000.0000, -91.9000); //PoliceLight1
g_Vehicle[0] = CreateVehicle(490, -1975.2310723.728245.6867, -90.299700, -1); //FBI Rancher
g_Vehicle[1] = CreateVehicle(490, -1996.2443704.942445.6868, -0.099800, -1); //FBI Rancher
AttachObjectToVehicle(g_Object[0], g_Vehicle[1], 0.00001.73980.55980.00000.00000.0000);
AttachObjectToVehicle(g_Object[1g_Vehicle[1], 0.00001.21990.25000.00000.00000.0000); 
Is it wrong to do so or is it simply the same?
Reply
#9

Quote:
Originally Posted by ******
Посмотреть сообщение
That is not where the cars are created.
What do you mean?

EDIT: You mean I must do everything this way?

PHP код:
new _vehicleidg_Object
//1
_vehicleid CreateVehicle(597, -1610.5964651.78848.05040.000001, -1);
g_Object CreateObject(18646, -1958.4755724.290248.72860.00000.00000.0000);
AttachObjectToVehicle(g_Object_vehicleid0.00001.73980.55980.00000.00000.0000);
//2
_vehicleid CreateVehicle(597, -1610.5964651.78848.05040.000001, -1);
g_Object CreateObject(18646, -1958.4755724.290248.72860.00000.00000.0000);
AttachObjectToVehicle(g_Object_vehicleid0.00001.73980.55980.00000.00000.0000);
//3
_vehicleid CreateVehicle(597, -1610.5964651.78848.05040.000001, -1);
g_Object CreateObject(18646, -1958.4755724.290248.72860.00000.00000.0000);
AttachObjectToVehicle(g_Object_vehicleid0.00001.73980.55980.00000.00000.0000); 
Reply
#10

You mean do something like this?

PHP код:
enum Example_Enum
{
    
Model,
    
Float:PX,
    
Float:PY,
    
Float:PZ,
    
Float:ANGLE,
    
COLOR1,
    
COLOR2
};
new 
Example[][Example_Enum] =
{
    {
4201783.2333, -1932.496513.05180.0000, -1, -1},
    {
4381775.7085, -1916.046313.27720.0000, -1, -1},
    {
4201805.3810, -1917.465813.11950.0000, -1, -1}
}; 
PHP код:
//OnGameModeInit
for(new 0!= sizeof Example++)
{
    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], 200false);
    if(
vehicleid  == INVALID_VEHICLE_ID) continue;

Reply
#11

I have '195' created cars and of those cars, only '7' have a health of "200" and a police object placed. Do you recommend placing in the function only the cars that have the objects placed and personal health, or place the 195 cars? Thanks you.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)