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"),
|
discordActionLink = GetConvar("discordActionLink", "https://discord.gg/Z9Mxu72zZ6"),
|
||||||
discordActionText2 = GetConvar("core:discordActionText2", "STORE"),
|
discordActionText2 = GetConvar("core:discordActionText2", "STORE"),
|
||||||
discordActionLink2 = GetConvar("core:discordActionLink2", "https://andyyy.tebex.io/category/fivem-scripts"),
|
discordActionLink2 = GetConvar("core:discordActionLink2", "https://andyyy.tebex.io/category/fivem-scripts"),
|
||||||
|
groups = json.decode(GetConvar("core:groups")) or {}
|
||||||
}
|
}
|
||||||
|
|
||||||
local nd_core = exports["ND_Core"]
|
local nd_core = exports["ND_Core"]
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
|
---@param src number
|
||||||
|
---@return table
|
||||||
function NDCore.getPlayer(src)
|
function NDCore.getPlayer(src)
|
||||||
return ActivePlayers[src]
|
return ActivePlayers[src]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param metadata string
|
||||||
|
---@param data any
|
||||||
|
---@return table
|
||||||
function NDCore.getPlayers(metadata, data)
|
function NDCore.getPlayers(metadata, data)
|
||||||
if not metadata or not data then return ActivePlayers end
|
if not metadata or not data then return ActivePlayers end
|
||||||
local players = {}
|
local players = {}
|
||||||
|
|||||||
@@ -179,10 +179,22 @@ local function createCharacterTable(info)
|
|||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param rank number
|
---@param rank number
|
||||||
|
---@return boolean
|
||||||
function self.addGroup(name, rank)
|
function self.addGroup(name, rank)
|
||||||
|
local groupInfo = Config.groups[name]
|
||||||
|
if not groupInfo return end
|
||||||
self.groups[name] = {
|
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
|
end
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
@@ -193,6 +205,9 @@ local function createCharacterTable(info)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param src number
|
||||||
|
---@param info table
|
||||||
|
---@return table
|
||||||
function NDCore.newCharacter(src, info)
|
function NDCore.newCharacter(src, info)
|
||||||
local license = GetPlayerIdentifierByType(src, "license")
|
local license = GetPlayerIdentifierByType(src, "license")
|
||||||
if not license then return end
|
if not license then return end
|
||||||
@@ -227,6 +242,8 @@ function NDCore.newCharacter(src, info)
|
|||||||
return charInfo
|
return charInfo
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param id number
|
||||||
|
---@return table
|
||||||
function NDCore.fetchCharacter(id)
|
function NDCore.fetchCharacter(id)
|
||||||
local result = MySQL.query.await("SELECT * FROM nd_characters WHERE charid = ?", {id})
|
local result = MySQL.query.await("SELECT * FROM nd_characters WHERE charid = ?", {id})
|
||||||
if not result then return end
|
if not result then return end
|
||||||
@@ -248,6 +265,8 @@ function NDCore.fetchCharacter(id)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param src number
|
||||||
|
---@return table
|
||||||
function NDCore.getPlayerCharacters(src)
|
function NDCore.getPlayerCharacters(src)
|
||||||
local characters = {}
|
local characters = {}
|
||||||
local result = MySQL.query.await("SELECT * FROM nd_characters WHERE license = ?", {GetPlayerIdentifierByType(src, "license")})
|
local result = MySQL.query.await("SELECT * FROM nd_characters WHERE license = ?", {GetPlayerIdentifierByType(src, "license")})
|
||||||
@@ -273,6 +292,9 @@ function NDCore.getPlayerCharacters(src)
|
|||||||
return characters
|
return characters
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param src number
|
||||||
|
---@param id number
|
||||||
|
---@return table
|
||||||
function NDCore.setActiveCharacter(src, id)
|
function NDCore.setActiveCharacter(src, id)
|
||||||
local char = ActivePlayers[src]
|
local char = ActivePlayers[src]
|
||||||
if char then char:unload() end
|
if char then char:unload() end
|
||||||
|
|||||||
Reference in New Issue
Block a user