Garry's Mod Wiki

GM:CanExitVehicle

  boolean GM:CanExitVehicle( Vehicle veh, Player ply )

Description

Determines if the player can exit the vehicle on their own. Player:ExitVehicle will bypass this hook.

See GM:CanPlayerEnterVehicle for the opposite hook.
See also GM:PlayerLeaveVehicle for a hook that will be called whenever a player exits any vehicle for any reason.

Arguments

1 Vehicle veh
The vehicle entity
2 Player ply
The player

Returns

1 boolean
True if the player can exit the vehicle.

Example

Only lets player exit vehicle if it is not in motion.

hook.Add( "CanExitVehicle", "PlayerMotion", function( veh, ply ) return ( veh:GetVelocity() == Vector( 0, 0, 0 ) ) end )