Raised This Month: $51 Target: $400
 12% 

Solved gather data from game server


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-21-2021 , 17:52   gather data from game server
Reply With Quote #1

So, I would like to show the server admins on a web page. To do that, I will need to access the users.ini file. I can think of some ways to solve the problem, but I'm not sure which one would be optimal.

The first two options would need a mysql database.

1. Add all users to the database through the plugin itself.
or 2. send a socket post request to the web page. There, parse the data and add to the database.

The third one would be to send a rcon command to the game server which would return the users that are in the file. Would need to search about that one though, but I found this article on the valve developer so it should be possible.
https://developer.valvesoftware.com/..._RCON_Protocol

Let me know if you have any ideas.
__________________









Last edited by CrazY.; 07-02-2021 at 08:57.
CrazY. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-21-2021 , 23:41   Re: gather data from game server
Reply With Quote #2

There are several PHP tools for sending RCON queries to HL1 and HL2 servers. However, many web hosts don't allow external connections so this isn't an option, at least it's not an option with my host (at the level that I've purchased). Granted, if you have this limitation, you'd probably have a limitation for a common database too.

Using a common database, if possible, would probably be the best IMO. Sadly, for my website, the only option I have is to send POST or GET queries from the game server which isn't the best for what I'm wanting to do with my custom plugin.
__________________
fysiks is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-22-2021 , 10:39   Re: gather data from game server
Reply With Quote #3

Thank you for the input
__________________








CrazY. is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-22-2021 , 12:48   Re: gather data from game server
Reply With Quote #4

I'd suggest using the module CURL it supports alot of protocols.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 06-22-2021 at 12:50.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-22-2021 , 16:33   Re: gather data from game server
Reply With Quote #5

You could build a mini server plugin that can send a list of admins when requested. UDP instead of TCP will make it even simpler.
__________________

Last edited by Bugsy; 06-22-2021 at 18:58.
Bugsy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-24-2021 , 12:17   Re: gather data from game server
Reply With Quote #6

Quote:
Originally Posted by Natsheh View Post
I'd suggest using the module CURL it supports alot of protocols.
Thank you, but I would like to do this without the need for a third-party module.

Quote:
Originally Posted by Bugsy View Post
You could build a mini server plugin that can send a list of admins when requested. UDP instead of TCP will make it even simpler.
I did some tests following your suggestion.
I created a socket and connected it to localhost on a random port. Every second I checked if there is data to be received. During the tests, I noticed that socket_is_readable lags the server. I will probably stick with the SQL method. Below is the plugin I made, in case you want to try it.

Code:
#include <amxmodx> #include <sockets> public plugin_init() {     register_plugin("UDP Server", "1.0", "Crazy")     new error, socket = socket_open("localhost", 11000, SOCKET_UDP, error)     server_print("^tsocket is %d", socket)     if (socket == -1)     {         switch (error)         {             case 1: server_print("^tsocket: error while creating socket")             case 2: server_print("^tsocket: couldn't resolve hostname")             case 3: server_print("^tsocket: Couldn't connect")         }     }     else     {         new data[1]         data[0] = socket         set_task(1.0, "SocketReceive", _, data, sizeof data, "b")     } } public SocketReceive(data[]) {     new socket = data[0]         if (socket_is_readable(socket))     {         server_print("^tsocket is readable")     } }
__________________








CrazY. is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-24-2021 , 12:19   Re: gather data from game server
Reply With Quote #7

Try this module, using socket_unblock() to eliminate the lag
__________________
Bugsy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-24-2021 , 12:26   Re: gather data from game server
Reply With Quote #8

I'm currently testing on windows, I could only find the linux compiled binary.
__________________








CrazY. is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-24-2021 , 12:39   Re: gather data from game server
Reply With Quote #9

https://forums.alliedmods.net/showpo...8&postcount=15
__________________
Bugsy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-25-2021 , 16:33   Re: gather data from game server
Reply With Quote #10

Looks the same, still lagging when calling socket_change

Code:
#include <amxmodx> #include <sockets_hz> public plugin_init() {     register_plugin("UDP Server", "1.0", "Crazy")     new error, socket = socket_open("localhost", 11000, SOCKET_UDP, error)     server_print("^tsocket is %d", socket)     if (socket == -1)     {         switch (error)         {             case 1: server_print("^tsocket: error while creating socket")             case 2: server_print("^tsocket: couldn't resolve hostname")             case 3: server_print("^tsocket: Couldn't connect")         }     }     else     {         new data[1]         data[0] = socket         socket_unblock(socket)         set_task(1.0, "SocketReceive", _, data, sizeof data, "b")     } } public SocketReceive(data[]) {     new socket = data[0]         if (socket_change(socket))     {         server_print("^tsocket is readable")     } }
__________________








CrazY. is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode