fix: unload player called on client

This commit is contained in:
SamShanks1
2022-07-25 15:37:12 +01:00
parent 265163a787
commit 7afd9f575b
3 changed files with 32 additions and 7 deletions

View File

@@ -1,15 +1,18 @@
<h1 align="center">qb-pefcl</h1>
**This is a compatibility resource that enables PEFCL to function properly with QBCore. Please ensure that you have the latest version
of PEFCL and QBCore installed**
## Installation Steps:
1. Download this repository and place it in the `resources` directory
2. Add `ensure qb-pefcl` to your `server.cfg` (Start this resource after `QBCore` and `PEFCL` have been started)
3. Navigate to the `config.json` in `PEFCL` and change the following settings under `FrameworkIntegration`:
a. `enabled` to `true`
b. `exportResource` to `qb-pefcl`
3. Navigate to the `config.json` in `PEFCL` and change the following settings:
- Under `frameworkIntegration`
- `enabled`: `true`
- `resource`: `qb-pefcl`
- Under `target`
- `type`: `"qb-target"`
- `enabled`: `true`
**Note this currently only works on PEFCL develop branch**

3
client.lua Normal file
View File

@@ -0,0 +1,3 @@
RegisterNetEvent("QBCore:Client:OnPlayerUnload", function()
TriggerServerEvent("qb-pefcl:server:UnloadPlayer")
end)

View File

@@ -20,6 +20,9 @@ exports("removeCash", removeCash)
exports("getCash", getCash)
AddEventHandler("QBCore:Server:PlayerLoaded", function(player)
if not player then
return
end
local citizenid = player.PlayerData.citizenid
local charInfo = player.PlayerData.charinfo
local playerSrc = player.PlayerData.source
@@ -30,6 +33,22 @@ AddEventHandler("QBCore:Server:PlayerLoaded", function(player)
})
end)
AddEventHandler("QBCore:Client:OnPlayerUnload", function(src)
RegisterNetEvent("qb-pefcl:server:UnloadPlayer", function(src)
exports.pefcl:unloadPlayer(src)
end)
AddEventHandler("onServerResourceStart", function(resName)
if resName ~= GetCurrentResourceName() then
return
end
local players = QBCore.Functions.GetQBPlayers()
for _, v in pairs(players) do
exports.pefcl:loadPlayer(v.PlayerData.source, {
source = v.PlayerData.source,
identifier = v.PlayerData.citizenid,
name = v.PlayerData.charinfo.firstname .. " " .. v.PlayerData.charinfo.lastname,
})
end
end)