mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-19 06:46:03 +01:00
update: fetch with identifer and charid
This commit is contained in:
@@ -306,12 +306,18 @@ end
|
|||||||
|
|
||||||
---@param id number
|
---@param id number
|
||||||
---@return table
|
---@return table
|
||||||
function NDCore.fetchCharacter(id)
|
function NDCore.fetchCharacter(id, src)
|
||||||
local result = MySQL.query.await("SELECT * FROM nd_characters WHERE charid = ?", {id})
|
local result
|
||||||
|
if src then
|
||||||
|
result = MySQL.query.await("SELECT * FROM nd_characters WHERE charid = ? and identifier = ?", {id, GetPlayerIdentifierByType(src, Config.characterIdentifier)})
|
||||||
|
else
|
||||||
|
result = MySQL.query.await("SELECT * FROM nd_characters WHERE charid = ?", {id})
|
||||||
|
end
|
||||||
|
|
||||||
if not result then return end
|
if not result then return end
|
||||||
|
|
||||||
local info = result[1]
|
local info = result[1]
|
||||||
return createCharacterTable({
|
return createCharacterTable({
|
||||||
|
source = src,
|
||||||
id = info.charid,
|
id = info.charid,
|
||||||
identifier = info.identifier,
|
identifier = info.identifier,
|
||||||
name = info.name,
|
name = info.name,
|
||||||
@@ -359,8 +365,7 @@ end
|
|||||||
---@return table
|
---@return table
|
||||||
function NDCore.setActiveCharacter(src, id)
|
function NDCore.setActiveCharacter(src, id)
|
||||||
if not src then return end
|
if not src then return end
|
||||||
local character = NDCore.fetchCharacter(id)
|
local character = NDCore.fetchCharacter(id, src)
|
||||||
character.source = src
|
|
||||||
character.name = GetPlayerName(src)
|
character.name = GetPlayerName(src)
|
||||||
character.active()
|
character.active()
|
||||||
return ActivePlayers[src]
|
return ActivePlayers[src]
|
||||||
|
|||||||
Reference in New Issue
Block a user