From 4575b5e02ae26af759f80e37cb22e776595db2cc Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Thu, 12 May 2022 07:41:12 +1000 Subject: [PATCH] refactor(player): simplify Was planning to support checking other user playerdata, but will require much more planning to implement properly. --- imports/player/client.lua | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/imports/player/client.lua b/imports/player/client.lua index ad79841..7aa0056 100644 --- a/imports/player/client.lua +++ b/imports/player/client.lua @@ -1,8 +1,8 @@ local CPlayer = {} CPlayer.__index = CPlayer -function CPlayer:getCoords() - if not self.coords then +function CPlayer:getCoords(update) + if update or not self.coords then self.coords = GetEntityCoords(self.ped) end @@ -17,26 +17,10 @@ function lib.addPlayerMethod(name, fn) CPlayer[name] = fn end -function lib.getPlayer(id, ped, serverId) +function lib.getPlayer() return setmetatable({ - id = id or cache.playerId, - ped = ped or cache.ped, - serverId = serverId or cache.serverId, + id = cache.playerId, + ped = cache.ped, + serverId = cache.serverId, }, CPlayer) end - -function lib.getPlayerFromServerId(serverId) - local playerId = GetPlayerFromServerId(serverId) - - if playerId then - return lib.getPlayer(playerId, playerId == cache.playerId and cache.ped or NetworkGetEntityFromNetworkId(serverId), serverId) - end -end - -function lib.getPlayerFromPed(ped) - local playerId = NetworkGetPlayerIndexFromPed(ped) - - if playerId then - return lib.getPlayer(playerId, ped, playerId == cache.playerId and cache.serverId or GetPlayerServerId(playerId)) - end -end