if SetVehicleHealth?
#1

I would like to; If the car health is <400 the player got RemovePlayerFromVehicle....How?
Reply
#2

pawn Код:
new Float:health;
GetVehicleHealth(GetPlayerVehicleID(playerid), health);
if(health < 400.0) RemovePlayerFromVehicle(playerid);
Reply
#3

Under what Callback should i Add this?
Reply
#4

Quote:
Originally Posted by Gooday
Посмотреть сообщение
Under what Callback should i Add this?
You want that for every player and every car?
Reply
#5

You can add it OnPlayerUpdate or you can just create a timer
Reply
#6

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
You want that for every player and every car?
Except the players with skin 50.... And all the cars
Reply
#7

Alright. Then you need a timer to put at OnGameModeInit/OnFilterScriptInit (Depending on if you use a GM or FS).
pawn Код:
SetTimer("CheckHealth", 1000, 1); //Timer which gets called every second
And then you have to add at the bottom of your GM/FS:
pawn Код:
forward CheckHealth();
public CheckHealth()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerInAnyVehicle(i) && GetPlayerSkin(i) != 50)
        {
            new Float:health;
            GetVehicleHealth(GetPlayerVehicleID(i), health));
            if(health < 400.0)
            {
                RemovePlayerFromVehicle(i);
                SendClientMessage(i, COLOR_BLUE, "[Vehicle] You were removed from your vehicle because it had less than 400 health points.");
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)