SA-MP Forums Archive
Global vehicles health problem - 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: Global vehicles health problem (/showthread.php?tid=385151)



Global vehicles health problem - Face9000 - 14.10.2012

Hello,i've this code to set at 980.0 the vehicles hp (all vehicles):

pawn Код:
forward SetVehicleHealthEx(vehicleid,Float:vHealth);

public SetVehicleHealthEx(vehicleid,Float:vHealth)
    return SetVehicleHealth(vehicleid,vHealth);

public OnVehicleSpawn(vehicleid)
{
    SetTimerEx("SetVehicleHealthEx",500,false,"df",vehicleid,980.0);
    return 1;
}
But it doesn't work, the vehicles hp are at 1000 instead of 980.


Re: Global vehicles health problem - Jensen - 14.10.2012

PHP код:
This callback is called when a vehicle respawns
https://sampwiki.blast.hk/wiki/OnVehicleSpawn


Re: Global vehicles health problem - Calabresi - 14.10.2012

You need to use foreach for that.

Код:
foreach (vid : Vehicle)
{
   SetVehicleHealth(vid, 980.0);
}
Add this in OnGameModeInit.


Re: Global vehicles health problem - Niko_boy - 14.10.2012

no that would only work for one time afaik
that is under OnGameModeInt after that if vehicle died and respawned it will have 1000 health

Edit: may be do that when player enter vehicle ? or no nvm


Re: Global vehicles health problem - Calabresi - 14.10.2012

Quote:
Originally Posted by Niko_boy
Посмотреть сообщение
no that would only work for one time afaik
that is under OnGameModeInt after that if vehicle died and respawned it will have 1000 health
Adding it to OnVehicleSpawn aswell will solve it.


Re: Global vehicles health problem - Face9000 - 14.10.2012

I've already at OnVehicleSpawn and doesn't work.

EDIT: Fixed,thanks.