mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
fix: group updating but not job
This commit is contained in:
@@ -388,30 +388,29 @@ function NDCore.Functions.SetPlayerData(characterId, key, value, description)
|
|||||||
NDCore.Players[player][key] = value
|
NDCore.Players[player][key] = value
|
||||||
TriggerEvent("ND:moneyChange", player, "cash", tonumber(value), "set", description)
|
TriggerEvent("ND:moneyChange", player, "cash", tonumber(value), "set", description)
|
||||||
end
|
end
|
||||||
MySQL.query("UPDATE characters SET cash = ? WHERE character_id = ?", {tonumber(value), characterId})
|
MySQL.query.await("UPDATE characters SET cash = ? WHERE character_id = ?", {tonumber(value), characterId})
|
||||||
elseif key == "bank" then
|
elseif key == "bank" then
|
||||||
if player then
|
if player then
|
||||||
NDCore.Players[player][key] = value
|
NDCore.Players[player][key] = value
|
||||||
TriggerEvent("ND:moneyChange", player, "bank", tonumber(value), "set", description)
|
TriggerEvent("ND:moneyChange", player, "bank", tonumber(value), "set", description)
|
||||||
end
|
end
|
||||||
MySQL.query("UPDATE characters SET bank = ? WHERE character_id = ?", {tonumber(value), characterId})
|
MySQL.query.await("UPDATE characters SET bank = ? WHERE character_id = ?", {tonumber(value), characterId})
|
||||||
elseif key == "job" then
|
elseif key == "job" then
|
||||||
if player then
|
if player then
|
||||||
NDCore.Players[player].job = value
|
NDCore.Players[player].job = value
|
||||||
end
|
end
|
||||||
MySQL.query("UPDATE characters SET job = ? WHERE character_id = ?", {value, characterId})
|
MySQL.query.await("UPDATE characters SET job = ? WHERE character_id = ?", {value, characterId})
|
||||||
else
|
else
|
||||||
if player then
|
if player then
|
||||||
NDCore.Players[player].data[key] = value
|
NDCore.Players[player].data[key] = value
|
||||||
MySQL.query("UPDATE characters SET `data` = ? WHERE character_id = ?", {json.encode(NDCore.Players[player].data), characterId})
|
MySQL.query.await("UPDATE characters SET `data` = ? WHERE character_id = ?", {json.encode(NDCore.Players[player].data), characterId})
|
||||||
else
|
else
|
||||||
MySQL.query("SELECT `data` FROM characters WHERE character_id = ?", {characterId}, function(result)
|
local result = MySQL.query.await("SELECT `data` FROM characters WHERE character_id = ?", {characterId})
|
||||||
if result and result[1] then
|
if not result or not result[1] then return end
|
||||||
local data = json.decode(result[1].data)
|
|
||||||
data[key] = value
|
local data = json.decode(result[1].data)
|
||||||
MySQL.query("UPDATE characters SET `data` = ? WHERE character_id = ?", {json.encode(data), characterId})
|
data[key] = value
|
||||||
end
|
MySQL.query.await("UPDATE characters SET `data` = ? WHERE character_id = ?", {json.encode(data), characterId})
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -572,26 +571,29 @@ function NDCore.Functions.SetPlayerToGroup(characterId, group, rank)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local result = MySQL.query.await("SELECT data FROM characters WHERE character_id = ?", {characterId})
|
local result = MySQL.query.await("SELECT data FROM characters WHERE character_id = ?", {characterId})
|
||||||
if result and result[1] then
|
if not result or not result[1] then return end
|
||||||
local data = result[1].data
|
local data = json.decode(result[1].data)
|
||||||
if not data.groups then
|
if not data then
|
||||||
data.groups = {}
|
data = {}
|
||||||
end
|
|
||||||
local rankName = tostring(groupRank)
|
|
||||||
if config.groups[group] and config.groups[group][groupRank] then
|
|
||||||
rankName = config.groups[group][groupRank]
|
|
||||||
end
|
|
||||||
data.groups[group] = {
|
|
||||||
rank = groupRank,
|
|
||||||
rankName = rankName
|
|
||||||
}
|
|
||||||
NDCore.Functions.SetPlayerData(characterId, "groups", data.groups)
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
if not data.groups then
|
||||||
|
data.groups = {}
|
||||||
|
end
|
||||||
|
local rankName = tostring(groupRank)
|
||||||
|
if config.groups[group] and config.groups[group][groupRank] then
|
||||||
|
rankName = config.groups[group][groupRank]
|
||||||
|
end
|
||||||
|
data.groups[group] = {
|
||||||
|
rank = groupRank,
|
||||||
|
rankName = rankName
|
||||||
|
}
|
||||||
|
NDCore.Functions.SetPlayerData(characterId, "groups", data.groups)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Remove a player from a group.
|
-- Remove a player from a group.
|
||||||
function NDCore.Functions.RemovePlayerFromGroup(characterId, group)
|
function NDCore.Functions.RemovePlayerFromGroup(characterId, group)
|
||||||
|
if not group then return end
|
||||||
local group = group:lower()
|
local group = group:lower()
|
||||||
for groupName, groupRanks in pairs(config.groups) do
|
for groupName, groupRanks in pairs(config.groups) do
|
||||||
if groupName:lower() == group then
|
if groupName:lower() == group then
|
||||||
|
|||||||
Reference in New Issue
Block a user