initial commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
local ____lualib = require("lualib_bundle")
|
||||
local __TS__Class = ____lualib.__TS__Class
|
||||
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
|
||||
local __TS__New = ____lualib.__TS__New
|
||||
local ____exports = {}
|
||||
____exports.PlayerInfoClass = __TS__Class()
|
||||
local PlayerInfoClass = ____exports.PlayerInfoClass
|
||||
PlayerInfoClass.name = "PlayerInfoClass"
|
||||
PlayerInfoClass.____file_path = "scripts/vscripts/player_info.lua"
|
||||
function PlayerInfoClass.prototype.____constructor(self)
|
||||
self.playersIdBySteamId = {}
|
||||
end
|
||||
function PlayerInfoClass.prototype.InitPlayer(self, playerId, info)
|
||||
local steamId = tostring(PlayerResource:GetSteamAccountID(playerId))
|
||||
self.playersIdBySteamId[steamId] = playerId
|
||||
self:UpdatePlayerInfo(playerId, info)
|
||||
end
|
||||
function PlayerInfoClass.prototype.UpdatePlayerInfo(self, playerId, info)
|
||||
for ____, ____value in ipairs(__TS__ObjectEntries(info)) do
|
||||
local key = ____value[1]
|
||||
local value = ____value[2]
|
||||
if type(value) == "string" then
|
||||
do
|
||||
pcall(function()
|
||||
local parsedValue = JSON:parse(value)
|
||||
info[key] = parsedValue
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
CustomNetTables:SetTableValue(
|
||||
"player_info",
|
||||
tostring(playerId),
|
||||
info
|
||||
)
|
||||
if GameRules.donateManager and type(GameRules.donateManager.CheckForChangeDonate) == "function" then
|
||||
GameRules.donateManager:CheckForChangeDonate(playerId)
|
||||
end
|
||||
end
|
||||
function PlayerInfoClass.prototype.GetPlayerInfo(self, playerId)
|
||||
local info = CustomNetTables:GetTableValue(
|
||||
"player_info",
|
||||
tostring(playerId)
|
||||
)
|
||||
return info or nil
|
||||
end
|
||||
function PlayerInfoClass.prototype.GetPlayerIdBySteamId(self, steamId)
|
||||
return self.playersIdBySteamId[steamId]
|
||||
end
|
||||
____exports.PlayerInfo = __TS__New(____exports.PlayerInfoClass)
|
||||
return ____exports
|
||||
Reference in New Issue
Block a user