Vehicle health
#1

How can I change the vehicle health? like LSPD car got 1000 and I want change it to 2500 How can I do that? Im using this command for Factions vehicles :
pawn Код:
LSPDVehicles[0] = AddStaticVehicleEx(596,1602.0660,-1683.9678,5.6124,90.3080,0,1, VEHICLE_RESPAWN); // Cruiser
If someone know how to set the health vehicle please edit the code the give me
Reply
#2

make a loop and add something like this inside it:
Код:
SetVehicleHealth(LSPDVehicles[i], 2500);
Reply
#3

use OnVehicleSpawn and SetVehicleHealth
Reply
#4

Quote:
Originally Posted by dominik523
Посмотреть сообщение
make a loop and add something like this inside it:
Код:
SetVehicleHealth(LSPDVehicles[i], 2500);
This is not working..

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
I dont know how..
Reply
#5

pawn Код:
public OnVehicleSpawn(vehicleid)
{
    for(new i; i < MAX_VEHICLES; i ++) // creating a loop through all vehicles
    {
        if(vehicleid == LSPDVehicles[i])
        {
        SetVehicleHealth(vehicleid,2500);
        }// for each LSPD vehicle set vehicle health to 2500 as you want!
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by SilentSoul
Посмотреть сообщение
pawn Код:
public OnVehicleSpawn(vehicleid)
{
    for(new i; i < MAX_VEHICLES; i ++) // creating a loop through all vehicles
    {
        if(vehicleid == LSPDVehicles[i])
        {
        SetVehicleHealth(vehicleid,2500);
        }// for each LSPD vehicle set vehicle health to 2500 as you want!
    }
    return 1;
}
Thanks its working !
And if i want to do it for private vehicle I need to do this :
pawn Код:
public OnVehicleSpawn(vehicleid)
{
    for(new i; i < MAX_VEHICLES; i ++) // creating a loop through all vehicles
    {
        if(vehicleid == 470[i])
        {
        SetVehicleHealth(vehicleid,2500);
        }// for each LSPD vehicle set vehicle health to 2500 as you want!
    }
    return 1;
}
470 its the ID of patriot
Reply
#7

pawn Код:
public OnVehicleSpawn(vehicleid)
{
    for(new i; i < MAX_VEHICLES; i ++) // creating a loop through all vehicles
    {
        if(GetVehicleModel(vehicleid[i]) == 470)
        {
            SetVehicleHealth(vehicleid[i], 2500);
        }// for each LSPD vehicle set vehicle health to 2500 as you want!
    }
    return 1;
}
Reply
#8

Ya set all the vehicles to 2500 when anyone of them respawns that makes sense.
Reply
#9

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Ya set all the vehicles to 2500 when anyone of them respawns that makes sense.
I was about to say the same.

If a COP vehicle gets seriously damaged, then another COP vehicle spawn, all cop vehicles will magically repair.

So, the correct is when the vehicle spawns, set just its health

pawn Код:
public OnVehicleSpawn(vehicleid)
{
        if(GetVehicleModel(vehicleid[i]) == 470)
        {
            SetVehicleHealth(vehicleid[i], 2500);
        }
    return 1;
}
But OnVehicleSpawn will only get called when a vehicle RE-SPAWNS (Not when the vehicle gets created)

Now the loop will make sense...

pawn Код:
// AddStaticVehicle...
// AddStaticVehicle...
// AddStaticVehicle...

for(new i; i < MAX_VEHICLES; i ++) // creating a loop through all vehicles
{
    if(GetVehicleModel(vehicleid[i]) == 470)
    {
        SetVehicleHealth(vehicleid[i], 2500);
    }// for each LSPD vehicle set vehicle health to 2500 as you want!
}
Reply
#10

Quote:
Originally Posted by arakuta
Посмотреть сообщение
I was about to say the same.

If a COP vehicle gets seriously damaged, then another COP vehicle spawn, all cop vehicles will magically repair.

So, the correct is when the vehicle spawns, set just its health

pawn Код:
public OnVehicleSpawn(vehicleid)
{
        if(GetVehicleModel(vehicleid[i]) == 470)
        {
            SetVehicleHealth(vehicleid[i], 2500);
        }
    return 1;
}
But OnVehicleSpawn will only get called when a vehicle RE-SPAWNS (Not when the vehicle gets created)

Now the loop will make sense...

pawn Код:
// AddStaticVehicle...
// AddStaticVehicle...
// AddStaticVehicle...

for(new i; i < MAX_VEHICLES; i ++) // creating a loop through all vehicles
{
    if(GetVehicleModel(vehicleid[i]) == 470)
    {
        SetVehicleHealth(vehicleid[i], 2500);
    }// for each LSPD vehicle set vehicle health to 2500 as you want!
}
I'm using this code for the factions vehicles
pawn Код:
for(new i; i < MAX_VEHICLES; i ++) // creating a loop through all vehicles
    {
        if(vehicleid == LSPDVehicles[i])
        {
        SetVehicleHealth(vehicleid,2500);
        }// for each LSPD vehicle set vehicle health to 2500 as you want!
    }
    for(new i; i < MAX_VEHICLES; i ++) // creating a loop through all vehicles
    {
        if(vehicleid == FBIVehicles[i])
        {
        SetVehicleHealth(vehicleid,2500);
        }// for each LSPD vehicle set vehicle health to 2500 as you want!
    }
But the one with LSPDVehicles works but the FBIVehicles doennt work maybe do you know why?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)