Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
feat(server): now works with qb-core too
Browse files Browse the repository at this point in the history
  • Loading branch information
mahanmoulaei committed Apr 11, 2022
1 parent c532252 commit c76adb2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
44 changes: 38 additions & 6 deletions Server/Server.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
local Framework = nil
local Core = nil

if Config.UseRPName then
if GetResourceState('es_extended') ~= 'missing' then
Framework = 'ESX'
Core = exports['es_extended']:getSharedObject()
elseif GetResourceState('qb-core') ~= 'missing' then
Framework = 'QB'
Core = exports['qb-core']:GetCoreObject()
elseif GetResourceState('JLRP-Framework') ~= 'missing' then
Framework = 'JLRP'
Core = exports['JLRP-Framework']:getSharedObject()
end
end


local PlayersInCurrentRadioChannel = {}
--TODO : Check The Bug In playerDropped Event
AddEventHandler("playerDropped", function()
Expand Down Expand Up @@ -56,19 +73,34 @@ function CreateFullRadioListOfChannel(RadioChannel)
playersInRadio[player] = {}
playersInRadio[player].Source = player

local name
local name = nil

if Config.UseRPName then
local xPlayer = ESX.GetPlayerFromId(player)
if xPlayer then
name = xPlayer.getName()
else --extra check to make sure player sends a name to client
if Framework == 'ESX' then
local xPlayer = Core.GetPlayerFromId(player)
if xPlayer then
name = xPlayer.getName()
end
elseif Framework == 'QB' then
local xPlayer = Core.Functions.GetPlayer(player)
if xPlayer then
name = xPlayer.PlayerData.charinfo.firstname..' '..xPlayer.PlayerData.charinfo.lastname
end
elseif Framework == 'JLRP' then
local xPlayer = Core.GetPlayerFromId(player)
if xPlayer then
name = xPlayer.getName()
else --extra check to make sure player sends a name to client
name = GetPlayerName(player)
end
end

if name == nil then --extra check to make sure player sends a name to client
name = GetPlayerName(player)
end
else
name = GetPlayerName(player)
end

playersInRadio[player].Name = name
end

Expand Down
1 change: 0 additions & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ author 'Mahan#8183'
description 'JolbakLifeRP Radio List : List of players in each radio for pma-voice'

shared_scripts {
'@es_extended/imports.lua',
'Config.lua',
}

Expand Down

0 comments on commit c76adb2

Please sign in to comment.