2019-02-15 20:17:30 -08:00
|
|
|
if playerUtilsG then
|
|
|
|
return playerUtilsG
|
|
|
|
end
|
2016-08-26 23:44:17 -07:00
|
|
|
local playerUtils = {}
|
|
|
|
|
|
|
|
-- imports
|
|
|
|
|
2017-06-15 18:30:26 -07:00
|
|
|
local mathUtils = require("MathUtils")
|
2016-08-26 23:44:17 -07:00
|
|
|
|
|
|
|
-- imported functions
|
|
|
|
|
2017-06-15 18:30:26 -07:00
|
|
|
local euclideanDistanceNamed = mathUtils.euclideanDistanceNamed
|
2016-08-26 23:44:17 -07:00
|
|
|
|
|
|
|
-- module code
|
|
|
|
|
2018-05-23 17:25:08 -07:00
|
|
|
function playerUtils.validPlayer(player, natives)
|
|
|
|
return player and player.valid and player.connected and player.character and player.character.valid and (player.character.surface.index == natives.activeSurface)
|
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
|
2018-05-23 17:25:08 -07:00
|
|
|
if (player ~= nil) and player.connected and (player.character ~= nil) and player.character.valid and (player.character.surface.index == natives.activeSurface) then
|
2016-10-14 17:00:18 -07:00
|
|
|
if (euclideanDistanceNamed(player.character.position, position) < distance) then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
2016-08-26 23:44:17 -07:00
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2019-02-15 20:17:30 -08:00
|
|
|
playerUtilsG = playerUtils
|
2016-10-14 17:00:18 -07:00
|
|
|
return playerUtils
|