mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

onClientVehicleEnterStop/onVehicleEnterStop

Open Fierelier opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

A onClientVehicleEnterStop/onVehicleEnterStop, which triggers when the ped/player cancels entering a vehicle, would be just the event I need. Perhaps also a getPedTargetVehicle, which returns the vehicle the ped/player is trying to get into.

Describe alternatives you've considered

No response

Additional context

I have a script which alters the rotation of the player, which makes them not walk to the vehicle properly when getting in from far away. I can use onClientVehicleStartEnter to detect when the player starts getting into a car, but I couldn't think of a reliable way to detect when they cancel doing that (for example, by pressing a movement key) - There's some sort of buffer before the movement keys cancel anything, then I don't know how much analog input there needs to be, and the player could also be moved/teleported away... It's just a lot of stuff to deal with and get wrong.

Security Policy

  • [x] I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.

Fierelier avatar Jul 17 '22 23:07 Fierelier

I agree with request, however you can work around it by checking for the 'TASK_COMPLEX_GO_TO_CAR_DOOR_AND_STAND_STILL' task with getPedTask.

Here's an example:

addEventHandler('onClientVehicleStartEnter', root, function(player, seat, door)
    local vehicle = source
    Timer(function()
        local _, task = localPlayer:getTask('primary', 3)
        if task ~= 'TASK_COMPLEX_GO_TO_CAR_DOOR_AND_STAND_STILL' then
            triggerEvent('onClientVehicleEnterStop', vehicle, player, seat, door)
            sourceTimer:destroy()
        end
    end, 0, 0)
end)

addEvent('onClientVehicleEnterStop', true)
addEventHandler('onClientVehicleEnterStop', root, function()
    print('Entering interrupted')
end)

Hope this helps.

JcynR avatar Jul 25 '22 21:07 JcynR

Oh wow, I didn't even know about this function at all, that's insane! Thank you!

Fierelier avatar Jul 26 '22 17:07 Fierelier