Custom Vehicle health
#1

So im trying to make all vehicles armoured vehicles used by law enforcers in my server health be more than 1000, now i made this code but its not working could someone tell me where i go wrong.. If you are posting a reply please ensure to explain it because im not only posting for the help but posting to learn as well..

PHP код:
for(new 0<= MAX_VEHICLESi++)
    {
        if(
IsValidVehicle(i))
        {
            new 
vehm GetVehicleModel(i);
            if(
vehm == 427 || vehm == 470 || vehm == 447)
            {
                
SetVehicleHealth(i2500.0);
            }
        }
    } 
Reply
#2

Where do you use this code?
Reply
#3

Quote:
Originally Posted by DarkSkull
Посмотреть сообщение
Where do you use this code?
Ongamemodeinit and onvehiclespawn
Reply
#4

You must run that code after you load/create the vehicles. Keep in mind that vehicle ids start at 1, not 0, so:
PHP код:
/* OnGameModeInit */
AddStaticVehicle(...);
AddStaticVehicle(...);
for(new 
1GetVehiclePoolSize(); <= ti++) 
{
    new 
v_model GetVehicleModel(i);
    if(
v_model == 427 || v_model == 470 || v_model == 447
    {
        
SetVehicleHealth(i2500.0); 
    }

PHP код:
/* OnVehicleSpawn */
new v_model GetVehicleModel(vehicleid);
if(
v_model == 427 || v_model == 470 || v_model == 447
{
    
SetVehicleHealth(vehicleid2500.0); 

You can skip IsValidVehicle because GetVehicleModel returns 0 if the vehicle doesn't exist.
Reply
#5

Quote:
Originally Posted by RIDE2DAY
Посмотреть сообщение
You must run that code after you load/create the vehicles. Keep in mind that vehicle ids start at 1, not 0, so:
PHP код:
/* OnGameModeInit */
AddStaticVehicle(...);
AddStaticVehicle(...);
for(new 
1GetVehiclePoolSize(); <= ti++) 
{
    new 
v_model GetVehicleModel(i);
    if(
v_model == 427 || v_model == 470 || v_model == 447
    {
        
SetVehicleHealth(i2500.0); 
    }

PHP код:
/* OnVehicleSpawn */
new v_model GetVehicleModel(vehicleid);
if(
v_model == 427 || v_model == 470 || v_model == 447
{
    
SetVehicleHealth(vehicleid2500.0); 

You can skip IsValidVehicle because GetVehicleModel returns 0 if the vehicle doesn't exist.
Do i have to use addstaticvehicle, cause for my scripts i used CreateVehicle
Reply
#6

No, It can be CreateVehicle as well.
Reply
#7

Quote:
Originally Posted by DarkSkull
Посмотреть сообщение
No, It can be CreateVehicle as well.
Its not working
Reply
#8

bump
Reply
#9

You shouldn't check by model because eventually it's gonna catch up on you, you should check by vehicle ids instead.
Reply
#10

Are you sure that the code Ride2Day gave you is run after all the vehicles are loaded in?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)