SA-MP Forums Archive
Car HP - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Car HP (/showthread.php?tid=70962)



Car HP - sanandreas - 28.03.2009

Hi all,
I have this problem with this code. I want the code to get the cars health so that when the car is about to blow up they get a message and they get kicked out of the car.
Код:
 Above OnGameModeInit
forward Carhp(playerid, vehicleid);
new car;

public Carhp(playerid, vehicleid)
{
  car = GetPlayerVehicleID(playerid);
	new Float:vehhp = GetVehicleHealth(car,vehhp);
	if(vehhp <= 250)
	{
	SendClientMessage(playerid,COLOR_BLUE,"GET OUT!");
       RemovePlayerFromVehicle(playerid);
	}
	return 1;
}
Thx for all help


Re: Car HP - BMUK - 29.03.2009

pawn Код:
SetTimer("Carhp",1000,1);
pawn Код:
public Carhp()
{
  for(new i=0; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerInAnyVehicle(i))
    {
      new Float:chealth;
      GetVehicleHealth(GetPlayerVehicleID(i),chealth);
           
      if(chealth <= 250)
      {
        SendClientMessage(i,COLOR_BLUE,"GET OUT!");
        RemovePlayerFromVehicle(i);
      }
    }
  }
}



Re: Car HP - sanandreas - 29.03.2009

Thx so much bro