Check player in car - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Check player in car (
/showthread.php?tid=253282)
Check player in car -
Swiftz - 05.05.2011
Ok how can check which players are there in particular vehicle id and set their hp to zero? Thanks in advance
Re: Check player in car -
xir - 05.05.2011
pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == id) return SetPlayerHealth(playerid, 0);
return 1;
}
Re: Check player in car -
Seven_of_Nine - 05.05.2011
You want to make like with... tanks? xD
Re: Check player in car -
[NoV]LaZ - 05.05.2011
xir's code will kill the player if the player is too close to the vehicle, not when the player is in the vehicle. Use OnPlayerStateChange for that. It's more realistic to check when the player has sat inside the vehicle.
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if ((newstate == PLAYER_STATE_DRIVER) && (oldstate == PLAYER_STATE_ONFOOT))
{
if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 432) // Tank's vehicle model id is 432
{
SetPlayerHealth(playerid, 0);
}
}
}
Re: Check player in car -
xir - 05.05.2011
It would not kill the player if it was near the vehicle, it would kill the player right when the player pressed enter.
But yeah OnPlayerStateChange is more realistic as you said
Re: Check player in car -
Swiftz - 06.05.2011
No, Thats not what i want, Actually it kills a player when he enters the car, But i made a command of bomb in car, So when bomb is activated, the car which bomb is placed is stored in a variable say carbomb(vehicleid), So i need to check if any player is there inside the car when the bomb is activated, I never did this , Is there any way to do?