checking the health of all vehicles
#1

hi,

how can i check the health of all vehicles in game and eject the player when the health of the vehicle goes lower than 250?
Should i use a timer? If yes, pls show me an example how to check it.

thx
Reply
#2

Instead of looping through the vehicles, loop through the players instead. Check if they're in a vehicle, and if they are check the health of that vehicle. You will need a timer of course. A 1 or 2 second delay would probably work.
Reply
#3

thx
i know about the timer and the loop but how would i perform the check?
Could u please show it to me in an example where the player gets ejected from the vehicle when the health of his car is lower than 250?

please
Reply
#4

pawn Код:
foreach(Player, i)
{
    if(IsPlayerInAnyVehicle(i))
    {
        new iVehicle, Float: iHealth;
        iVehicle = GetPlayerVehicleID(i);
        GetVehicleHealth(iVehicle, iHealth);

        if(iHealth <= 250)
        {
            // Eject the player here
            Ban(i); // :D
        }
    }
}
Reply
#5

thx alot
Reply
#6

You didn't put the ban part in did you? :O lol
Reply
#7

ofc not
thx.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)