From d227ad90d61a49c37225efb48390788e366dd08d Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sat, 14 Apr 2018 19:31:02 +0100 Subject: [PATCH] Added Home Commands --- Addons/Commands/home.lua | 37 +++++++++++++++++++++++++++++++++++++ Addons/load.lua | 1 + Addons/playerRanks.lua | 5 ++++- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 Addons/Commands/home.lua diff --git a/Addons/Commands/home.lua b/Addons/Commands/home.lua new file mode 100644 index 00000000..4ea2d3a7 --- /dev/null +++ b/Addons/Commands/home.lua @@ -0,0 +1,37 @@ +--[[ +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 function homes(reset) + global.addons = not reset and global.addons or {} + global.addons.homes = not reset and global.addons.homes or {} + return global.addons.homes +end + +commands.add_command('set-home', 'Set Your Home Possition', {}, function(event,args) + local player = Game.get_player(event) + if not homes()[player.index] then homes()[player.index] = {player.force.get_spawn_position(player.surface),player.force.get_spawn_position(player.surface)} end + homes()[player.index][1] = player.position + player_return('Home set at: ('..math.floor(player.position.x)..','..math.floor(player.position.y)..')') +end) + +commands.add_command('home', 'Goto you home possition', {}, function(event,args) + local player = Game.get_player(event) + if not homes()[player.index] then homes()[player.index] = {player.force.get_spawn_position(player.surface),player.force.get_spawn_position(player.surface)} end + homes()[player.index][2] = player.position + player.teleport(player.surface.find_non_colliding_position('player',homes()[player.index][1],32,1),player.surface) +end) + +commands.add_command('return', 'Goto where you were before using /home', {}, function(event,args) + local player = Game.get_player(event) + if not homes()[player.index] then homes()[player.index] = {player.force.get_spawn_position(player.surface),player.force.get_spawn_position(player.surface)} end + local _temp = player.position + player.teleport(player.surface.find_non_colliding_position('player',homes()[player.index][2],32,1),player.surface) + homes()[player.index][2] = _temp +end) \ No newline at end of file diff --git a/Addons/load.lua b/Addons/load.lua index 87dec82c..6ca2e7ea 100644 --- a/Addons/load.lua +++ b/Addons/load.lua @@ -26,6 +26,7 @@ require('Commands/cheat-mode') require('Commands/kill') require('Commands/repair') require('Commands/tags') +require('Commands/home') require('Commands/tp') -- requires Admin/admin require('Commands/admin') -- requires Admin/reports diff --git a/Addons/playerRanks.lua b/Addons/playerRanks.lua index bb333d86..4de2676f 100644 --- a/Addons/playerRanks.lua +++ b/Addons/playerRanks.lua @@ -184,7 +184,10 @@ ranks['Mod']:edit('allow',false,{ ranks['Donator']:edit('allow',false,{ ['global-chat']=true, ['jail']=true, - ['unjail']=true + ['unjail']=true, + ['set-home']=true, + ['home']=true, + ['return']=true }) ranks['Veteran']:edit('allow',false,{ ['tree-decon']=true,