Author Topic: Simple Hopper  (Read 3890 times)

0 Members and 1 Guest are viewing this topic.

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Simple Hopper
« on: April 16, 2015, 04:02:25 PM »
SIMPLE SERVER HOPPER

Fixed the unknown command error!

Ok so this is my FIRST derma! When you see the derma you will see... its not a very good derma but i might make it better in the future! This has button that you can press to connect to a different server of YOUR choice! Config in: simple_hopper/lua/autorun/hopper.lua

Put the simple_hopper folder in garrysmod/addons thats it!

Steam workshop page: Click Here

To do list:
  • Make better design
  • Add to ULX
  • Remove from ULX

NEW YOUTUBE VIDEO

You can open the hopper by typing !hopper in chat or by typing +hopper in console (ulx hopper also works in console)

NOW DOES NOT NEED ULX!!!

WARNING: PLEASE DO NOT HATE ON THIS BECAUSE ITS NOT THE BEST DERMA ITS BASIC AND THATS WHY ITS CALLED SIMPLE SERVER HOPPER THANKS
« Last Edit: May 19, 2015, 03:07:44 PM by XxLMM13xX »

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Simple Hopper
« Reply #1 on: April 16, 2015, 04:48:53 PM »
Some suggetions:

ulx\modules\sh\hopper.lua on line 9
Code: Lua
  1. ply = calling_ply:Name()
This line is completely useless as you never actually use it, you could cut it out and be fine.


Also, the way you make your GUI, is a bit tedious.  While what you have probably works just fine, you could just put everything in tables and a for loop and make the code 1/5 of what it is now.

Otherwise seems like a decent addon.

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: Simple Hopper
« Reply #2 on: April 16, 2015, 05:04:39 PM »
Some suggetions:

ulx\modules\sh\hopper.lua on line 9
Code: Lua
  1. ply = calling_ply:Name()
This line is completely useless as you never actually use it, you could cut it out and be fine.


Also, the way you make your GUI, is a bit tedious.  While what you have probably works just fine, you could just put everything in tables and a for loop and make the code 1/5 of what it is now.


Otherwise seems like a decent addon.

i made this really quick so i probably used that to test something! I will remove it! Also i dont know what you mean what will the table help?

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: Simple Hopper
« Reply #3 on: April 17, 2015, 09:05:26 AM »
ATTENTION: I HAVE FIXED THE UNKNOWN COMMAND ERROR!!!

Download the new version to fix!

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: Simple Hopper
« Reply #4 on: April 22, 2015, 02:02:08 PM »
Added a new youtube video AND a  link to the workshop!

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: Simple Hopper
« Reply #5 on: April 25, 2015, 03:00:51 PM »
I see why you said this requires ULX/ULiB in your post on the Steam Workshop for this
I'm not sure, however, why you went through the trouble of making a whole new file just to add it as a command in ULX when you could have added the console command ("ulx hopper" --as it is now) in one line and the chat command in 5
Code: Lua
  1. hook.Add("PlayerSay", "ChatCommandForHopper", function()
  2. if (text=="!hopper" then)
  3. ply:ConCommand("+hopper")
  4. end
  5. end )
(Don't mind the retarded spacing, I typed the code in Chrome)

That doesn't really matter tho

As for the table/for loop (as Aaron mentioned):
I think he meant you could add all of your servers into a table and then loop through it (via a for loop) and with each occurrence, you would create a new DButton and DLabel with that server's name & IP, therefor removing the need for repeatedly and tediously making a new dlabel and dbutton like you did here:

Code: Lua
  1.         local connect1 = vgui.Create( "DButton", HopperDerma )
  2.         connect1:SetPos( 50, 50 )
  3.         connect1:SetText( "Connect" )
  4.         connect1.DoClick = function()
  5.         LocalPlayer():ConCommand( "connect "..serverip1 )
  6.         HopperDerma:Close()
  7.         end
  8.        
  9.         local connect1L = vgui.Create( "DLabel", HopperDerma )
  10.         connect1L:SetPos( 120, 50 )
  11.         connect1L:SetSize( 900, 20 )
  12.         connect1L:SetText( servername1 )
  13.        
  14.         local connect2 = vgui.Create( "DButton", HopperDerma )
  15.         connect2:SetPos( 50, 75 )
  16.         connect2:SetText( "Connect" )
  17.         connect2.DoClick = function()
  18.         LocalPlayer():ConCommand("connect "..serverip2)
  19.         HopperDerma:Close()
  20.         end
  21.        
  22.         local connect2L = vgui.Create( "DLabel", HopperDerma )
  23.         connect2L:SetPos( 120, 75 )
  24.         connect2L:SetSize( 900, 15 )
  25.         connect2L:SetText( servername2 )
  26.        
  27.         local connect3 = vgui.Create( "DButton", HopperDerma )
  28.         connect3:SetPos( 50, 100 )
  29.         connect3:SetText( "Connect" )
  30.         connect3.DoClick = function()
  31.         LocalPlayer():ConCommand("connect "..serverip3)
  32.         HopperDerma:Close()
  33.         end
  34.        
  35.         local connect3L = vgui.Create( "DLabel", HopperDerma )
  36.         connect3L:SetPos( 120, 100 )
  37.         connect3L:SetSize( 900, 10 )
  38.         connect3L:SetText( servername3 )       
  39.        
  40.         local connect4 = vgui.Create( "DButton", HopperDerma )
  41.         connect4:SetPos( 50, 125 )
  42.         connect4:SetText( "Connect" )
  43.         connect4.DoClick = function()
  44.         LocalPlayer():ConCommand("connect "..serverip4)
  45.         HopperDerma:Close()
  46.         end
  47.  
  48.         local connect4L = vgui.Create( "DLabel", HopperDerma )
  49.         connect4L:SetPos( 120, 125 )
  50.         connect4L:SetSize( 900, 10 )
  51.         connect4L:SetText( servername4 )       
  52.        
  53.         local close = vgui.Create( "DButton", HopperDerma )
  54.         close:SetPos( 110, 250 )
  55.         close:SetText( "Close" )
  56.         close.DoClick = function()
  57.         HopperDerma:Close()
  58.         end

I've been working with tables a lot lately and they are incredibly useful

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: Simple Hopper
« Reply #6 on: April 25, 2015, 03:20:10 PM »
Yes i understand why i SHOULD use a table but hey copy and paste worked here also... i'm mainly focused on working on a better design

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: Simple Hopper
« Reply #7 on: May 19, 2015, 03:09:32 PM »
NEW VERSION

Removed the ULX part and added a version check!