Open ImSkully opened 3 years ago
The StartExit
and StartEnter
events triggering immediately when you begin jacking is expected behavior IMO - they can be cancelled and too many scripts rely on these now to change this.
What you want is an event to indicate when the jacking is actually taking place (ie. when the driver is physically being pulled out of the car). If you want a scripting workaround for now, you can check this out: https://forum.mtasa.com/topic/128380-help-prevent-ped-from-sit-in-vehicle-after-carjack/?do=findComment&comment=990598
I have plans to add onVehicleJacked
and onClientVehicleJacked
, haven't come around to it yet. (It's easier to do for next release to avoid b.w.c.)
(I would label issue as an enhancement btw)
Correct me if I'm wrong but isn't StartExit
meant to denote that a player is starting to actually exit a vehicle? With this issue, the event gets triggered but the player doesn't actually begin leaving the vehicle at all. Sure, the jacking can be cancelled but in my case I have no reason to cancel it and it should still be allowed, however I am relying on the onClientVehicleStartExit
event to trigger reliably when the player is actually going to be leaving a vehicle so I can remove interfaces.
The issue I'm having now is that the interface is displayed for the player in a vehicle however if a nearby player begins carjacking them but cancels it, the event still gets triggered and the interface will disappear.
Correct me if I'm wrong but isn't
StartExit
meant to denote that a player is starting to actually exit a vehicle? With this issue, the event gets triggered but the player doesn't actually begin leaving the vehicle at all.
I get what you mean, it might seem more logical that way, but we can't change it now because then we would need a PreStartExit
event. And it's not worth making a breaking change over a semantic issue IMO.
If you try to exit a vehicle at speed you also need to wait for the car to slow down or go fast enough to roll out. In theory something could interrupt the exiting task and the same thing would happen (the event fired but the player remains in his car) This event is mainly there to allow scripts to cancel exiting before it takes place.
However your issue is valid enough, that there is a lack of events to notify of actual entering/exiting (which is what you are interested in most of the time)
So it would make sense to add two intermediate events like
onVehicleEnteredPhysically
onVehicleExitedPhysically
The issue I'm having now is that the interface is displayed for the player in a vehicle however if a nearby player begins carjacking them but cancels it, the event still gets triggered and the interface will disappear.
I think a lot of people encounter this. For your interface you can't rely on these events right now but rather ask the game for the true state of things. Luckily this can be done through scripting
You have two options
1) Use isPedInVehicle
clientside as this returns whether the player/ped is physically inside (note: different than getPedOccupiedVehicle)
2) Use the task system with getPedTask
and check for the driving task.
getPedTask(ped, "primary", 4) == "TASK_SIMPLE_CAR_DRIVE"
Fair point in terms of BWC if such a change was made, I guess the alternative of ped task will have to do for now until such an event like onVehicleExitedPhysically
exists.
Describe the bug The event
onClientVehicleStartExit
is triggered for a player when they are sitting inside a vehicle and another player begins to carjack them, whilst this is normal and expected since the player will indeed be exiting the vehicle, the carjacker can however cancel their action and stop carjacking if they press any key to walk (WASD) whilst in the animation of approaching the vehicle. This cancels the carjack however the event is still triggered for the player who is now still remaining in the vehicle.This is problematic in cases where this event is relied on to only be triggered when a player truly is going to be out of the vehicle.
To reproduce
onClientVehicleStartExit
.onClientVehicleStartExit
will already have been triggered for the driver of the vehicle.Expected Behaviour
onClientVehicleStartExit
describes the event of a client actually beginning to leave a vehicle, therefore this should only be triggered when the carjacking reaches a point where it can no longer be cancelled and the client is for definite going to be exiting the vehicle, this is the point at which the carjacker begins to open the vehicle door to pull the client out; after this animation starts it can no longer be cancelled.Screenshots N/A
Version
Additional context https://github.com/multitheftauto/mtasa-blue/blob/415579f06d804d94c0557dfe9f1d752e515eb60f/Server/mods/deathmatch/logic/CGame.cpp#L3238-L3285