forked from explosivegaming/ExpCluster
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
43 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- Config to control when players items are removed, this is a list of event names that will trigger inventory clear | ||
-- @config inventory_clear | ||
|
||
local events = defines.events | ||
return { | ||
events.on_player_banned, | ||
events.on_player_kicked, | ||
--events.on_player_left_game | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- Will move players items to spawn when they are banned or kicked, option to clear on leave | ||
-- @addon Inventory-Clear | ||
|
||
local Event = require 'utils.event' --- @dep utils.event | ||
local events = require 'config.inventory_clear' --- @dep config.inventory_clear | ||
local move_items = _C.move_items --- @dep expcore.common | ||
|
||
local function clear_items(event) | ||
local player = game.players[event.player_index] | ||
local inv = player.get_main_inventory() | ||
move_items(inv.get_contents()) | ||
inv.clear() | ||
end | ||
|
||
for _, event_name in ipairs(events) do Event.add(event_name, clear_items) end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters