mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 22:27:34 +00:00
move: server meta player to shared
This commit is contained in:
parent
9a6e29382e
commit
51c24d13f5
|
@ -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)
|
||||
|
|
76
lua/gmod_integration/shared/sh_player_meta.lua
Normal file
76
lua/gmod_integration/shared/sh_player_meta.lua
Normal 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
|
Loading…
Reference in New Issue
Block a user