mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Fix reviving ghosts placed by players and healing entities of other forces
This commit is contained in:
@@ -28,18 +28,20 @@ commands.add_command('repair', 'Repairs all destoryed and damaged entites in an
|
|||||||
local max_range = rank.power-highest_admin_power > 0 and const/(rank.power-highest_admin_power) or nil
|
local max_range = rank.power-highest_admin_power > 0 and const/(rank.power-highest_admin_power) or nil
|
||||||
local center = player and player.position or {x=0,y=0}
|
local center = player and player.position or {x=0,y=0}
|
||||||
if not range or max_range and range > max_range then player_return({'commands.invalid-range',0,math.floor(max_range)}) return commands.error end
|
if not range or max_range and range > max_range then player_return({'commands.invalid-range',0,math.floor(max_range)}) return commands.error end
|
||||||
for x = -range-2, range+2 do
|
local area = {{center.x-range,center.y-range},{center.x+range,center.y+range}}
|
||||||
for y = -range-2, range+2 do
|
local max_health = 2^32 - 1
|
||||||
if x^2+y^2 < range^2 then
|
local sq_range = range^2
|
||||||
for key, entity in pairs(player.surface.find_entities_filtered({area={{x+center.x,y+center.y},{x+center.x+1,y+center.y+1}},type='entity-ghost'})) do
|
for key, entity in pairs(player.surface.find_entities_filtered({area=area,type='entity-ghost'})) do
|
||||||
if disallow[entity.ghost_prototype.name] then
|
if entity.force == player.force and (entity.position.x-center.x)^2+(entity.position.y-center.y)^2 < sq_range then
|
||||||
player_return('You have repaired: '..entity.name..' this item is not allowed.',defines.text_color.crit,player)
|
if disallow[entity.ghost_prototype.name] then
|
||||||
Admin.temp_ban(player,'<server>','Attempt To Repair A Banned Item')
|
player_return('You have repaired: '..entity.name..' this item is not allowed.',defines.text_color.crit,player)
|
||||||
entity.destroy()
|
Admin.temp_ban(player,'<server>','Attempt To Repair A Banned Item')
|
||||||
else entity.revive() end
|
entity.destroy()
|
||||||
end
|
elseif entity.time_to_live ~= max_health then
|
||||||
for key, entity in pairs(player.surface.find_entities({{x+center.x,y+center.y},{x+center.x+1,y+center.y+1}})) do if entity.health then entity.health = 10000 end end
|
entity.revive() end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
for key, entity in pairs(player.surface.find_entities(area)) do
|
||||||
|
if entity.force == player.force and (entity.position.x-center.x)^2+(entity.position.y-center.y)^2 < sq_range and entity.health then entity.health = 10000 end
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user