Getting the time when a player finishes entering a vehicle?

**[Gamemode.PlayerEnteredVehicle

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.PlayerEnteredVehicle)** only works when a vehicle entering animation starts playing when a player tries to enter the vehicle. How can I get the specific moment when the animation finishes and the vehicle is fully controllable?

use timer(s)

Vehicle model is unknown, so no way to tell whats the animation length, if any.

Everything would be awesome if PlayerEnteredVehicle would get called when the animation finishes.

I have no idea, but this may be of some help for you.

**[Entity.SequenceDuration

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.SequenceDuration)**

Provided that the sequence is already set when PlayerEnteredVehicle is called, the following code may work for you.

[lua]
hook.Add(“PlayerEnteredVehicle”, “SomeUniqueID”, function(ply, vehicle, role)
timer.Simple(ply:SequenceDuration(), function()
if ( IsValid(ply) ) then
– Do some stuff.
end;
end);
end);
[/lua]

Thanks, SequenceDuration() Is all I needed, also why validate a player? Only players can enter vehicles anyway, theres no way the player can’t be valid.

Yes there is, you should always check if a player is valid when using timers.

The player may have disconnected or become invalid by the time the callback from the timer has run, so it is always best to check if they are valid.

I won’t be using timers, so thats not a problem.

Okay but in my example it was neccessary.

Yeah I know, should have specified. I prefer to use var = CurTime()+1 if CurTime() >= var then. In most cases its much more flexible than timers.