From e8f86ac054a31928284c61c302bd15113e39adf6 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 27 Mar 2020 17:54:46 +0000 Subject: [PATCH] Made check for ext --- locale/en/commands.cfg | 2 ++ modules/gui/server-ups.lua | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg index ab475d4b..4f25d450 100644 --- a/locale/en/commands.cfg +++ b/locale/en/commands.cfg @@ -74,3 +74,5 @@ home-set=Your home point has been set to x: __1__ y: __2__ return-set=Your return point has been set to x: __1__ y: __2__ home-get=Your home point is at x: __1__ y: __2__ +[expcom-server-ups] +no-ext=No external source was found, cannot display server ups. \ No newline at end of file diff --git a/modules/gui/server-ups.lua b/modules/gui/server-ups.lua index 021dee03..5c48b019 100644 --- a/modules/gui/server-ups.lua +++ b/modules/gui/server-ups.lua @@ -25,6 +25,9 @@ Commands.new_command('server-ups','Toggle the server ups display') :add_alias('sups','ups') :register(function(player) local label = player.gui.screen[sverer_ups.name] + if not global.ext or not global.ext.server_ups then + return Commands.error{'expcom-server-ups.no-ext'} + end label.visible = not label.visible end) @@ -48,12 +51,11 @@ end) -- Update the caption for all online players Event.on_nth_tick(60,function() - local caption = 'Server UPS = 60.0' if global.ext and global.ext.server_ups then - caption = 'Server UPS = '..global.ext.server_ups - end - for _,player in pairs(game.connected_players) do - player.gui.screen[sverer_ups.name].caption = caption + local caption = 'Server UPS = '..global.ext.server_ups + for _,player in pairs(game.connected_players) do + player.gui.screen[sverer_ups.name].caption = caption + end end end)