Garry's Mod Wiki

GM:PlayerLeaveVehicle

void GM:PlayerLeaveVehicle( Player ply, Vehicle veh )

Description

Called when a player leaves a vehicle.

For vehicles with exit animations, this will be called at the end of the animation, not at the start!
This is not called when a different vehicle is immediately entered with Player:EnterVehicle.

Arguments

1 Player ply
Player who left a vehicle.
2 Vehicle veh
Vehicle the player left.

Example

Make the vehicle continue running (or more precisely start its engine again) when a player exists it, unless the player holds their Reload key.

hook.Add( "PlayerLeaveVehicle", "PlayerLeaveVehicleTurnOn", function( ply, veh ) if ( ply:KeyDown( IN_RELOAD ) ) then return end -- We need to wait a few frames for the vehicle to stop working timer.Create( "magic timer" .. veh:EntIndex(), 0, 2, function() -- Only run on the last time the timer is fired if ( timer.RepsLeft( "magic timer" .. veh:EntIndex() ) > 0 ) then return end veh:StartEngine( true ) -- Start the engine back up veh:ReleaseHandbrake() -- Release the handbrake end ) end )

Page Links


Special Pages


Wikis

?

Render Time: 27ms

Session 0
DB GetPage 3
Generate Html 2
SaveChanges 8
Render Body 0
Render Sidebar 12