Skip to content

Commit

Permalink
fix(imports/player): return function
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Sep 18, 2022
1 parent 36703a1 commit f1671f1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
26 changes: 14 additions & 12 deletions imports/player/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,30 @@
local CPlayer = {}

function CPlayer:__index(index, ...)
local method = CPlayer[index]
local method = CPlayer[index]

if method then
return function(...)
return method(self, ...)
end
end
if method then
return function(...)
return method(self, ...)
end
end
end

function CPlayer:getCoords(update)
if update or not self.coords then
self.coords = GetEntityCoords(cache.ped)
end
if update or not self.coords then
self.coords = GetEntityCoords(cache.ped)
end

return self.coords
return self.coords
end

function CPlayer:getDistance(coords)
return #(self:getCoords() - coords)
return #(self:getCoords() - coords)
end

---@deprecated
function lib.getPlayer()
return CPlayer
return CPlayer
end

return lib.getPlayer
28 changes: 15 additions & 13 deletions imports/player/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,35 @@
local CPlayer = {}

function CPlayer:__index(index, ...)
local method = CPlayer[index]
local method = CPlayer[index]

if method then
return function(...)
return method(self, ...)
end
end
if method then
return function(...)
return method(self, ...)
end
end
end

function CPlayer:getCoords(update)
if update or not self.coords then
self.coords = GetEntityCoords(self.getPed())
end
if update or not self.coords then
self.coords = GetEntityCoords(self.getPed())
end

return self.coords
return self.coords
end

function CPlayer:getDistance(coords)
return #(self:getCoords() - coords)
return #(self:getCoords() - coords)
end

function CPlayer:getPed()
self.ped = GetPlayerPed(self.source)
return self.ped
return self.ped
end

---@deprecated
function lib.getPlayer()
return CPlayer
return CPlayer
end

return lib.getPlayer

0 comments on commit f1671f1

Please sign in to comment.