This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[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 03-06-2024 , 07:10   Re: [AMXX] Server Informations
Reply With Quote #1

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



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 22:24.


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