IsPlayerInVehicle
#1

ok so i'm making a feature when a player is inside a Police car and getting shot, his health should freezes because the cop car is bullet proof in real life


how can i make that?
Reply
#2

There are two ways.

Either change the health of the vehicle to a extrem high value

pawn Код:
SetVehicleHealth(vehicleid, 1000000);
https://sampwiki.blast.hk/wiki/SetVehicleHealth

or update vehicle health in OnPlayerUpdate callback.
pawn Код:
public OnPlayerUpdate(playerid)
{
    new vehicleId = GetPlayerVehicleID(playerid);
    if(vehicleId == YOUR_POLICE_VEHICLE ID)
    {
        SetVehicleHealth(vehicleId, 1000);
    }
}
Reply
#3

I think he means the player's health and not the vehicle's. You can use OnPlayerWeaponShot callback:
pawn Код:
// In OnPlayerWeaponShot:
if (hittype == BULLET_HIT_TYPE_PLAYER && 596 <= GetVehicleModel(GetPlayerVehicleID(hitid)) <= 599) return 0;
if the player that gets shot is inside LSPD, SFPD, LVPD or Police Ranger then the bullet will not be synced. For more things such as bullets from sea sparrow etc, you better use OnPlayerTakeDamage callback instead.
Reply
#4

No no, not the car health
The player health is the one i'm talking about because no matter what the car health is; when they shoot the player inside, the bullet reduces his HP
so how can i disable the damage when player is inside a cop car
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)