7 Commits

Author SHA1 Message Date
Andyyy7666
70a1487420 wip(compat/qb/server): basic functions 2024-03-09 19:07:30 +01:00
Andy
626f0ad06f Merge pull request #66 from ND-Framework/feat/custom-group-info
Feat/custom group info
2024-03-09 19:03:19 +01:00
Andyyy7666
d5c3acbd81 tweak(server/player): adding job group 2024-03-09 19:02:18 +01:00
Andyyy7666
98cba87bec feat(server/player): adding custom group info 2024-03-09 19:00:15 +01:00
Andyyy7666
001fc22ef6 fix: syntax error 2024-02-29 23:17:08 +01:00
Andy
87420e99e9 Merge pull request #65 from ND-Framework/feat/discord-groups
feat: receive groups by discord roles
2024-02-29 22:29:13 +01:00
Andyyy7666
c5597161d9 feat: receive groups by discord roles
Player can receive groups based on the discord roles they have, ace perms are also added when group is received.
2024-02-29 22:28:25 +01:00
3 changed files with 85 additions and 6 deletions

View File

@@ -1 +1,73 @@
if not lib.table.contains(Config.compatibility, "qb") then return end if not lib.table.contains(Config.compatibility, "qb") then return end
local QBCore = {}
QBCore.Config = QBConfig
QBCore.Shared = QBShared
QBCore.ClientCallbacks = {}
QBCore.ServerCallbacks = {}
QBCore.Players = {}
QBCore.Functions = {}
QBCore.Player_Buckets = {}
QBCore.Entity_Buckets = {}
QBCore.UsableItems = {}
function QBCore.Functions.GetCoords(entity)
local coords = GetEntityCoords(entity)
local heading = GetEntityHeading(entity)
return vec4(coords.x, coords.y, coords.z, heading)
end
function QBCore.Functions.GetIdentifier(source, idtype)
if GetConvarInt("sv_fxdkMode", 0) == 1 then return "license:fxdk" end
return GetPlayerIdentifierByType(source, idtype or "license")
end
function QBCore.Functions.GetSource(identifier)
for src, _ in pairs(NDCore.players) do
local idens = GetPlayerIdentifiers(src)
for _, id in pairs(idens) do
if identifier == id then
return src
end
end
end
return 0
end
local function createPlayer(player)
end
function QBCore.Functions.GetPlayer(source)
if type(source) == "number" then
return createPlayer(NDCore.players[source])
else
return createPlayer(NDCore.players[QBCore.Functions.GetSource(source)])
end
end
function QBCore.Functions.GetPlayerByCitizenId(citizenid)
for src in pairs(NDCore.players) do
if NDCore.players[src].id == citizenid then
return NDCore.players[src]
end
end
end
-- function QBCore.Functions.GetOfflinePlayerByCitizenId(citizenid)
-- return QBCore.Player.GetOfflinePlayer(citizenid)
-- end
-- function QBCore.Functions.GetPlayerByLicense(license)
-- return QBCore.Player.GetPlayerByLicense(license)
-- end
function QBCore.Functions.GetPlayerByPhone(number)
for src in pairs(NDCore.players) do
if NDCore.players[src].phonenumber == number then
return createPlayer(NDCore.players[src])
end
end
end

View File

@@ -24,6 +24,7 @@ Config = {
groups = json.decode(GetConvar("core:groups", "[]")), groups = json.decode(GetConvar("core:groups", "[]")),
admins = json.decode(GetConvar("core:admins", "[]")), admins = json.decode(GetConvar("core:admins", "[]")),
adminDiscordRoles = json.decode(GetConvar("core:adminDiscordRoles", "[]")), adminDiscordRoles = json.decode(GetConvar("core:adminDiscordRoles", "[]")),
groupRoles = json.decode(GetConvar("core:groupRoles", "[]")),
multiCharacter = false, multiCharacter = false,
compatibility = json.decode(GetConvar("core:compatibility", "[]")) compatibility = json.decode(GetConvar("core:compatibility", "[]"))
} }

View File

@@ -309,6 +309,12 @@ local function createCharacterTable(info)
self.addGroup("admin") self.addGroup("admin")
end end
end end
for group, role in pairs(Config.groupRoles) do
if lib.table.contains(roles, role) then
self.addGroup(group)
end
end
end end
for name, _ in pairs(self.groups) do for name, _ in pairs(self.groups) do
@@ -323,10 +329,10 @@ local function createCharacterTable(info)
---@param rank number ---@param rank number
---@param isJob boolean ---@param isJob boolean
---@return boolean ---@return boolean
function self.addGroup(name, rank, isJob) function self.addGroup(name, rank, info, isJob)
local groupRank = tonumber(rank) or 1 local groupRank = tonumber(rank) or 1
local groupInfo = Config.groups?[name] local groupInfo = info or Config.groups?[name]
local bossRank = groupInfo and groupInfo.minimumBossRank local bossRank = groupInfo?.minimumBossRank
-- if not groupInfo then return end -- if not groupInfo then return end
if isJob then if isJob then
@@ -337,8 +343,8 @@ local function createCharacterTable(info)
self.groups[name] = { self.groups[name] = {
name = name, name = name,
label = groupInfo and groupInfo.label or name, label = groupInfo?.label or name,
rankName = groupInfo and groupInfo.ranks[groupRank] or groupRank, rankName = groupInfo?.ranks?[groupRank] or groupRank,
rank = groupRank, rank = groupRank,
isJob = isJob, isJob = isJob,
isBoss = bossRank and groupRank >= bossRank isBoss = bossRank and groupRank >= bossRank
@@ -382,7 +388,7 @@ local function createCharacterTable(info)
---@return boolean ---@return boolean
function self.setJob(name, rank) function self.setJob(name, rank)
self.removeGroup(self.job) self.removeGroup(self.job)
local job = self.addGroup(name, rank, true) local job = self.addGroup(name, rank, nil, true)
if job then if job then
self.job = job.name self.job = job.name
self.jobInfo = job self.jobInfo = job