mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
feat: change license to any identifier
This commit is contained in:
3
init.lua
3
init.lua
@@ -8,7 +8,8 @@ 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 {}
|
groups = json.decode(GetConvar("core:groups")) or {},
|
||||||
|
characterIdentifier = GetConvar("core:characterIdentifier", "license")
|
||||||
}
|
}
|
||||||
|
|
||||||
local nd_core = exports["ND_Core"]
|
local nd_core = exports["ND_Core"]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local function createCharacterTable(info)
|
local function createCharacterTable(info)
|
||||||
local self = {
|
local self = {
|
||||||
source = info.source,
|
source = info.source,
|
||||||
license = info.license,
|
identifier = info.identifier,
|
||||||
name = info.name,
|
name = info.name,
|
||||||
firstname = info.firstname,
|
firstname = info.firstname,
|
||||||
lastname = info.lastname,
|
lastname = info.lastname,
|
||||||
@@ -209,12 +209,12 @@ end
|
|||||||
---@param info table
|
---@param info table
|
||||||
---@return table
|
---@return table
|
||||||
function NDCore.newCharacter(src, info)
|
function NDCore.newCharacter(src, info)
|
||||||
local license = GetPlayerIdentifierByType(src, "license")
|
local identifier = GetPlayerIdentifierByType(src, Config.characterIdentifier)
|
||||||
if not license then return end
|
if not identifier then return end
|
||||||
|
|
||||||
local charInfo = createCharacterTable({
|
local charInfo = createCharacterTable({
|
||||||
source = src,
|
source = src,
|
||||||
license = license,
|
identifier = identifier,
|
||||||
name = GetPlayerName(src) or "",
|
name = GetPlayerName(src) or "",
|
||||||
firstname = info.firstname or "",
|
firstname = info.firstname or "",
|
||||||
lastname = info.lastname or "",
|
lastname = info.lastname or "",
|
||||||
@@ -227,8 +227,8 @@ function NDCore.newCharacter(src, info)
|
|||||||
inventory = info.inventory or {},
|
inventory = info.inventory or {},
|
||||||
})
|
})
|
||||||
|
|
||||||
charInfo.id = MySQL.insert.await("INSERT INTO nd_characters (license, name, firstname, lastname, dob, gender, cash, bank, metadata) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", {
|
charInfo.id = MySQL.insert.await("INSERT INTO nd_characters (identifier, name, firstname, lastname, dob, gender, cash, bank, metadata) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", {
|
||||||
license,
|
identifier,
|
||||||
charInfo.name,
|
charInfo.name,
|
||||||
charInfo.firstname,
|
charInfo.firstname,
|
||||||
charInfo.lastname,
|
charInfo.lastname,
|
||||||
@@ -251,7 +251,7 @@ function NDCore.fetchCharacter(id)
|
|||||||
local info = result[1]
|
local info = result[1]
|
||||||
return createCharacterTable({
|
return createCharacterTable({
|
||||||
id = id,
|
id = id,
|
||||||
license = info.license,
|
identifier = info.identifier,
|
||||||
name = info.name,
|
name = info.name,
|
||||||
firstname = info.firstname,
|
firstname = info.firstname,
|
||||||
lastname = info.lastname,
|
lastname = info.lastname,
|
||||||
@@ -269,14 +269,14 @@ end
|
|||||||
---@return table
|
---@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 identifier = ?", {GetPlayerIdentifierByType(src, Config.characterIdentifier)})
|
||||||
local amount = #result
|
local amount = #result
|
||||||
|
|
||||||
for i=1, amount do
|
for i=1, amount do
|
||||||
local info = result[i]
|
local info = result[i]
|
||||||
characters[info.charid] = createCharacterTable({
|
characters[info.charid] = createCharacterTable({
|
||||||
id = info.charid,
|
id = info.charid,
|
||||||
license = info.license,
|
identifier = info.identifier,
|
||||||
name = info.name,
|
name = info.name,
|
||||||
firstname = info.firstname,
|
firstname = info.firstname,
|
||||||
lastname = info.lastname,
|
lastname = info.lastname,
|
||||||
|
|||||||
Reference in New Issue
Block a user