mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-28 03:55:23 +09:00
4th try now :/
This commit is contained in:
@@ -19,42 +19,6 @@ local ThisModule = {
|
||||
end
|
||||
}
|
||||
|
||||
local function on_marked_for_deconstruction(self,event)
|
||||
-- the _env should be auto loaded but does not, so to prevent desyncs it cant be an anon function
|
||||
local chache = self.data.chache[event.player_index]
|
||||
if not chache then
|
||||
local player = Game.get_player(event)
|
||||
if not player then return end
|
||||
if not Role then
|
||||
if player.admin then self.data.chache[event.player_index] = {'tree-decon',false}
|
||||
else self.data.chache[event.player_index] = {'decon',false} end
|
||||
else
|
||||
if Role.allowed(player,'tree-decon') then self.data.chache[event.player_index] = {'tree-decon',false}
|
||||
elseif not Role.allowed(player,'decon') then self.data.chache[event.player_index] = {'no-decon',false}
|
||||
else self.data.chache[event.player_index] = {'decon',false} end
|
||||
end
|
||||
chache = self.data.chache[event.player_index]
|
||||
end
|
||||
if not event.entity.last_user or event.entity.name == 'entity-ghost' then
|
||||
if chache[1] == 'tree-decon' then
|
||||
table.insert(self.data.trees,event.entity)
|
||||
self.data.clear = game.tick + 10
|
||||
end
|
||||
else
|
||||
if chache[1] == 'no-decon' then
|
||||
event.entity.cancel_deconstruction('player')
|
||||
if not chache[2] then
|
||||
chache[2] = true
|
||||
local player = Game.get_player(event)
|
||||
player_return({'DeconControl.player-print'},defines.textcolor.crit,player)
|
||||
Role.print(Role.meta.groups.Admin.lowest,{'DeconControl.rank-print',player.name},defines.textcolor.info)
|
||||
if Admin then Admin.give_warning(player,'<server>','Trying To Decon The Base') end
|
||||
end
|
||||
self.data.clear = game.tick + 10
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Event Handlers Define
|
||||
Event.register(-1,function(event)
|
||||
Server.new_thread{
|
||||
@@ -68,7 +32,41 @@ Event.register(-1,function(event)
|
||||
local tree = table.remove(trees,1)
|
||||
if tree and tree.valid then tree.destroy() end
|
||||
end
|
||||
end):on_event(defines.events.on_marked_for_deconstruction,on_marked_for_deconstruction):open()
|
||||
end):on_event(defines.events.on_marked_for_deconstruction,function(self,event)
|
||||
-- the _env should be auto loaded but does not, so to prevent desyncs it cant be an anon function
|
||||
local chache = self.data.chache[event.player_index]
|
||||
if not chache then
|
||||
local player = Game.get_player(event)
|
||||
if not player then return end
|
||||
if not Role then
|
||||
if player.admin then self.data.chache[event.player_index] = {'tree-decon',false}
|
||||
else self.data.chache[event.player_index] = {'decon',false} end
|
||||
else
|
||||
if Role.allowed(player,'tree-decon') then self.data.chache[event.player_index] = {'tree-decon',false}
|
||||
elseif not Role.allowed(player,'decon') then self.data.chache[event.player_index] = {'no-decon',false}
|
||||
else self.data.chache[event.player_index] = {'decon',false} end
|
||||
end
|
||||
chache = self.data.chache[event.player_index]
|
||||
end
|
||||
if not event.entity.last_user or event.entity.name == 'entity-ghost' then
|
||||
if chache[1] == 'tree-decon' then
|
||||
table.insert(self.data.trees,event.entity)
|
||||
self.data.clear = game.tick + 10
|
||||
end
|
||||
else
|
||||
if chache[1] == 'no-decon' then
|
||||
event.entity.cancel_deconstruction('player')
|
||||
if not chache[2] then
|
||||
chache[2] = true
|
||||
local player = Game.get_player(event)
|
||||
player_return({'DeconControl.player-print'},defines.textcolor.crit,player)
|
||||
Role.print(Role.meta.groups.Admin.lowest,{'DeconControl.rank-print',player.name},defines.textcolor.info)
|
||||
if Admin then Admin.give_warning(player,'<server>','Trying To Decon The Base') end
|
||||
end
|
||||
self.data.clear = game.tick + 10
|
||||
end
|
||||
end
|
||||
end):open()
|
||||
end)
|
||||
|
||||
-- Module Return
|
||||
|
||||
Reference in New Issue
Block a user