Global vehicles health problem
#1

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.
Reply
#2

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

You need to use foreach for that.

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

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

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.
Reply
#6

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

EDIT: Fixed,thanks.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)