mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +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 = {}
|
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)
|
function CPlayer:getCoords(update)
|
||||||
if update or not self.coords then
|
if update or not self.coords then
|
||||||
@@ -13,15 +22,6 @@ function CPlayer:getDistance(coords)
|
|||||||
return #(self:getCoords() - coords)
|
return #(self:getCoords() - coords)
|
||||||
end
|
end
|
||||||
|
|
||||||
function lib.addPlayerMethod(name, fn)
|
|
||||||
CPlayer[name] = fn
|
|
||||||
end
|
|
||||||
|
|
||||||
function lib.getPlayer()
|
function lib.getPlayer()
|
||||||
return setmetatable({
|
return CPlayer
|
||||||
id = cache.playerId,
|
|
||||||
serverId = cache.serverId,
|
|
||||||
}, CPlayer)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
player = lib.getPlayer()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user