1
0
mirror of https://github.com/veden/Rampant.git synced 2025-02-11 13:39:05 +02:00
Rampant/libs/PlayerUtils.lua

29 lines
829 B
Lua
Raw Normal View History

local playerUtils = {}
-- imports
local mathUtils = require("MathUtils")
-- imported functions
local euclideanDistanceNamed = mathUtils.euclideanDistanceNamed
-- module code
2017-05-19 00:47:24 -07:00
function playerUtils.validPlayer(player)
2017-08-08 01:19:51 -07:00
return player and player.valid and player.connected and player.character and player.character.valid and (player.character.surface.index == 1)
2017-05-19 00:47:24 -07:00
end
function playerUtils.playersWithinProximityToPosition(players, position, distance)
2016-10-14 17:00:18 -07:00
for _,player in pairs(players) do
if (player ~= nil) and player.connected and (player.character ~= nil) and player.character.valid and (player.character.surface.index == 1) then
if (euclideanDistanceNamed(player.character.position, position) < distance) then
return true
end
end
end
return false
end
2016-10-14 17:00:18 -07:00
return playerUtils