Raised This Month: $32 Target: $400
 8% 

[AMXX] Server Informations


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 02-15-2024 , 17:12   [AMXX] Server Informations
Reply With Quote #1

Not sure where it should be located so I posted here.

This plugin passes server informations to your website without a database. It uses Easy HTTP module to pass some basics informations through HTTP Request. It is avaliable both linux and windows.

1. Install serverResponse.php into your website.
2. Install the module
3. Add your website link on the constant

PHP Code:
new const g_szWebsite[] = "http://www.yourwebsite.com" 
4. Compile your plugin and install it
5. Each 60 seconds the plugin makes the request to your website.
6. The PHP file will format the informations as JSON
7. Use it as you wish. More informations can be added.

-

This is just a simple way of using Easy HTTP. It can be used for more useful things such as the Auto Plugin Updater I built before. Also, by using ezhttp_get_data you can get the response of the PHP, opening more doors like being useful to use php API's from your website to get some informations AMXX can't, like Bypass Guard does by getting AS with gRIP.

EasyHTTP can also read json files and parse it flawlessly as well, such an underrated module.
Attached Files
File Type: zip server Info.zip (3.27 MB, 49 views)
File Type: zip Full PHP Example with server checker & score count.zip (3.5 KB, 33 views)
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 02-22-2024 at 04:11.
EFFx is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 02-15-2024 , 17:13   Re: [AMXX] Server Informations
Reply With Quote #2

Reserved.

The JSON format will be saved like this:

