Added Capsul Events

This commit is contained in:
Cooldude2606
2018-01-07 13:56:13 +00:00
parent cb85ebfd2b
commit 0ab553efbf
5 changed files with 61 additions and 4 deletions

View File

@@ -67,8 +67,8 @@ local inventorys = {
defines.inventory.player_armor
}
local function put_item_in_chests(chests,item,surface)
local chests = chests
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)
@@ -90,7 +90,7 @@ function Admin.move_inventory(player)
local inventory = player.get_inventory(_inventory)
for item,count in pairs(inventory.get_contents()) do
local item = {name=item,count=count}
chests = put_item_in_chests(chests,item,player.surface)
chests = Admin.move_item_to_spawn(item,player.surface,chests)
end
inventory.clear()
end

53
Addons/Admin/capsules.lua Normal file
View File

@@ -0,0 +1,53 @@
--[[
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 const = 8 -- this is how many entites must be found in order to give a warning
-- false means that it cant be used
local capsules = {
['artillery-targeting-remote']=false,
['cliff-explosives']=true,
['cluster-grenade']=false,
['defender-capsule']=true,
['destroyer-capsule']=true,
['discharge-defense-remote']=true,
['distractor-capsule']=true,
['grenade']=false,
['poison-capsule']=false,
['raw-fish']=true,
['slowdown-capsule']=true,
}
Event.register(defines.events.on_player_used_capsule,function(event)
local player = Game.get_player(event)
local item = event.item
if capsules[item.name] or Ranking.get_rank(player):allowed('capsules') then return end
local x,y = event.position.x, event.position.y
local player_entities = player.surface.count_entities_filtered{
force=player.force,
area={{x-5,y-5},{x+5,y+5}}
}
if player_entities < const then return end
player_return({'capsules.used',item.name},defines.text_color.med,player)
Admin.give_warning(player,'<server>','Using '..item.name..' inside the base.',4)
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})
Admin.move_item_to_spawn({name='atomic-bomb',count=found},player.surface)
if found > 0 then
player_return({'capsules.nuke'},defines.text_color.med,player)
Admin.give_warning(player,'<server>','Nukes are not allowed for your rank.',4)
end
end)

View File

@@ -30,7 +30,7 @@ Event.register(-1,function(event)
else self.data.chache[event.player_index] = {'decon',false} end
chache = self.data.chache[event.player_index]
end
if not event.entity.last_user then
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

View File

@@ -24,6 +24,7 @@ require('Admin/discord')
require('Admin/auto-message')
require('Admin/tree-decon')
require('Admin/inventory-search')
require('Admin/capsules')
-- commands dir
require('Commands/cheat-mode')

3
locale/en/capsules.cfg Normal file
View File

@@ -0,0 +1,3 @@
[capsules]
used=You used __1__ are it hit some of your own buildings, please be more careful, atleast there was no damage.
nuke=Nukes are not allowed for your rank, this is just a way to help provent grifers.