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

29 lines
887 B
Lua
Raw Normal View History

local playerUtils = {}
-- imports
local mathUtils = require("MathUtils")
-- imported functions
local euclideanDistanceNamed = mathUtils.euclideanDistanceNamed
-- module code
2018-05-24 02:25:08 +02: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 09:47:24 +02:00
end
2018-05-24 02:25:08 +02:00
function playerUtils.playersWithinProximityToPosition(players, position, distance, natives)
2016-10-15 02:00:18 +02:00
for _,player in pairs(players) do
2018-05-24 02:25:08 +02: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-15 02:00:18 +02:00
if (euclideanDistanceNamed(player.character.position, position) < distance) then
return true
end
end
end
return false
end
2016-10-15 02:00:18 +02:00
return playerUtils