PHP Code:
{
    
"IP:PORT": {
        
"server""Server Name",
        
"map""de_dust2",
        
"players""0",
        
"playersmax""32",
        
"ip""IP:PORT"
    
}

It can also hold more servers informations than just one. Currently using it for my pug mod to get servers informations, such as mode description (Warmup, Knife Round, Live, etc), also match scoreboard and so on.

----------------

(22.02.2024)

Updated main post with a Full-working PHP example which checks the IP passed to the Web API. Also, a simple way to display the existing informations inside the JSON file for starters.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 02-22-2024 at 04:12.
EFFx is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 02-28-2024 , 16:52   Re: [AMXX] Server Informations
Reply With Quote #3

an alternative method would be the gt API, whose functions return all the data mentioned above. This does not require installing anything on the server, simply that the IP exists in its database.
__________________
mlibre is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 02-29-2024 , 05:47   Re: [AMXX] Server Informations
Reply With Quote #4

Quote:
Originally Posted by EFFx View Post
This is just a simple way of using Easy HTTP. It can be used for more useful things such as the Auto Plugin Updater I built before. Also, by using ezhttp_get_data you can get the response of the PHP, opening more doors like being useful to use php API's from your website to get some informations AMXX can't, like Bypass Guard does by getting AS with gRIP.
SourceQuery from xPaw or LGSL is way better of getting informations without any third-party files installation in the server, the api you mentioned sucks.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 02-29-2024 , 08:04   Re: [AMXX] Server Informations
Reply With Quote #5

Quote:
Originally Posted by EFFx View Post
SourceQuery from xPaw or LGSL is way better...
I think this API gt is easier to use than others, it also uses the JSON method, because I say it is an alternative, because not all hosts allow "Query" or "Sockets" output as a "security" measure, so, if you are limited this could help.
__________________
mlibre is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 02-29-2024 , 08:47   Re: [AMXX] Server Informations
Reply With Quote #6

Quote:
Originally Posted by mlibre View Post
because not all hosts allow "Query" or "Sockets" output as a "security" measure
That's true, been there.

Problem with gametracker.rs API, not to mention that it is slow af, is that is it not accurate. A lot of servers are displayed as offline and there is no way of contacting them.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 03-05-2024 , 13:10   Re: [AMXX] Server Informations
Reply With Quote #7

you should be able to accomplish this without 3rd party modules, instead parse the json object in header using socekts
__________________
bigdaddy424 is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 03-05-2024 , 21:30   Re: [AMXX] Server Informations
Reply With Quote #8

since there isnt a tutorial on how to post data using sockets i took my time and came up with something simple:

Code:
#include <amxmodx> #include <json> #include <sockets> new socket, error new const webhook_url[] = "webhook.site" new const webhook_path[] = "/b616d41a-c1b6-4eaa-bad7-bf045b026161" public plugin_init()     register_srvcmd("f", "upload_data") public plugin_end()     socket_close(socket) public upload_data() {     new JSON:object = json_init_object()     new JSON:array = json_init_array()     new JSON:player[MAX_PLAYERS + 1]         socket = socket_open(webhook_url, 80, SOCKET_TCP, error)     new hostname[64]     get_cvar_string("hostname", hostname, charsmax(hostname))     json_object_set_string(object, "hostname", hostname)     json_object_set_number(object, "maxplayers", get_maxplayers())     json_object_set_number(object, "online", get_playersnum())     json_object_set_number(object, "admins", admins_num())     json_object_set_value(object, "players", array)         new players[MAX_PLAYERS], num, id     get_players(players, num)     for (new i = 0; i < num; i++)     {         id = players[i]         if (is_user_connected(id))         {             player[i] = json_init_object()             json_object_set_string(player[i], "name", fmt("%n", id))             json_object_set_number(player[i], "kills", get_user_frags(id))             json_object_set_number(player[i], "deaths", get_user_deaths(id))             json_object_set_number(player[i], "time", get_user_time(id))             json_array_append_value(array, player[i])         }     }     new json_data[1024]     json_serial_to_string(object, json_data, charsmax(json_data), true)     new data[2048]     formatex(data, charsmax(data),         "POST %s HTTP/1.1^r^n\         Host: %s^r^n\         Accept: application/json^r^n\         Content-Type: application/json^r^n\         Content-Length: %d^r^n^r^n\         %s", webhook_path, webhook_url, strlen(json_data), json_data     )     socket_send(socket, data, charsmax(data)) }
__________________
bigdaddy424 is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 03-06-2024 , 07:10   Re: [AMXX] Server Informations
Reply With Quote #9

Quote:
Originally Posted by bigdaddy424 View Post
you should be able to accomplish this without 3rd party modules, instead parse the json object in header using socekts
As mentioned before, it was not supposed to be just a basic plugin that sends server informations to your website.

Quote:
Originally Posted by bigdaddy424 View Post
since there isnt a tutorial on how to post data using sockets i took my time and came up with something simple:

Code:
#include <amxmodx> #include <json> #include <sockets> new socket, error new const webhook_url[] = "webhook.site" new const webhook_path[] = "/b616d41a-c1b6-4eaa-bad7-bf045b026161" public plugin_init()     register_srvcmd("f", "upload_data") public plugin_end()     socket_close(socket) public upload_data() {     new JSON:object = json_init_object()     new JSON:array = json_init_array()     new JSON:player[MAX_PLAYERS + 1]         socket = socket_open(webhook_url, 80, SOCKET_TCP, error)     new hostname[64]     get_cvar_string("hostname", hostname, charsmax(hostname))     json_object_set_string(object, "hostname", hostname)     json_object_set_number(object, "maxplayers", get_maxplayers())     json_object_set_number(object, "online", get_playersnum())     json_object_set_number(object, "admins", admins_num())     json_object_set_value(object, "players", array)         new players[MAX_PLAYERS], num, id     get_players(players, num)     for (new i = 0; i < num; i++)     {         id = players[i]         if (is_user_connected(id))         {             player[i] = json_init_object()             json_object_set_string(player[i], "name", fmt("%n", id))             json_object_set_number(player[i], "kills", get_user_frags(id))             json_object_set_number(player[i], "deaths", get_user_deaths(id))             json_object_set_number(player[i], "time", get_user_time(id))             json_array_append_value(array, player[i])         }     }     new json_data[1024]     json_serial_to_string(object, json_data, charsmax(json_data), true)     new data[2048]     formatex(data, charsmax(data),         "POST %s HTTP/1.1^r^n\         Host: %s^r^n\         Accept: application/json^r^n\         Content-Type: application/json^r^n\         Content-Length: %d^r^n^r^n\         %s", webhook_path, webhook_url, strlen(json_data), json_data     )     socket_send(socket, data, charsmax(data)) }
JSON tutorials are hard to find, the more, the better.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Reply


Thread Tools
Display Modes

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 13:58.


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