ULX

Author Topic: Fun with lua_socket  (Read 7131 times)

0 Members and 3 Guests are viewing this topic.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Fun with lua_socket
« on: May 24, 2008, 08:52:36 PM »
So.. I discovered this awesome addon on facepunch last night called luasocket. It's winsock for lua.

Also.. just so happened that Id had lots of experience with sockets from VB.

So, I started a new project that I dub... GMSW (Garrysmod Server Watch)
HLSW is great.. but one thing that always bothered me about it was that (since it was not designed for gmod specifically) certain things that I would like to have access to were not sent to the log it retrieves. things such as prop spawning and such.

I already have a server program I made in VB that listens for connections from GMod lua_socket and I wrote a few hooks (prop spawning, chatting, disconnecting and connecting) and it sends this information to all people who have GMSW connected to the garrysmod server. Doesn't look as pretty as HLSW and I still havn't figured out how to quite receive data the OTHER WAY... so all it can do right now is receive data from the game and display it on the clients screens.

Work in progress.. if anyone is interested, I can post some source code or whatnot... keep in mind, however, this wouldn't run OOB.. you'd need lua_socket installed and working on your server.


Also.. planned features..
-Ability for users on the server to do a console/chat command to send a message to all users connected to the GMSW program. used as like.. a report/contact tool. (ex. !report Hey Pres, I need you to check out the server, someone is spamming) and then that would make the program on my computer play an alarm(or something most likely configurable) and do a popup window with the message. I realize the potential for abuse.. but I'll probably include some sort of safeguard.. such as a warning to all players who use it warning then that abuse will result in a ban or something.. and also probably restrict them to 1 report an hour or something along those lines.
« Last Edit: May 24, 2008, 09:04:09 PM by MrPresident »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Fun with lua_socket
« Reply #1 on: May 24, 2008, 10:18:04 PM »
Yeah, with lua_socket, the bounds are pretty limitless.
SpBogie offered some editing of the code to get some of it's http, ftp and other modules working I think.
At least I think he contributed.

Have you seen the 3d IRC client in FP releases that uses lua_socket?
I've not downloaded or played with it any, but the screen shots looked great.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Chironex

  • Full Member
  • ***
  • Posts: 197
  • Karma: 11
  • Formerly known as Kyzer
Re: Fun with lua_socket
« Reply #2 on: May 25, 2008, 04:32:34 AM »
Nice MrPresident. If you want testers, count me in :D. I was making something like that, but it was using ShellPipes and didn't worked very good..so i dropped the project.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Fun with lua_socket
« Reply #3 on: May 25, 2008, 06:36:40 AM »
Ohhh neato
Experiencing God's grace one day at a time.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Fun with lua_socket
« Reply #4 on: May 26, 2008, 04:35:21 PM »
One of the highlights...

Dual server monitoring... so far I only have the chat fully functional. Notice how it is also color coded. This gets the colors directly from UTeam! =)


Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Fun with lua_socket
« Reply #5 on: May 26, 2008, 04:58:38 PM »
This is gonna be sweet. :D

How does the connection set up, out of curiosity? Want to know if it'll work back in my dorm room.
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Fun with lua_socket
« Reply #6 on: May 26, 2008, 05:03:35 PM »
Love the High contrast/black background. Good for contrast/vision impaired people like me!
Good work Pres.
No idea how I could help, but if you need extra look at anything or ideas, let me know.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Fun with lua_socket
« Reply #7 on: May 26, 2008, 07:16:48 PM »
The user runs the server. The garrysmod server then connects to the user via tcp socket.

Unfortunately, you'll need to have the ability to have a port open on your local machine for the client to connect to.

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Fun with lua_socket
« Reply #8 on: May 26, 2008, 07:43:46 PM »
I would love to test this script for you. Can I dl as is?
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Fun with lua_socket
« Reply #9 on: May 26, 2008, 07:56:23 PM »
The user runs the server. The garrysmod server then connects to the user via tcp socket.

Will the server being monitored (ie, client) make multiple outbound connections?

That is, can multiple people monitor the same server, since you have the person monitoring set as a server?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Fun with lua_socket
« Reply #10 on: May 26, 2008, 08:55:12 PM »
Yes, the connections are set as an object which I have set incrementally in a table, so when the client goes to send information it will send it to every server(end user) it is connected to.

We've TESTED it with 3 people simultaneously, however Im certain it could handle many more with no performance issue.



Also, I will be willing to let some people have this program as is (meaning I designed it ultimately for myself, but it will work with everyone...) however you need the lua_socket module from facepunch. Get that now if you want to try this out and in a few days when I get all the bugs worked out, I'll post my .exe and server lua files as well as connection instructions here.

Meanwhile, if you have any suggestions, please feel free.
« Last Edit: May 26, 2008, 08:57:08 PM by MrPresident »

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Fun with lua_socket
« Reply #11 on: May 26, 2008, 09:06:35 PM »
Idk if it's possible, but if it were. Could you incorporate a server restart or maybe map change timer into it? Like restart the server everyday at 6:00 A.m and reload/change the map every hour. that would be useful if possible.

I'm downloading lua_socket now :D
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Fun with lua_socket
« Reply #12 on: May 26, 2008, 09:08:33 PM »
I dont see how that would fit in this program. That would be easy enough to make into a seperate module for ULX or just a stand alone lua file.

Im working on figuring out how to send information from the user to the garrysmod server, at that point I'll add in the ability for you to be able to chat back with the server and run RCon commands. Maybe I'll add in custom commands you can sceduelle from inside the program too, so you'd be able to sceduelle a restart or a map change. =)
« Last Edit: May 26, 2008, 09:10:35 PM by MrPresident »

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Fun with lua_socket
« Reply #13 on: May 26, 2008, 09:10:31 PM »
Oh, ok. is this the luasocket you're using? http://forums.facepunchstudios.com/showthread.php?t=495940
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Fun with lua_socket
« Reply #14 on: May 26, 2008, 09:31:06 PM »
Yes. You'll also need to download and install the VS2008 runtime files if you are running your server on your computer, or ask your host to do it if you pay, Both of my hosts did it for me no problem, so it shouldnt be an issue.

Also, once you download it get the patch thing sspboogie posted and just overwrite the first one you downloaded with his files (it's a fix).