fix(imports/player): return function

This commit is contained in:
Linden
2022-09-18 22:41:25 +10:00
parent 36703a1f47
commit f1671f14bc
2 changed files with 29 additions and 25 deletions

View File

@@ -6,28 +6,30 @@
local CPlayer = {} local CPlayer = {}
function CPlayer:__index(index, ...) function CPlayer:__index(index, ...)
local method = CPlayer[index] local method = CPlayer[index]
if method then if method then
return function(...) return function(...)
return method(self, ...) return method(self, ...)
end end
end 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
self.coords = GetEntityCoords(cache.ped) self.coords = GetEntityCoords(cache.ped)
end end
return self.coords return self.coords
end end
function CPlayer:getDistance(coords) function CPlayer:getDistance(coords)
return #(self:getCoords() - coords) return #(self:getCoords() - coords)
end end
---@deprecated ---@deprecated
function lib.getPlayer() function lib.getPlayer()
return CPlayer return CPlayer
end end
return lib.getPlayer

View File

@@ -6,33 +6,35 @@
local CPlayer = {} local CPlayer = {}
function CPlayer:__index(index, ...) function CPlayer:__index(index, ...)
local method = CPlayer[index] local method = CPlayer[index]
if method then if method then
return function(...) return function(...)
return method(self, ...) return method(self, ...)
end end
end 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
self.coords = GetEntityCoords(self.getPed()) self.coords = GetEntityCoords(self.getPed())
end end
return self.coords return self.coords
end end
function CPlayer:getDistance(coords) function CPlayer:getDistance(coords)
return #(self:getCoords() - coords) return #(self:getCoords() - coords)
end end
function CPlayer:getPed() function CPlayer:getPed()
self.ped = GetPlayerPed(self.source) self.ped = GetPlayerPed(self.source)
return self.ped return self.ped
end end
---@deprecated ---@deprecated
function lib.getPlayer() function lib.getPlayer()
return CPlayer return CPlayer
end end
return lib.getPlayer