mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 04:21:41 +09:00
Added Modules to be converted
This commit is contained in:
229
to convert/Addons/Admin/admin.lua
Normal file
229
to convert/Addons/Admin/admin.lua
Normal file
@@ -0,0 +1,229 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
Admin = Admin or {}
|
||||
|
||||
local function append_name(reason,name)
|
||||
local reason = reason or 'No Reason'
|
||||
if not string.find(string.lower(reason),string.lower(name)) then return reason..' - '..name
|
||||
else return reason end
|
||||
end
|
||||
|
||||
local function open(player,pre_select_player,pre_select_action)
|
||||
if Admin.center then Gui.center.clear(player) Admin.center.open(player,pre_select_player,pre_select_action) end
|
||||
end
|
||||
|
||||
function Admin.allowed(player)
|
||||
local player = Game.get_player(player)
|
||||
local lowest_admin_power = Ranking.get_group('Admin').lowest.power
|
||||
return lowest_admin_power >= Ranking.get_rank(player).power
|
||||
end
|
||||
|
||||
function Admin.btn_flow(frame,buttons)
|
||||
local frame = frame.add{
|
||||
type='flow',
|
||||
name='admin'
|
||||
}
|
||||
frame.add{
|
||||
type='label',
|
||||
caption='',
|
||||
name='player'
|
||||
}.style.visible = false
|
||||
local function format(btn)
|
||||
btn.style.height = 30
|
||||
btn.style.width = 30
|
||||
end
|
||||
if not buttons or buttons.ban then format(Admin.ban_btn:draw(frame)) end
|
||||
if not buttons or buttons.kick then format(Admin.kick_btn:draw(frame)) end
|
||||
if not buttons or buttons.jail then format(Admin.jail_btn:draw(frame)) end
|
||||
if not buttons or buttons.go_to then format(Admin.go_to_btn:draw(frame)) end
|
||||
if not buttons or buttons.bring then format(Admin.bring_btn:draw(frame)) end
|
||||
return frame.player
|
||||
end
|
||||
|
||||
function Admin.take_action(action,player,by_player,reason)
|
||||
if action == 'Ban' then Admin.ban(player,by_player,reason)
|
||||
elseif action == 'Temp Ban' and Admin.temp_ban then Admin.temp_ban(player,by_player,reason)
|
||||
elseif action == 'Kick' then Admin.kick(player,by_player,reason)
|
||||
elseif action == 'Jail' then Admin.jail(player,by_player,reason)
|
||||
elseif action == 'GoTo' then Admin.go_to(player,by_player)
|
||||
elseif action == 'Bring' then Admin.bring(player,by_player)
|
||||
end
|
||||
end
|
||||
|
||||
local inventorys = {
|
||||
defines.inventory.player_main,
|
||||
defines.inventory.player_quickbar,
|
||||
defines.inventory.player_trash,
|
||||
defines.inventory.player_guns,
|
||||
defines.inventory.player_ammo,
|
||||
defines.inventory.player_armor,
|
||||
defines.inventory.player_armor
|
||||
}
|
||||
|
||||
function Admin.move_item_to_spawn(item,surface,chests)
|
||||
local chests = chests or surface.find_entities_filtered{area={{-10,-10},{10,10}},name='iron-chest'} or {}
|
||||
local chest = nil
|
||||
while not chest or not chest.get_inventory(defines.inventory.chest).can_insert(item) do
|
||||
chest = table.remove(chests,1)
|
||||
if not chest then chest = surface.create_entity{
|
||||
name='iron-chest',
|
||||
position=surface.find_non_colliding_position('iron-chest',{0,0},32,1)
|
||||
} end
|
||||
end
|
||||
chest.get_inventory(defines.inventory.chest).insert(item)
|
||||
table.insert(chests,chest)
|
||||
return chests
|
||||
end
|
||||
|
||||
function Admin.move_inventory(player)
|
||||
local player = Game.get_player(player)
|
||||
if not player then return end
|
||||
local chests = player.surface.find_entities_filtered{area={{-10,-10},{10,10}},name='iron-chest'} or {}
|
||||
for _,_inventory in pairs(inventorys) do
|
||||
local inventory = player.get_inventory(_inventory)
|
||||
if inventory then
|
||||
for item,count in pairs(inventory.get_contents()) do
|
||||
local item = {name=item,count=count}
|
||||
chests = Admin.move_item_to_spawn(item,player.surface,chests)
|
||||
end
|
||||
inventory.clear()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Admin.ban_btn = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-ban',
|
||||
caption='utility/danger_icon',
|
||||
tooltip={'admin-commands.tooltip-ban'}
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
pre_select_player = parent.player and parent.player.caption or nil
|
||||
open(event.player_index,pre_select_player,'Ban')
|
||||
end)
|
||||
|
||||
function Admin.ban(player,by_player,reason)
|
||||
local player = Game.get_player(player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
local reason = append_name(reason,by_player_name)
|
||||
Sync.emit_embeded{
|
||||
title='Player Ban',
|
||||
color=Color.to_hex(defines.text_color.crit),
|
||||
description='There was a player banned.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=reason
|
||||
}
|
||||
Admin.move_inventory(player)
|
||||
Server.interface(game.ban_player,true,player,reason)
|
||||
end
|
||||
|
||||
Admin.kick_btn = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-kick',
|
||||
caption='utility/warning_icon',
|
||||
tooltip={'admin-commands.tooltip-kick'}
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
pre_select_player = parent.player and parent.player.caption or nil
|
||||
open(event.player_index,pre_select_player,'Kick')
|
||||
end)
|
||||
|
||||
function Admin.kick(player,by_player,reason)
|
||||
local player = Game.get_player(player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
local reason = append_name(reason,by_player_name)
|
||||
Sync.emit_embeded{
|
||||
title='Player Kick',
|
||||
color=Color.to_hex(defines.text_color.high),
|
||||
description='There was a player kicked.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=reason
|
||||
}
|
||||
Admin.move_inventory(player)
|
||||
Server.interface(game.kick_player,true,player,reason)
|
||||
end
|
||||
|
||||
Admin.jail_btn = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-jail',
|
||||
caption='utility/clock',
|
||||
tooltip={'admin-commands.tooltip-jail'}
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
pre_select_player = parent.player and parent.player.caption or nil
|
||||
open(event.player_index,pre_select_player,'Jail')
|
||||
end)
|
||||
|
||||
function Admin.jail(player,by_player,reason)
|
||||
local player = Game.get_player(player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
local reason = append_name(reason,by_player_name)
|
||||
Sync.emit_embeded{
|
||||
title='Player Jail',
|
||||
color=Color.to_hex(defines.text_color.med),
|
||||
description='There was a player jailed.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=reason
|
||||
}
|
||||
Admin.move_inventory(player)
|
||||
Ranking._presets().last_jail = player.name
|
||||
Server.interface(Ranking.give_rank,true,player,'Jail',by_player_name)
|
||||
end
|
||||
|
||||
Admin.go_to_btn = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-go-to',
|
||||
caption='utility/export_slot',
|
||||
tooltip={'admin-commands.tooltip-go-to'}
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
pre_select_player = parent.player and parent.player.caption or nil
|
||||
Admin.go_to(pre_select_player,event.player_index)
|
||||
end)
|
||||
|
||||
function Admin.go_to(player,by_player)
|
||||
local player = Game.get_player(player)
|
||||
local _player = Game.get_player(by_player)
|
||||
_player.teleport(player.surface.find_non_colliding_position('player',player.position,32,1),player.surface)
|
||||
end
|
||||
|
||||
Admin.bring_btn = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-bring',
|
||||
caption='utility/import_slot',
|
||||
tooltip={'admin-commands.tooltip-bring'}
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
pre_select_player = parent.player and parent.player.caption or nil
|
||||
Admin.bring(pre_select_player,event.player_index)
|
||||
end)
|
||||
|
||||
function Admin.bring(player,by_player)
|
||||
local player = Game.get_player(player)
|
||||
local _player = Game.get_player(by_player)
|
||||
if not player or not _player then return end
|
||||
player.teleport(_player.surface.find_non_colliding_position('player',_player.position,32,1),_player.surface)
|
||||
end
|
||||
|
||||
function Admin.tp(from_playaer, to_player)
|
||||
local _from_player = Game.get_player(from_player)
|
||||
local _to_player = Game.get_player(to_player)
|
||||
|
||||
if not _from_player or not _to_player then return end
|
||||
|
||||
if Game.players[_from_player].health >= 0 then return end
|
||||
if Game.players[_to_player].health >= 0 then return end
|
||||
|
||||
_from_player.teleport(_to_player.surface.find_non_colliding_position('player',_to_player.position,32,1),_to_player.surface)
|
||||
end
|
||||
39
to convert/Addons/Admin/afk-kick.lua
Normal file
39
to convert/Addons/Admin/afk-kick.lua
Normal file
@@ -0,0 +1,39 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
function get_allowed_afk_time(player)
|
||||
local rank = Ranking.get_rank(player)
|
||||
local count = #game.connected_players
|
||||
local base = rank.base_afk_time or false
|
||||
if not base then return false end
|
||||
return (base/5)*count
|
||||
end
|
||||
|
||||
Event.register(-1,function(event)
|
||||
Server.new_thread{
|
||||
name='afk-kick',
|
||||
}:on_event('tick',function(self)
|
||||
if (game.tick%3600) ~= 0 then return end
|
||||
for _,player in pairs(game.connected_players) do
|
||||
local afk = #game.connected_players < 3 and 10 or get_allowed_afk_time(player)
|
||||
if afk then
|
||||
if player.afk_time > afk*3600 then game.kick_player(player,'AFK For Too Long ('..math.floor(afk)..' Minutes)') end
|
||||
end
|
||||
end
|
||||
end):on_event('error',function(self,err)
|
||||
Sync.emit_embeded{
|
||||
title='Auto Kick Error',
|
||||
color=Color.to_hex(defines.text_color.bg),
|
||||
description='Auto Kick Error - Closed Thread',
|
||||
Error=err
|
||||
}
|
||||
self:close()
|
||||
end):open()
|
||||
end)
|
||||
134
to convert/Addons/Admin/auto-chat.lua
Normal file
134
to convert/Addons/Admin/auto-chat.lua
Normal file
@@ -0,0 +1,134 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
-- white spaces removed and made into lower
|
||||
-- these messages are sent only to the player
|
||||
local messages = {
|
||||
['discord']={'chat-bot.discord'},
|
||||
['expgaming']={'chat-bot.website'},
|
||||
['website']={'chat-bot.website'},
|
||||
['command']={'chat-bot.custom-commands'},
|
||||
['commands']={'chat-bot.custom-commands'},
|
||||
['softmod']={'chat-bot.softmod'},
|
||||
['script']={'chat-bot.softmod'},
|
||||
['link']={'chat-bot.links'},
|
||||
['links']={'chat-bot.links'},
|
||||
['loop']={'chat-bot.loops'},
|
||||
['loops']={'chat-bot.loops'},
|
||||
--Thadius suggestion start
|
||||
['rhd']={'chat-bot.lhd'},
|
||||
--Thadius suggestion end
|
||||
['roundabout']={'chat-bot.loops'},
|
||||
['roundabouts']={'chat-bot.loops'},
|
||||
['afk']=function(_player) local max=_player for _,player in pairs(game.connected_players) do if max.afk_time < player.afk_time then max=player end end return {'chat-bot.afk',max.name,tick_to_display_format(max.afk_time)} end
|
||||
}
|
||||
-- white spaces removed and made into lower
|
||||
-- these are global chat commands that can be used
|
||||
-- comands start with ! (all messages are also commands)
|
||||
local command_syntax = '!'
|
||||
local commands = {
|
||||
['online']=function(player) return {'chat-bot.players-online',#game.connected_players} end,
|
||||
['playtime']=function(player) return {'chat-bot.map-time',tick_to_display_format(game.tick)} end,
|
||||
['players']=function(player) return {'chat-bot.players',#game.players} end,
|
||||
['dev']={'chat-bot.not-real-dev'},
|
||||
['blame']=function(player) local names = {'Cooldude2606','arty714','badgamernl',player.name} return {'chat-bot.blame',names[math.random(#names)]} end,
|
||||
['readme']={'chat-bot.read-readme'},
|
||||
['magic']={'chat-bot.magic'},
|
||||
['aids']={'chat-bot.aids'},
|
||||
['riot']={'chat-bot.riot'},
|
||||
['lenny']={'chat-bot.lenny'},
|
||||
['wiki']={'chat-bot.wiki'},
|
||||
['evolution']=function(player) return {'chat-bot.current-evolution',string.format('%.2f',game.forces['enemy'].evolution_factor)} end,
|
||||
--Jokes about food and drink
|
||||
['whattoeat']={'chat-bot.food'},
|
||||
['makepopcorn']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'chat-bot.message',{'chat-bot.get-popcorn-2',self.data}} end
|
||||
end):open() return {'chat-bot.get-popcorn-1'} end,
|
||||
['orderpizza']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data[2]==0 then game.print{'chat-bot.message',{'chat-bot.order-pizza-2',self.data[1]}}
|
||||
elseif self.data[2]==1 then game.print{'chat-bot.message',{'chat-bot.order-pizza-3',self.data[1]}} self.reopen = false
|
||||
end
|
||||
self.data[2]=self.data[2]+1
|
||||
end):open() return {'chat-bot.order-pizza-1'} end,
|
||||
['passsomesnaps']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data[2]==0 then game.print{'chat-bot.message',{'chat-bot.get-snaps-2',self.data[1]}}
|
||||
elseif self.data[2]==1 then game.print{'chat-bot.message',{'chat-bot.get-snaps-3',self.data[1]}} self.reopen = false
|
||||
end
|
||||
self.data[2]=self.data[2]+1
|
||||
end):open() return {'chat-bot.get-snaps-1'} end,
|
||||
['makecocktail']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data[2]==0 then game.print{'chat-bot.message',{'chat-bot.get-cocktail-2',self.data[1]}}
|
||||
elseif self.data[2]==1 then game.print{'chat-bot.message',{'chat-bot.get-cocktail-3',self.data[1]}} self.reopen = false
|
||||
end
|
||||
self.data[2]=self.data[2]+1
|
||||
end):open() return {'chat-bot.get-cocktail-1'} end,
|
||||
['makecoffee']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'chat-bot.message',{'chat-bot.make-coffee-2',self.data}} end
|
||||
end):open() return {'chat-bot.make-coffee-1'} end,
|
||||
['orderpizza']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data[2]==0 then game.print{'chat-bot.message',{'chat-bot.order-pizza-2',self.data[1]}}
|
||||
elseif self.data[2]==1 then game.print{'chat-bot.message',{'chat-bot.order-pizza-3',self.data[1]}} self.reopen = false
|
||||
end
|
||||
self.data[2]=self.data[2] + 1
|
||||
end):open() return {'chat-bot.order-pizza-1'} end,
|
||||
['maketea']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'chat-bot.message',{'chat-bot.make-tea-2',self.data}} end
|
||||
end):open() return {'chat-bot.make-tea-1'} end,
|
||||
['meadplease']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'chat-bot.message',{'chat-bot.get-mead-2',self.data}} end
|
||||
end):open() return {'chat-bot.get-mead-1'} end,
|
||||
['passabeer']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'chat-bot.message',{'chat-bot.get-beer-2',self.data}} end
|
||||
end):open() return {'chat-bot.get-beer-1'} end
|
||||
}
|
||||
|
||||
Event.register(defines.events.on_console_chat,function(event)
|
||||
local player = Game.get_player(event)
|
||||
if not player then return end
|
||||
local player_message = event.message:lower():gsub("%s+", "")
|
||||
local allowed = Ranking.get_rank(player):allowed('global-chat')
|
||||
for to_find,message in pairs(messages) do
|
||||
if player_message:match(command_syntax..to_find) then
|
||||
if allowed then
|
||||
if is_type(message,'function') then message=message(player) end
|
||||
game.print{'chat-bot.message',message}
|
||||
else player_return({'chat-bot.rank-error'},nil,player) end
|
||||
elseif player_message:match(to_find) then
|
||||
if is_type(message,'function') then message=message(player) end
|
||||
player_return({'chat-bot.message',message},nil,player)
|
||||
end
|
||||
end
|
||||
for to_find,message in pairs(commands) do
|
||||
if player_message:match(command_syntax..to_find) then
|
||||
if allowed then
|
||||
if is_type(message,'function') then message=message(player) end
|
||||
game.print{'chat-bot.message',message}
|
||||
else player_return({'chat-bot.rank-error'},nil,player) end
|
||||
end
|
||||
end
|
||||
end)
|
||||
61
to convert/Addons/Admin/auto-message.lua
Normal file
61
to convert/Addons/Admin/auto-message.lua
Normal file
@@ -0,0 +1,61 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
Event.register(-1,function(event)
|
||||
Server.new_thread{
|
||||
name='auto-message',
|
||||
timeout=54000, -- 3240000 = 15 hours dont make the mistake i did, 54000 is 15 minutes
|
||||
reopen=true,
|
||||
data={
|
||||
high_rank= 'Owner',
|
||||
low_rank= 'Regular',
|
||||
low={
|
||||
{'chat-bot.join-us'},
|
||||
{'chat-bot.discord'},
|
||||
{'chat-bot.website'},
|
||||
{'chat-bot.custom-commands'},
|
||||
{'chat-bot.read-readme'}
|
||||
}
|
||||
}
|
||||
}:on_event('timeout',function(self)
|
||||
local data = self.data
|
||||
if not data.high_rank or not data.low_rank
|
||||
or not data.low then self.reopen = false return end
|
||||
local _high = Ranking.get_rank(data.high_rank)
|
||||
game.print{'chat-bot.message',{'chat-bot.players-online',#game.connected_players}}
|
||||
game.print{'chat-bot.message',{'chat-bot.map-time',tick_to_display_format(game.tick)}}
|
||||
--[[local _low = Ranking.get_rank(data.low_rank)
|
||||
Ranking.print(_high,{'chat-bot.players-online',#game.connected_players},nil,true)
|
||||
Ranking.print(_high,{'chat-bot.map-time',tick_to_display_format(game.tick)},nil,true)
|
||||
for _,line in pairs(data.low) do
|
||||
Ranking.print(_low,line,nil,true)
|
||||
end]]
|
||||
self.reopen = true
|
||||
end):on_event(defines.events.on_player_joined_game,function(self,event)
|
||||
local player = Game.get_player(event)
|
||||
if not player then return end
|
||||
local data = self.data
|
||||
if not data.high_rank or not data.low_rank
|
||||
or not data.low then self.reopen = false return end
|
||||
-- idk but this stoped working for no appent reason so i added more checks for nil values
|
||||
if Ranking.get_rank(player).power <= Ranking.get_rank(data.low_rank).power then return end
|
||||
for _,message in pairs(data.low) do
|
||||
player_return({'chat-bot.message',message},nil,player)
|
||||
end
|
||||
end):on_event('error',function(self,err)
|
||||
Sync.emit_embeded{
|
||||
title='Auto Message Error',
|
||||
color=Color.to_hex(defines.text_color.bg),
|
||||
description='Auto Message Error - Closed Thread',
|
||||
Error=err
|
||||
}
|
||||
self.reopen = false
|
||||
self:close()
|
||||
end):open()
|
||||
end)
|
||||
47
to convert/Addons/Admin/base-damage.lua
Normal file
47
to convert/Addons/Admin/base-damage.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
-- alot of this is copied from redmew - but it has been reworked to use the ExpCore
|
||||
-- https://github.com/Valansch/RedMew/blob/develop/nuke_control.lua
|
||||
|
||||
local function _damage(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.damage = not reset and global.addons.damage or {}
|
||||
return global.addons.damage
|
||||
end
|
||||
|
||||
Event.register(defines.events.on_entity_damaged,function(event)
|
||||
if event.force == nil or event.force ~= event.entity.force then return end
|
||||
if event.cause == nil or event.cause.name ~= 'player' then return end
|
||||
local player = Game.get_player(event.cause.player)
|
||||
if Ranking.get_rank(player):allowed('base-damage') then return end
|
||||
if not _damage()[player.index] then _damage()[player.index] = {0,0} end
|
||||
_damage()[player.index][1] = _damage()[player.index][1]+event.final_damage_amount
|
||||
if _damage()[player.index][2] < event.tick-300 then
|
||||
_damage()[player.index][2] = event.tick
|
||||
player_return({'base-damage.used'},defines.text_color.med,player)
|
||||
Admin.give_warning(player,'<server>','Damaged something inside the base. Total Delt: '.._damage()[player.index][1],4)
|
||||
end
|
||||
end)
|
||||
|
||||
Event.register(defines.events.on_player_ammo_inventory_changed,function(event)
|
||||
local player = Game.get_player(event)
|
||||
if Ranking.get_rank(player):allowed('nuke') then return end
|
||||
local found = player.remove_item({name='atomic-bomb',count=1000})
|
||||
if not _damage()[player.index] then _damage()[player.index] = {0,0} end
|
||||
if found > 0 then
|
||||
Admin.move_item_to_spawn({name='atomic-bomb',count=found},player.surface)
|
||||
player_return({'base-damage.nuke'},defines.text_color.med,player)
|
||||
if _damage()[player.index][2] < event.tick-300 then
|
||||
_damage()[player.index][2] = event.tick
|
||||
Admin.give_warning(player,'<server>','Nukes are not allowed for your rank.',4)
|
||||
end
|
||||
end
|
||||
end)
|
||||
54
to convert/Addons/Admin/discord.lua
Normal file
54
to convert/Addons/Admin/discord.lua
Normal file
@@ -0,0 +1,54 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
Event.register(defines.events.on_console_command,function(event)
|
||||
local command = event.command
|
||||
local args = {}
|
||||
if event.parameters then for word in event.parameters:gmatch('%S+') do table.insert(args,word) end end
|
||||
local data = {}
|
||||
data.title = string.gsub(command,'^%l',string.upper)
|
||||
data.by = event.player_index and game.players[event.player_index].name or '<server>'
|
||||
if data.by == '<server>' then return end
|
||||
if command == 'config' or command == 'banlist' then
|
||||
Sync.emit_embeded{
|
||||
title='Edit To '..data.title,
|
||||
color=Color.to_hex(defines.text_color.bg),
|
||||
description='A player edited the '..command..'.',
|
||||
['By:']=data.by,
|
||||
['Edit:']=table.concat(args,' ',1)
|
||||
}
|
||||
else
|
||||
if command == 'ban' then
|
||||
data.colour = Color.to_hex(defines.text_color.crit)
|
||||
data.reason = table.concat(args,' ',2)
|
||||
elseif command == 'kick' then
|
||||
data.colour = Color.to_hex(defines.text_color.high)
|
||||
data.reason = table.concat(args,' ',2)
|
||||
elseif command == 'unban' then data.colour = Color.to_hex(defines.text_color.low)
|
||||
elseif command == 'mute' then data.colour = Color.to_hex(defines.text_color.med)
|
||||
elseif command == 'unmute' then data.colour = Color.to_hex(defines.text_color.low)
|
||||
elseif command == 'promote' then data.colour = Color.to_hex(defines.text_color.info)
|
||||
elseif command == 'demote' then data.colour = Color.to_hex(defines.text_color.info)
|
||||
elseif command == 'purge' then data.colour = Color.to_hex(defines.text_color.med)
|
||||
else return end
|
||||
data.username = args[1]
|
||||
if not Game.get_player(data.username) then return end
|
||||
if string.sub(command,-1) == 'e' then data.command = command..'d' else data.command = command..'ed' end
|
||||
data.reason = data.reason and data.reason ~= '' and data.reason or 'No Reason Required'
|
||||
Sync.emit_embeded{
|
||||
title='Player '..data.title,
|
||||
color=data.colour,
|
||||
description='There was a player '..data.command..'.',
|
||||
['Player:']='<<inline>>'..data.username,
|
||||
['By:']='<<inline>>'..data.by,
|
||||
['Reason:']=data.reason
|
||||
}
|
||||
end
|
||||
end)
|
||||
79
to convert/Addons/Admin/inventory-search.lua
Normal file
79
to convert/Addons/Admin/inventory-search.lua
Normal file
@@ -0,0 +1,79 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
-- removed from none admin ranks, no further action
|
||||
local low_items = {
|
||||
'loader',
|
||||
'fast-loader',
|
||||
'express-loader',
|
||||
'small-plane',
|
||||
'player-port',
|
||||
'coin',
|
||||
'programmable-speaker'
|
||||
}
|
||||
|
||||
-- removed for admin and non-admin ranks, gives warnings to non-admins
|
||||
local med_items = {
|
||||
'railgun',
|
||||
'railgun-dart',
|
||||
'belt-immunity-equipment'
|
||||
}
|
||||
|
||||
-- temp-ban for any rank, this is a very hard enforcement, admin ranks lose rank
|
||||
local high_items = {
|
||||
'electric-energy-interface',
|
||||
'infinity-chest'
|
||||
}
|
||||
|
||||
local inventorys = {
|
||||
defines.inventory.player_main,
|
||||
defines.inventory.player_quickbar,
|
||||
defines.inventory.player_trash
|
||||
}
|
||||
|
||||
local _root_tree = {low_items=low_items,med_items=med_items,high_items=high_items}
|
||||
|
||||
local function take_action(player,item_name,category)
|
||||
if category == 'low_items' then player_return({'inventory-search.low',item_name},defines.text_color.med,player)
|
||||
elseif category == 'med_items' then player_return({'inventory-search.med',item_name},defines.text_color.high,player) Admin.give_warning(player,'<server>','Found A Banned Item',5)
|
||||
elseif category == 'high_items' then player_return({'inventory-search.high',item_name},defines.text_color.crit,player) Admin.temp_ban(player,'<server>','Found A Banned Item')
|
||||
else return end
|
||||
end
|
||||
|
||||
function search_player(player)
|
||||
for category,items in pairs(_root_tree) do
|
||||
if category ~= 'low_items' or not Ranking.get_rank(player):allowed('admin-items') then
|
||||
for _,_inventory in pairs(inventorys) do
|
||||
local inventory = player.get_inventory(_inventory)
|
||||
if inventory then
|
||||
for _,item in pairs(items) do
|
||||
local found = inventory.remove(item)
|
||||
if found > 0 then take_action(player,item,category) end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.register({defines.events.on_player_main_inventory_changed,defines.events.on_player_quickbar_inventory_changed},function(event)
|
||||
local player = Game.get_player(event)
|
||||
if player and player.name == 'freek18' then search_player(player) end
|
||||
end)
|
||||
|
||||
Event.register(defines.events.on_tick,function(event)
|
||||
if (game.tick%900) == 0 then
|
||||
local players = game.connected_players
|
||||
if #players == 0 then return end
|
||||
local player = players[math.random(#players)]
|
||||
if Ranking.get_rank(player):allowed('all-items') then return end
|
||||
search_player(player)
|
||||
end
|
||||
end)
|
||||
40
to convert/Addons/Admin/player-info.lua
Normal file
40
to convert/Addons/Admin/player-info.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
function get_player_info(player,frame,add_cam)
|
||||
local player = Game.get_player(player)
|
||||
if not player then return {} end
|
||||
local _player = {}
|
||||
_player.index = player.index
|
||||
_player.name = player.name
|
||||
_player.online = player.connected
|
||||
_player.tag = player.tag
|
||||
_player.color = player.color
|
||||
_player.admin = player.admin
|
||||
_player.online_time = player.online_time
|
||||
_player.rank = Ranking.get_rank(player).name
|
||||
_player.group = Ranking.get_group(player).name
|
||||
if frame then
|
||||
local frame = frame.add{type='frame',direction='vertical',style='image_frame'}
|
||||
frame.style.width = 200
|
||||
frame.style.height = 275
|
||||
frame.add{type='label',caption={'player-info.name',_player.index,_player.name},style='caption_label'}
|
||||
local _online = {'player-info.no'}; if _player.online then _online = {'player-info.yes'} end
|
||||
frame.add{type='label',caption={'player-info.online',_online,tick_to_display_format(_player.online_time)}}
|
||||
local _admin = {'player-info.no'}; if _player.admin then _admin = {'player-info.yes'} end
|
||||
frame.add{type='label',caption={'player-info.admin',_admin}}
|
||||
frame.add{type='label',caption={'player-info.group',_player.group}}
|
||||
frame.add{type='label',caption={'player-info.rank',_player.rank}}
|
||||
if add_cam then
|
||||
Gui.cam_link{entity=player.character,frame=frame,width=200,height=150,zoom=0.5,respawn_open=true}
|
||||
end
|
||||
end
|
||||
return _player
|
||||
end
|
||||
276
to convert/Addons/Admin/reports.lua
Normal file
276
to convert/Addons/Admin/reports.lua
Normal file
@@ -0,0 +1,276 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local report_to_warnings = 1 -- used in count_reports
|
||||
local varified_to_warings = 3 -- used in count_reports
|
||||
local reports_needed_for_jail = 6
|
||||
local min_time_to_remove_warning = 18000 -- this is in ticks
|
||||
local take_action = 8 -- below this number no action is taken, the first admin given warning jumps to this number
|
||||
local punishments = {
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'message',{'reports.message'},defines.text_color.info},
|
||||
{'message',{'reports.message'},defines.text_color.info},
|
||||
{'report',{'reports.reported'},defines.text_color.med},
|
||||
{'message',{'reports.kick-warn'},defines.text_color.med},
|
||||
{'kick'},
|
||||
{'message',{'reports.temp-warn'},defines.text_color.high},
|
||||
{'temp-ban'},
|
||||
{'message',{'reports.ban-warn'},defines.text_color.high},
|
||||
{'message',{'reports.last-warn'},defines.text_color.crit},
|
||||
{'ban'}
|
||||
}
|
||||
|
||||
local actions = {
|
||||
none=0,
|
||||
report=1,
|
||||
jail=2,
|
||||
kick=3,
|
||||
temp=4,
|
||||
ban=5
|
||||
}
|
||||
|
||||
local function valid_players(player,by_player)
|
||||
local player = Game.get_player(player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
local rank = Ranking.get_rank(by_player_name)
|
||||
return player, by_player_name, rank
|
||||
end
|
||||
|
||||
local function _reports(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.reports = not reset and global.addons.reports or {warnings={},reports={},varified={},actions={}}
|
||||
return global.addons.reports
|
||||
end
|
||||
|
||||
local function get_warnings(player)
|
||||
local player = Game.get_player(player)
|
||||
return _reports().warnings[player.name] or 0
|
||||
end
|
||||
|
||||
local function report_message(player,by_player,reason)
|
||||
local low_rank = Ranking.get_group('User').highest
|
||||
local high_rank = Ranking.get_group('Admin').lowest
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
if _reports().actions[player.name] == actions.report then return end
|
||||
Ranking.print(low_rank,{'reports.low-print',player.name,reason},defines.text_color.info,true)
|
||||
Ranking.print(high_rank,{'reports.high-print',player.name,by_player_name,reason},defines.text_color.med)
|
||||
Sync.emit_embeded{
|
||||
title='Player Report',
|
||||
color=Color.to_hex(defines.text_color.med),
|
||||
description='A player was reported.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=reason
|
||||
}
|
||||
end
|
||||
|
||||
local function count_reports(player)
|
||||
local player = Game.get_player(player)
|
||||
if not player then return 0 end
|
||||
local _count = 0
|
||||
local data = _reports()
|
||||
if data.reports[player.name] then
|
||||
for _,report in pairs(data.reports[player.name]) do
|
||||
_count=_count+report_to_warnings
|
||||
end
|
||||
end
|
||||
if data.varified[player.name] then
|
||||
for _,report in pairs(data.varified[player.name]) do
|
||||
_count=_count+varified_to_warings
|
||||
end
|
||||
end
|
||||
return _count
|
||||
end
|
||||
|
||||
local function cheak_reports(player)
|
||||
local player = Game.get_player(player)
|
||||
if not player then return end
|
||||
local reports = count_reports(player)
|
||||
if reports >= reports_needed_for_jail and _reports().actions[player.name] ~= 'report-jail' and Ranking.get_rank(player).group.name ~= 'Jail' then
|
||||
_reports().actions[player.name] = actions.report
|
||||
Admin.jail(player,'<server>','Too many user reports. Contact an Admin to be unjailed.')
|
||||
end
|
||||
end
|
||||
|
||||
local function give_punishment(player,by_player,reason)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
local warnings = get_warnings(player)
|
||||
local punishment = punishments[warnings]
|
||||
local reason = reason or 'No Other Reason'
|
||||
if not punishment or punishment[1] == 'nothing' then return
|
||||
elseif punishment[1] == 'message' then
|
||||
local message = punishment[2]
|
||||
local colour = punishment[3]
|
||||
player_return(message,colour,player)
|
||||
elseif punishment[1] == 'report' then
|
||||
local message = punishment[2]
|
||||
local colour = punishment[3]
|
||||
player_return(message,colour,player)
|
||||
report_message(player,'<server>',reason)
|
||||
elseif punishment[1] == 'kick' then
|
||||
_reports().actions[player.name] = actions.kick
|
||||
Admin.kick(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
|
||||
elseif punishment[1] == 'temp-ban' then
|
||||
--_reports().actions[player.name] = actions.temp -- see Admin.temp-ban
|
||||
Admin.temp_ban(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
|
||||
elseif punishment[1] == 'ban' then
|
||||
_reports().actions[player.name] = actions.ban
|
||||
Admin.ban(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
|
||||
end
|
||||
end
|
||||
|
||||
function Admin.give_warning(player,by_player,reason,min)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
local min = Game.get_player(by_player) and take_action or min or 0
|
||||
local warnings = get_warnings(player)
|
||||
if warnings < min then warnings = min end
|
||||
warnings = warnings+1
|
||||
_reports().warnings[player.name] = warnings
|
||||
if warnings > take_action then
|
||||
player_return({'reports.warning-given-by',by_player_name},defines.text_color.info,player)
|
||||
game.print({'reports.player-warning',player.name,by_player_name,reason})
|
||||
end
|
||||
give_punishment(player,by_player,reason)
|
||||
end
|
||||
|
||||
function Admin.report(player,by_player,reason)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player or Ranking.get_rank(player):allowed('no-report') then return end
|
||||
if Admin.is_banned(by_player) or Ranking.get_group(by_player).name == 'Jail' then return end
|
||||
if Ranking.get_rank(by_player):allowed('varified') then
|
||||
_reports().varified[player.name] = _reports().varified[player.name] or {}
|
||||
local reports = _reports().varified[player.name]
|
||||
for _,value in pairs(reports) do
|
||||
if value[1] == by_player_name then return end
|
||||
end
|
||||
table.insert(reports,{by_player_name,reason})
|
||||
else
|
||||
_reports().reports[player.name] = _reports().reports[player.name] or {}
|
||||
local reports = _reports().reports[player.name]
|
||||
for _,value in pairs(reports) do
|
||||
if value[1] == by_player_name then return end
|
||||
end
|
||||
table.insert(reports,{by_player_name,reason})
|
||||
end
|
||||
report_message(player,by_player,reason)
|
||||
cheak_reports(player)
|
||||
end
|
||||
|
||||
function Admin.clear_warings(player,by_player,no_emit)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
_reports().warnings[player.name]=0
|
||||
if not no_emit then
|
||||
Sync.emit_embeded{
|
||||
title='Player Clear',
|
||||
color=Color.to_hex(defines.text_color.low),
|
||||
description='A player had their warnings cleared.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function Admin.clear_reports(player,by_player,no_emit)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
_reports().reports[player.name]={}
|
||||
_reports().varified[player.name]={}
|
||||
if not no_emit then
|
||||
Sync.emit_embeded{
|
||||
title='Player Clear',
|
||||
color=Color.to_hex(defines.text_color.low),
|
||||
description='A player had their reports cleared.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function Admin.clear_player(player,by_player)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
Admin.clear_warings(player,by_player,true)
|
||||
Admin.clear_reports(player,by_player,true)
|
||||
_reports().actions[player.name]=actions.none
|
||||
if Ranking.get_rank(player).group.name == 'Jail' then Server.interface(Ranking.revert,true,player,by_player) end
|
||||
Sync.emit_embeded{
|
||||
title='Player Clear',
|
||||
color=Color.to_hex(defines.text_color.low),
|
||||
description='A player had their reports and warnings cleared.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
}
|
||||
end
|
||||
|
||||
function Admin.temp_ban(player,by_player,reason)
|
||||
local function append_name(reason,name)
|
||||
local reason = reason or 'No Reason'
|
||||
if not string.find(string.lower(reason),string.lower(name)) then return reason..' - '..name
|
||||
else return reason end
|
||||
end
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player or Admin.is_banned(player) then return end
|
||||
_reports().actions[player.name] = actions.temp
|
||||
Sync.emit_embeded{
|
||||
title='Player Temp-Ban',
|
||||
color=Color.to_hex(defines.text_color.high),
|
||||
description='A player was jailed.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=append_name(reason,by_player_name)
|
||||
}
|
||||
game.print({'reports.temp-ban',player.name,by_player_name,reason},defines.text_color.info)
|
||||
Admin.move_inventory(player)
|
||||
Ranking._presets().last_jail = player.name
|
||||
Server.interface(Ranking.give_rank,true,player,'Jail',by_player_name)
|
||||
end
|
||||
|
||||
function Admin.is_banned(player)
|
||||
local player=Game.get_player(player)
|
||||
if not player then return false end
|
||||
local action = _reports().actions[player.name]
|
||||
if action == actions.temp then return 'temp'
|
||||
elseif action == actions.ban then return true
|
||||
else return false end
|
||||
end
|
||||
|
||||
Event.register(defines.events.on_tick,function(event)
|
||||
if not _reports().remove_warnings_time then
|
||||
_reports().remove_warnings_time = {}
|
||||
local highest = nil
|
||||
for power,rank in pairs(Ranking._ranks()) do
|
||||
if not highest and not rank:allowed('no-report') then highest = power-1 end
|
||||
local _power = power; if highest then _power = power-highest end
|
||||
if rank:allowed('no-report') then _reports().remove_warnings_time[power] = 0
|
||||
else _reports().remove_warnings_time[power] = min_time_to_remove_warning*_power end
|
||||
end
|
||||
end
|
||||
if (game.tick % min_time_to_remove_warning) == 0 then
|
||||
for name,warnings in pairs(_reports().warnings) do
|
||||
if warnings > 0 then
|
||||
local rank = Ranking.get_rank(name)
|
||||
local time_to_remove = _reports().remove_warnings_time[rank.power]
|
||||
if (game.tick % time_to_remove) == 0 then
|
||||
_reports().warnings[name]=warnings-1
|
||||
if _reports().warnings[name] > 5 then
|
||||
player_return({'reports.remove-warn',_reports().warnings[name],tick_to_display_format(time_to_remove)},defines.text_color.low,name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
54
to convert/Addons/Admin/tree-decon.lua
Normal file
54
to convert/Addons/Admin/tree-decon.lua
Normal file
@@ -0,0 +1,54 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
Event.register(-1,function(event)
|
||||
Server.new_thread{
|
||||
name='tree-decon',
|
||||
data={trees={},chache={},clear=0}
|
||||
}:on_event('tick',function(self)
|
||||
local trees = self.data.trees
|
||||
if self.data.clear ~= 0 and self.data.clear < game.tick then self.data.chache = {} self.data.clear = 0 end
|
||||
if #trees == 0 then return end
|
||||
for i = 0,math.ceil(#trees/10) do
|
||||
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,function(self,event)
|
||||
local chache = self.data.chache[event.player_index]
|
||||
if not chache then
|
||||
local player = Game.get_player(event)
|
||||
if not player then return end
|
||||
local rank = Ranking.get_rank(player)
|
||||
if rank:allowed('tree-decon') then self.data.chache[event.player_index] = {'tree-decon',false}
|
||||
elseif not rank:allowed('decon') then self.data.chache[event.player_index] = {'no-decon',false}
|
||||
else self.data.chache[event.player_index] = {'decon',false} 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({'tree-decon.player-print'},defines.text_color.crit,player)
|
||||
local rank = Ranking.get_group('Admin').lowest
|
||||
Ranking.print(rank,{'tree-decon.rank-print',player.name},defines.text_color.info)
|
||||
Admin.give_warning(player,'<server>','Trying To Decon The Base')
|
||||
end
|
||||
self.data.clear = game.tick + 10
|
||||
end
|
||||
end
|
||||
end):open()
|
||||
end)
|
||||
Reference in New Issue
Block a user