AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved gather data from game server (https://forums.alliedmods.net/showthread.php?t=333143)

CrazY. 06-21-2021 17:52

gather data from game server
 
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.

fysiks 06-21-2021 23:41

Re: gather data from game server
 
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.

CrazY. 06-22-2021 10:39

Re: gather data from game server
 
Thank you for the input

Natsheh 06-22-2021 12:48

Re: gather data from game server
 
I'd suggest using the module CURL it supports alot of protocols.

Bugsy 06-22-2021 16:33

Re: gather data from game server
 
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.

CrazY. 06-24-2021 12:17

Re: gather data from game server
 
Quote:

Originally Posted by Natsheh (Post 2750729)
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 (Post 2750768)
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")     } }

Bugsy 06-24-2021 12:19

Re: gather data from game server
 
Try this module, using socket_unblock() to eliminate the lag

CrazY. 06-24-2021 12:26

Re: gather data from game server
 
I'm currently testing on windows, I could only find the linux compiled binary.

Bugsy 06-24-2021 12:39

Re: gather data from game server
 
https://forums.alliedmods.net/showpo...8&postcount=15

CrazY. 06-25-2021 16:33

Re: gather data from game server
 
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")     } }


All times are GMT -4. The time now is 02:33.

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