mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
update: gorups
This commit is contained in:
1
init.lua
1
init.lua
@@ -8,6 +8,7 @@ Config = {
|
||||
discordActionLink = GetConvar("discordActionLink", "https://discord.gg/Z9Mxu72zZ6"),
|
||||
discordActionText2 = GetConvar("core:discordActionText2", "STORE"),
|
||||
discordActionLink2 = GetConvar("core:discordActionLink2", "https://andyyy.tebex.io/category/fivem-scripts"),
|
||||
groups = json.decode(GetConvar("core:groups")) or {}
|
||||
}
|
||||
|
||||
local nd_core = exports["ND_Core"]
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
---@param src number
|
||||
---@return table
|
||||
function NDCore.getPlayer(src)
|
||||
return ActivePlayers[src]
|
||||
end
|
||||
|
||||
---@param metadata string
|
||||
---@param data any
|
||||
---@return table
|
||||
function NDCore.getPlayers(metadata, data)
|
||||
if not metadata or not data then return ActivePlayers end
|
||||
local players = {}
|
||||
|
||||
@@ -179,10 +179,22 @@ local function createCharacterTable(info)
|
||||
|
||||
---@param name string
|
||||
---@param rank number
|
||||
---@return boolean
|
||||
function self.addGroup(name, rank)
|
||||
local groupInfo = Config.groups[name]
|
||||
if not groupInfo return end
|
||||
self.groups[name] = {
|
||||
|
||||
label = groupInfo.label,
|
||||
rankName = groupInfo.ranks[rank] or rank,
|
||||
rank = rank
|
||||
}
|
||||
return true
|
||||
end
|
||||
|
||||
---@param name string
|
||||
---@return table
|
||||
function self.getGroup(name)
|
||||
return self.groups[name]
|
||||
end
|
||||
|
||||
---@param name string
|
||||
@@ -193,6 +205,9 @@ local function createCharacterTable(info)
|
||||
return self
|
||||
end
|
||||
|
||||
---@param src number
|
||||
---@param info table
|
||||
---@return table
|
||||
function NDCore.newCharacter(src, info)
|
||||
local license = GetPlayerIdentifierByType(src, "license")
|
||||
if not license then return end
|
||||
@@ -227,6 +242,8 @@ function NDCore.newCharacter(src, info)
|
||||
return charInfo
|
||||
end
|
||||
|
||||
---@param id number
|
||||
---@return table
|
||||
function NDCore.fetchCharacter(id)
|
||||
local result = MySQL.query.await("SELECT * FROM nd_characters WHERE charid = ?", {id})
|
||||
if not result then return end
|
||||
@@ -248,6 +265,8 @@ function NDCore.fetchCharacter(id)
|
||||
})
|
||||
end
|
||||
|
||||
---@param src number
|
||||
---@return table
|
||||
function NDCore.getPlayerCharacters(src)
|
||||
local characters = {}
|
||||
local result = MySQL.query.await("SELECT * FROM nd_characters WHERE license = ?", {GetPlayerIdentifierByType(src, "license")})
|
||||
@@ -273,6 +292,9 @@ function NDCore.getPlayerCharacters(src)
|
||||
return characters
|
||||
end
|
||||
|
||||
---@param src number
|
||||
---@param id number
|
||||
---@return table
|
||||
function NDCore.setActiveCharacter(src, id)
|
||||
local char = ActivePlayers[src]
|
||||
if char then char:unload() end
|
||||
|
||||
Reference in New Issue
Block a user