1
0
mirror of https://github.com/veden/Rampant.git synced 2025-01-20 02:59:47 +02:00
Rampant/libs/PlayerUtils.lua

39 lines
1.1 KiB
Lua
Raw Normal View History

2019-02-15 20:17:30 -08:00
if playerUtilsG then
return playerUtilsG
end
local playerUtils = {}
-- imports
local mathUtils = require("MathUtils")
-- imported functions
local euclideanDistanceNamed = mathUtils.euclideanDistanceNamed
-- module code
2018-05-23 17:25:08 -07:00
function playerUtils.validPlayer(player, natives)
2019-10-19 14:04:38 -07:00
if player and player.valid and player.connected then
local char = player.character
return char and char.valid and (char.surface.index == natives.activeSurface)
end
return false
2017-05-19 00:47:24 -07:00
end
2018-05-23 17:25:08 -07:00
function playerUtils.playersWithinProximityToPosition(players, position, distance, natives)
2016-10-14 17:00:18 -07:00
for _,player in pairs(players) do
2019-10-19 14:04:38 -07:00
if player and player.valid and player.connected then
local char = player.character
if ((char and char.valid and (char.surface.index == natives.activeSurface)) and
(euclideanDistanceNamed(char.position, position) < distance)) then
2019-10-19 12:13:48 -07:00
return true
end
end
end
return false
end
2019-02-15 20:17:30 -08:00
playerUtilsG = playerUtils
2016-10-14 17:00:18 -07:00
return playerUtils