mirror of
https://github.com/RoccoMyTacco/qb-pefcl.git
synced 2026-03-31 06:33:57 -04:00
fix: unload player called on client
This commit is contained in:
15
README.md
15
README.md
@@ -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
3
client.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
RegisterNetEvent("QBCore:Client:OnPlayerUnload", function()
|
||||
TriggerServerEvent("qb-pefcl:server:UnloadPlayer")
|
||||
end)
|
||||
21
server.lua
21
server.lua
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user