Files
ox_lib/imports/player/server.lua

41 lines
734 B
Lua
Raw Normal View History

--[[
This module was experimental and won't be worked on or used further.
May be removed in the future.
]]
2022-05-29 10:28:35 +10:00
local CPlayer = {}
function CPlayer:__index(index, ...)
2022-09-18 22:41:25 +10:00
local method = CPlayer[index]
2022-05-29 10:28:35 +10:00
2022-09-18 22:41:25 +10:00
if method then
return function(...)
return method(self, ...)
end
end
2022-05-29 10:28:35 +10:00
end
function CPlayer:getCoords(update)
2022-09-18 22:41:25 +10:00
if update or not self.coords then
self.coords = GetEntityCoords(self.getPed())
end
2022-05-29 10:28:35 +10:00
2022-09-18 22:41:25 +10:00
return self.coords
2022-05-29 10:28:35 +10:00
end
function CPlayer:getDistance(coords)
2022-09-18 22:41:25 +10:00
return #(self:getCoords() - coords)
2022-05-29 10:28:35 +10:00
end
function CPlayer:getPed()
self.ped = GetPlayerPed(self.source)
2022-09-18 22:41:25 +10:00
return self.ped
2022-05-29 10:28:35 +10:00
end
---@deprecated
2022-05-29 10:28:35 +10:00
function lib.getPlayer()
2022-09-18 22:41:25 +10:00
return CPlayer
2022-05-29 10:28:35 +10:00
end
2022-09-18 22:41:25 +10:00
return lib.getPlayer