mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 19:45:22 +09:00
Added go-to-spawn and clear-inventory
This commit is contained in:
@@ -11,6 +11,7 @@ local Public = {
|
||||
player_temp_banned=script.generate_event_name(),
|
||||
player_clear_temp_ban=script.generate_event_name()
|
||||
}
|
||||
|
||||
Global.register({
|
||||
Public.old_roles,
|
||||
Public.temp_bans
|
||||
|
||||
12
modules/commands/clear-inventory.lua
Normal file
12
modules/commands/clear-inventory.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
local Commands = 'expcore.commands'
|
||||
local move_items = ext_require('expcore.common','move_items')
|
||||
require 'config.command_parse_roles'
|
||||
|
||||
Commands.new_command('clear-inventory','Clears a players inventory')
|
||||
:add_param('player',false,'player-role-alive')
|
||||
:add_alias('clear-inv','move-inventory','move-inv')
|
||||
:register(function(player,action_player)
|
||||
local inv = action_player.get_main_inventory()
|
||||
move_items(inv.get_contents())
|
||||
inv.clear()
|
||||
end)
|
||||
38
modules/commands/spawn.lua
Normal file
38
modules/commands/spawn.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
local Commands = require 'expcore.commands'
|
||||
local Roles = require 'expcore.roles'
|
||||
|
||||
local function teleport(player)
|
||||
local surface = player.surface
|
||||
local spawn = player.force.get_spawn_position(surface)
|
||||
local position = surface.find_non_colliding_position('player',spawn,32,1)
|
||||
if not position then return false end
|
||||
if player.driving then player.driving = false end -- kicks a player out a vehicle if in one
|
||||
player.teleport(position,surface)
|
||||
return true
|
||||
end
|
||||
|
||||
Commands.new_command('go-to-spawn','Teleport to spawn')
|
||||
:add_param('player',true,'player-role-alive')
|
||||
:add_defaults{
|
||||
player=function(player)
|
||||
if player.connected and player.character and player.character.health > 0 then
|
||||
return player
|
||||
end
|
||||
end
|
||||
}
|
||||
:add_alias('spawn','tp-spawn')
|
||||
:register(function(player,action_player)
|
||||
if not action_player then
|
||||
return Commands.error{'exp-commands.spawn-unavailable'}
|
||||
elseif action_player == player then
|
||||
if not teleport(player) then
|
||||
return Commands.error{'exp-commands.spawn-unavailable'}
|
||||
end
|
||||
elseif Roles.player_allowed(player,'command/go-to-spawn/always') then
|
||||
if not teleport(action_player) then
|
||||
return Commands.error{'exp-commands.spawn-unavailable'}
|
||||
end
|
||||
else
|
||||
return Commands.error{'expcore-commands.unauthorized'}
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user