qbcore-framework / qb-core

FiveM RP Framework Core :muscle:
GNU General Public License v3.0
582 stars 962 forks source link

Update events.lua #1102

Closed TehSteel closed 4 months ago

TehSteel commented 4 months ago

Description

Added a trigger whenever a player leaves the server.

Checklist

GhzGarage commented 4 months ago

What're you using this for

TehSteel commented 4 months ago

You can't directly access a dropped player's data without "complicating" things too much. If you want to access a dropped player's data, you need to listen to onPlayerLoaded event and save the citizenid inside a table and when playerDropped event occurs, you need to check if the citizenid exists. Only then can you use QBCore.Functions.GetOfflinePlayerByCitizenId. Even if you use this method, it makes unnecessary SQL queries instead of making a trigger and passing the Player object.