IsPlayerInVehicle - 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: IsPlayerInVehicle (
/showthread.php?tid=607030)
IsPlayerInVehicle -
D3vin - 13.05.2016
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?
Re: IsPlayerInVehicle -
Skimmer - 13.05.2016
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);
}
}
Re: IsPlayerInVehicle -
Konstantinos - 13.05.2016
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.
Re: IsPlayerInVehicle -
D3vin - 13.05.2016
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