-
Notifications
You must be signed in to change notification settings - Fork 983
Add vehicle status player events #1205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add vehicle status player events #1205
Conversation
Implements client-side detection and server event triggers for entering, aborting, entering, and leaving vehicles when the 'baseevents' resource is not started. This ensures vehicle-related events are still handled even if the baseevents resource is unavailable.
Cisternita
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not useful
Why not? Why make a full event of QBCore relly on the existance of a script or not in the server and don't have a fallback? |
|
I haven't tested this event personally, but could we benefit from using the CEventNetworkPlayerEnteredVehicle game event instead of the thread? |
|
I don't think that event will detect the seat change |
|
Do you mean when someone shuffles seat without leaving the vehicle? |
|
exactly |
|
And also when entering is aborted |
|
From what I see, the current logic is: |
True, Do you know if that event triggers every time someone tries to get into vehicle? I mean, is it like the shooting one that triggers once for each ped near the shooting or is it only one by the player trying to get into a vehicl |
|
I dont really think we should be forcing our users to use baseevents, which this is pretty much doing. It isnt performant at all, and it is very well possible that servers choose intentionally not to use baseevents - which this would circumvent. |
|
I agree we shouldn't force users to use The way I see it is people should instead be using To me, that just leaves the main question of:
Also, was my first comment ever looked into further for entering vehicles? If not I can try to fit some time in to look at it: CEventNetworkPlayerEnteredVehicle If we can't find something more event based for everything, I believe our best course of action is:
|
|
I'll look into this |
|
If've check and we cannot replicate the events in baseevents just with CEvents. There is just one event useful here that is the one you mentioned "CEventNetworkPlayerEnteredVehicle". The problem is that baseevents provides (and therefore QBCore uses) four events:
With the provided event we can detect the enteredVehicle and kind of the leftVehicle if we make a loop when entered a vehicle and check if it is still inside or not. But the enteringVehicle and the enteringAborted cannot be detected (at least in any way I found). So we have really to options, continue with the baseevents fallback and make those event reliable and works under any circumstances or just do two out of four events. What do you think? @Qwerty1Verified |
I mean, there are 10000+ servers using qb-core, https://5metrics.dev/resource/qb-core
It is very apparent that baseevents, and the functionality it provides, is something people (excuse my language) couldnt care less about. And something that 99% of qbcore servers live without daily. As you mention though, we do use baseevents in some of our default qb-core logic. More specifically, for the
(The All of the abortion logic of the entering vehicle is handled in the respective script(s) mentioned above. So, we could in theory 100% make due with the "CEventNetworkPlayerEnteredVehicle" event. In my opinion, we should rather just rework the above mentioned scripts to use the "CEventNetworkPlayerEnteredVehicle" event, as that should in theory perform better(?). |
|
@Z3rio I know that baseevents it's used by anoyne, I don't use it either. But I think that if QBCore had an event to check enetering and leaving vehicles, scripts will be more optimized (each scripts has a loop to check for entering a vehicle). So I could use the CEventNetworkPlayerEnteredVehicle to check when entered and left the vehicle and the entering just be the same that when you enter. Do you agree? |
|
I agree that would be an optimal solution, yeah. But is the So the real work here would rather be actually refactoring all applicable qb-core resources to not use baseevents in its entirety (and not include in txadmin recipe), in favor of the |
|
Yeah I'd rather run a thread when needed than 24/7, so if we can avoid running a thread 24/7 by doing what I mentioned in an earlier comment we should be able to both remove any baseevents dependence, and improve performance overall. For example, if a player is not in a vehicle, we don't need to know whether they left or switched seats. We do need to know if a player is in a vehicle though so we can then look for those other changes, which the game event gives us |
|
I think that making a QBCore wrapper is the best option @Z3rio beacuse that event only provides the "player entered" functionality, but player left still needs a thread, so having it only in QBCore is better than in every single resource, right? I propose this:
Do you @Z3rio and @Qwerty1Verified agree with this? |
|
Yeah sounds in line with what I mentioned. It only runs when necessary in that case, still facilitates our required use case, and since the timing for those other events are less critical also allows us to reduce the loop frequency for massive performance gains. I also agree having a centralised and optimised thread that fires events is better than having repeated logic and threads running across several first and third party resources. We can control the conditions, and reduce repeated computation doing this. |
|
@Qwerty1Verified if you could check out the code and tell me what do you think. It was added:
|
|
Did you take a look? @Qwerty1Verified I tried in my server and it worked |
Description
This pull request adds a fallback implementation for vehicle-related player events in
server/events.luato ensure core vehicle event handling works even if thebaseeventsresource is not running. The new code tracks when a player enters, aborts entering, enters, or leaves a vehicle, and triggers the appropriate server events.Baseevents fallback implementation:
baseevents:enteringVehicle,baseevents:enteringAborted,baseevents:enteredVehicle,baseevents:leftVehicle) when thebaseeventsresource is not started. This ensures consistent vehicle event handling regardless of resource state.GetPedVehicleSeatto determine the seat index the player occupies in a vehicle.Checklist