Getting the time when a player finishes entering a vehicle?

**[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.


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

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

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.