move: server meta player to shared

This commit is contained in:
Linventif 2024-02-16 13:54:28 +01:00
parent 9a6e29382e
commit 51c24d13f5
No known key found for this signature in database
GPG Key ID: FAC0CA60F9AEEC24
2 changed files with 76 additions and 73 deletions

View File

@ -1,80 +1,7 @@
//
// Meta
//
local ply = FindMetaTable("Player")
function ply:gmIntGetConnectTime()
return self.gmIntTimeConnect || 0
end
function ply:gmIntSetCustomValue(key, value)
self.gmIntCustomValues = self.gmIntCustomValues || {}
self.gmIntCustomValues[key] = value
end
function ply:gmIntGetCustomValue(key)
return self.gmIntCustomValues && self.gmIntCustomValues[key]
end
function ply:gmIntRemoveCustomValue(key)
if (self.gmIntCustomValues) then
self.gmIntCustomValues[key] = nil
end
end
//
// Compatibility
//
local function getCustomCompatability(ply)
local values = {}
// DarkRP
if (DarkRP) then
values.money = ply:getDarkRPVar("money")
values.job = ply:getDarkRPVar("job")
end
// GUI Level System
if (GUILevelSystem) then
values.level = ply:GetLevel()
values.xp = ply:GetXP()
end
return values
end
//
// Methods
//
local function getCustomValues(ply)
local values = {}
// Get compatability values
for key, value in pairs(getCustomCompatability(ply)) do
values[key] = value
end
// Get custom values or overwrite compatability values
if (ply.gmIntCustomValues) then
for key, value in pairs(ply.gmIntCustomValues) do
values[key] = value
end
end
return values
end
function ply:gmIntGetCustomValues()
return getCustomValues(self)
end
function gmInte.plyValid(ply)
return ply:IsValid() && ply:IsPlayer() && !ply:IsBot()
end
function gmInte.verifyPlayer(ply)
if (!gmInte.plyValid(ply)) then return end
gmInte.http.get("/players/" .. ply:SteamID64(), function(code, data)

View File

@ -0,0 +1,76 @@
//
// Meta
//
local ply = FindMetaTable("Player")
function ply:gmIntGetConnectTime()
return self.gmIntTimeConnect || 0
end
function ply:gmIntSetCustomValue(key, value)
self.gmIntCustomValues = self.gmIntCustomValues || {}
self.gmIntCustomValues[key] = value
end
function ply:gmIntGetCustomValue(key)
return self.gmIntCustomValues && self.gmIntCustomValues[key]
end
function ply:gmIntRemoveCustomValue(key)
if (self.gmIntCustomValues) then
self.gmIntCustomValues[key] = nil
end
end
//
// Compatibility
//
local function getCustomCompatability(ply)
local values = {}
// DarkRP
if (DarkRP) then
values.money = ply:getDarkRPVar("money")
values.job = ply:getDarkRPVar("job")
end
// GUI Level System
if (GUILevelSystem) then
values.level = ply:GetLevel()
values.xp = ply:GetXP()
end
return values
end
//
// Methods
//
local function getCustomValues(ply)
local values = {}
// Get compatability values
for key, value in pairs(getCustomCompatability(ply)) do
values[key] = value
end
// Get custom values or overwrite compatability values
if (ply.gmIntCustomValues) then
for key, value in pairs(ply.gmIntCustomValues) do
values[key] = value
end
end
return values
end
function ply:gmIntGetCustomValues()
return getCustomValues(self)
end
function gmInte.plyValid(ply)
return ply:IsValid() && ply:IsPlayer() && !ply:IsBot()
end