SA-MP Forums Archive
checking the health of all vehicles - 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: checking the health of all vehicles (/showthread.php?tid=300362)



checking the health of all vehicles - PawnoQ - 29.11.2011

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


Re: checking the health of all vehicles - Vince - 29.11.2011

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.


Re: checking the health of all vehicles - PawnoQ - 29.11.2011

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


Re: checking the health of all vehicles - [L3th4l] - 29.11.2011

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
        }
    }
}



Re: checking the health of all vehicles - PawnoQ - 29.11.2011

thx alot


Re: checking the health of all vehicles - Thresholdold - 30.11.2011

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


Re: checking the health of all vehicles - PawnoQ - 30.11.2011

ofc not
thx.