mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-19 06:46:03 +01:00
feat(server/functions): finished groups.
This commit is contained in:
@@ -238,6 +238,7 @@ function NDCore.Functions.SetActiveCharacter(player, characterId)
|
|||||||
if result then
|
if result then
|
||||||
local i = result[1]
|
local i = result[1]
|
||||||
NDCore.Players[player] = {
|
NDCore.Players[player] = {
|
||||||
|
source = player,
|
||||||
id = characterId,
|
id = characterId,
|
||||||
firstName = i.first_name,
|
firstName = i.first_name,
|
||||||
lastName = i.last_name,
|
lastName = i.last_name,
|
||||||
@@ -295,20 +296,32 @@ function NDCore.Functions.DeleteCharacter(characterId)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Update the all the characters groups in the database.
|
-- Update the all the characters groups in the database.
|
||||||
function NDCore.Functions.UpdateAllGroups(characterId, groups)
|
function NDCore.Functions.UpdateGroups(player, groups)
|
||||||
local result = MySQL.query.await("UPDATE characters SET groups = ? WHERE character_id = ? LIMIT 1", {groups, characterId})
|
local result = MySQL.query.await("UPDATE characters SET groups = ? WHERE character_id = ?", {json.encode(groups), NDCore.Players[player].id})
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set a group to a character in the database.
|
-- Set a group to a character in the database.
|
||||||
function NDCore.Functions.SetGroup(characterId, group)
|
function NDCore.Functions.SetGroup(player, group, groupData)
|
||||||
local groups = {}
|
local groups = {}
|
||||||
local result = MySQL.query.await("SELECT groups FROM characters WHERE character_id = ? LIMIT 1", {characterId})
|
local result = MySQL.query.await("SELECT groups FROM characters WHERE character_id = ?", {NDCore.Players[player].id})
|
||||||
if result then
|
if result then
|
||||||
groups = json.decode(result[1].groups)
|
groups = json.decode(result[1].groups)
|
||||||
table.insert(groups, group)
|
groups[group] = groupData
|
||||||
end
|
end
|
||||||
result = MySQL.query.await("UPDATE characters SET groups = ? WHERE character_id = ? LIMIT 1", {json.encode(groups), characterId})
|
result = MySQL.query.await("UPDATE characters SET groups = ? WHERE character_id = ?", {json.encode(groups), NDCore.Players[player].id})
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Remove the group form a character in the database.
|
||||||
|
function NDCore.Functions.RemoveGroup(player, group)
|
||||||
|
local groups = {}
|
||||||
|
local result = MySQL.query.await("SELECT groups FROM characters WHERE character_id = ?", {NDCore.Players[player].id})
|
||||||
|
if result then
|
||||||
|
groups = json.decode(result[1].groups)
|
||||||
|
groups[group] = nil
|
||||||
|
end
|
||||||
|
result = MySQL.query.await("UPDATE characters SET groups = ? WHERE character_id = ?", {json.encode(groups), NDCore.Players[player].id})
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user