how can i detect passagers? - 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: how can i detect passagers? (
/showthread.php?tid=463648)
how can i detect passagers? -
Kapone21 - 13.09.2013
pawn Код:
new carid = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid) && !IsAnOwnableCar(carid))
{
SetVehicleToRespawn(carid);
}
How can i make if the car don't have passagers to respawn

?
Re: how can i detect passagers? -
Konstantinos - 13.09.2013
How to check if there's any passenger in that vehicle?
pawn Код:
stock IsVehicleOccupiedWithPassengers( vehicleid )
{
for( new i = 0; i < MAX_PLAYERS; i++ )
{
if( !IsPlayerConnected( i ) ) continue;
if( IsPlayerInVehicle( i, vehicleid ) && GetPlayerState( i ) == PLAYER_STATE_PASSENGER ) return 1;
}
return 0;
}
Usage:
pawn Код:
new
carid = GetPlayerVehicleID( playerid )
;
if( !IsVehicleOccupiedWithPassengers( carid ) ) SetVehicleToRespawn( carid );