From 2e017dbb706ab1e1efd30c7cbc24caf516d275ed Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 18 Apr 2019 22:44:17 +0100 Subject: [PATCH] Added go-to-spawn and clear-inventory --- .gitignore | 2 +- locale/en/commands.cfg | 3 +- modules/addons/jail-control.lua | 1 + modules/commands/clear-inventory.lua | 12 ++++++ modules/commands/spawn.lua | 38 +++++++++++++++++++ .../ExpAdmin}/ClearInventory/control.lua | 0 .../ExpAdmin}/ClearInventory/softmod.json | 0 7 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 modules/commands/clear-inventory.lua create mode 100644 modules/commands/spawn.lua rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/ClearInventory/control.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/ClearInventory/softmod.json (100%) diff --git a/.gitignore b/.gitignore index 4cf9699f..697e15f8 100644 --- a/.gitignore +++ b/.gitignore @@ -84,4 +84,4 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk -#*.vscode \ No newline at end of file +*.vscode \ No newline at end of file diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg index 182899f8..b35ff51f 100644 --- a/locale/en/commands.cfg +++ b/locale/en/commands.cfg @@ -33,4 +33,5 @@ warnings-received=__1__ recived a warning from __2__ for __3__. warnings-player=__1__ has __2__ warnings and __3__/__4__ script warnings. warnings-list-tilte=The following player have this many warnings (and this many script warnings): warnings-list=__1__: __2__ (__3__/__4__) -warnings-cleared=__1__ had all they warnings cleared by __2__. \ No newline at end of file +warnings-cleared=__1__ had all they warnings cleared by __2__. +spawn-unavailable=They was a problem getting you to spawn, please try again later. \ No newline at end of file diff --git a/modules/addons/jail-control.lua b/modules/addons/jail-control.lua index a65d6c2e..7e4aa526 100644 --- a/modules/addons/jail-control.lua +++ b/modules/addons/jail-control.lua @@ -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 diff --git a/modules/commands/clear-inventory.lua b/modules/commands/clear-inventory.lua new file mode 100644 index 00000000..28fd9d35 --- /dev/null +++ b/modules/commands/clear-inventory.lua @@ -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) \ No newline at end of file diff --git a/modules/commands/spawn.lua b/modules/commands/spawn.lua new file mode 100644 index 00000000..0b923222 --- /dev/null +++ b/modules/commands/spawn.lua @@ -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) \ No newline at end of file diff --git a/old/modules/ExpGamingAdmin/ClearInventory/control.lua b/old/modules/DONE/ExpAdmin/ClearInventory/control.lua similarity index 100% rename from old/modules/ExpGamingAdmin/ClearInventory/control.lua rename to old/modules/DONE/ExpAdmin/ClearInventory/control.lua diff --git a/old/modules/ExpGamingAdmin/ClearInventory/softmod.json b/old/modules/DONE/ExpAdmin/ClearInventory/softmod.json similarity index 100% rename from old/modules/ExpGamingAdmin/ClearInventory/softmod.json rename to old/modules/DONE/ExpAdmin/ClearInventory/softmod.json