Vehicle health - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vehicle health (
/showthread.php?tid=480752)
Vehicle health -
Dorlevi1506 - 12.12.2013
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
Re: Vehicle health -
dominik523 - 12.12.2013
make a loop and add something like this inside it:
Код:
SetVehicleHealth(LSPDVehicles[i], 2500);
Re: Vehicle health -
xVIP3Rx - 12.12.2013
use
OnVehicleSpawn and
SetVehicleHealth
Re: Vehicle health -
Dorlevi1506 - 12.12.2013
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..
Re: Vehicle health -
SilentSoul - 12.12.2013
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;
}
Re: Vehicle health -
Dorlevi1506 - 12.12.2013
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
Re: Vehicle health -
Loot - 12.12.2013
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;
}
Re: Vehicle health -
Pottus - 12.12.2013
Ya set all the vehicles to 2500 when anyone of them respawns that makes sense.
Re: Vehicle health -
arakuta - 12.12.2013
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!
}
Re: Vehicle health -
Dorlevi1506 - 12.12.2013
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?