mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 23:16:03 +01:00
refactor(player/client): set CPlayer.__index as a function
Match server implementation.
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
local CPlayer = {}
|
||||
CPlayer.__index = CPlayer
|
||||
|
||||
function CPlayer:__index(index, ...)
|
||||
local method = CPlayer[index]
|
||||
|
||||
if method then
|
||||
return function(...)
|
||||
return method(self, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function CPlayer:getCoords(update)
|
||||
if update or not self.coords then
|
||||
@@ -13,15 +22,6 @@ function CPlayer:getDistance(coords)
|
||||
return #(self:getCoords() - coords)
|
||||
end
|
||||
|
||||
function lib.addPlayerMethod(name, fn)
|
||||
CPlayer[name] = fn
|
||||
end
|
||||
|
||||
function lib.getPlayer()
|
||||
return setmetatable({
|
||||
id = cache.playerId,
|
||||
serverId = cache.serverId,
|
||||
}, CPlayer)
|
||||
return CPlayer
|
||||
end
|
||||
|
||||
player = lib.getPlayer()
|
||||
|
||||
Reference in New Issue
Block a user