Garry's Mod Wiki

GM:CanPlayerEnterVehicle

  boolean GM:CanPlayerEnterVehicle( Player player, Vehicle vehicle, number role )

Description

Determines whether or not a given player player can enter the given vehicle. Player:EnterVehicle will still call this hook.

Called just before GM:PlayerEnteredVehicle. See also GM:CanExitVehicle.

Arguments

1 Player player
The player that wants to enter a vehicle.
2 Vehicle vehicle
The vehicle in question.
3 number role
The seat number.

Returns

1 boolean
false if the player is not allowed to enter the vehicle.

Example

Displays a message in the console when a player enters any vehicle.

hook.Add( "CanPlayerEnterVehicle", "PrintPlayersInVehicles", function( ply, veh, role ) print( ply, "has entered the vehicle", veh ) end )