diff --git a/imports/player/client.lua b/imports/player/client.lua index 29c9216..8b4f36a 100644 --- a/imports/player/client.lua +++ b/imports/player/client.lua @@ -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()