From 2d4c13bc3d7935df7f2391914e9fb90fc76d506d Mon Sep 17 00:00:00 2001 From: Matthew <22198949+MafewTM@users.noreply.github.com> Date: Sun, 27 Oct 2024 13:46:50 -0400 Subject: [PATCH] feat(server/player): SetCharInfo export --- server/player.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/server/player.lua b/server/player.lua index 21fb85814..079ca9dbf 100644 --- a/server/player.lua +++ b/server/player.lua @@ -1122,6 +1122,25 @@ end exports('GetMetadata', GetMetadata) +---@param identifier Source | string +---@param charInfo string +---@param value any +function SetCharInfo(identifier, charInfo, value) + if not charInfo or type(charInfo) ~= 'string' then return end + + local player = type(identifier) == 'string' and (GetPlayerByCitizenId(identifier) or GetOfflinePlayer(identifier)) or GetPlayer(identifier) + + if not player then return end + + --local oldCharInfo = player.PlayerData.charinfo[charInfo] + + player.PlayerData.charinfo[charInfo] = value + + UpdatePlayerData(identifier) +end + +exports('SetCharInfo', SetCharInfo) + ---@param source Source ---@param playerMoney table ---@param moneyType MoneyType