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

How to log output of a server command?


Post New Thread Reply   
 
Thread Tools Display Modes
bibu
Veteran Member
Join Date: Sep 2010
Old 06-08-2014 , 06:43   Re: How to log output of a server command?
Reply With Quote #11

Quote:
Originally Posted by Black Rose View Post
Just make a socket request like SourceQuery, but directly from the server.
To be honest, I have no knownledge about php. Would I need a webpage for such thing? I mean, is it still going to be send by the server?

Quote:
Originally Posted by Black Rose View Post
That does require you to send the actual command yourself though.
Yeah, that's just fine. The command basically requires only the user id:

Quote:
amx_flag #xyz
And then, get the return message of it.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-08-2014 , 08:35   Re: How to log output of a server command?
Reply With Quote #12

Obviously a crude example since I don't fully understand the output format, you get the point:
Code:
#include <amxmodx> #include <sockets> new hSocket; new cmd[256] = "^xFF^xFF^xFF^xFF"; new rcon[] = "your rcon goes here"; public plugin_init() {     register_plugin("Test Plugin 4", "", "[ --{-@ ]");         register_srvcmd("testcmd", "test"); } public test() {         new error     hSocket = socket_open("127.0.0.1", 27015, SOCKET_UDP, error);         if ( ! hSocket )         return;         copy(cmd[4], charsmax(cmd) - 4, "challenge rcon");     socket_send(hSocket, cmd, 18);         set_task(0.1, "ChallengeRcon"); } public ChallengeRcon() {         static data[256];     socket_recv(hSocket, data, sizeof data);         new rcon_challenge[32];     copy(rcon_challenge, charsmax(rcon_challenge), data[19]);     trim(rcon_challenge);         formatex(cmd[4], charsmax(cmd) - 4, "rcon ^"%s^" ^"%s^" banid", rcon_challenge, rcon);     socket_send(hSocket, cmd, 18);         set_task(0.1, "ReadOutput"); } public ReadOutput() {         static data[256];     socket_recv(hSocket, data, sizeof data)         trim(data);     server_print("Output: %s", data[5]);         socket_close(hSocket); }

Code:
testcmd
Rcon from 127.0.0.1:58680:
rcon "632157337" "*" banid
L 06/08/2014 - 14:32:26: Rcon: "rcon "632157337" "*" banid" from "127.0.0.1:58680"
Usage:  banid <minutes> <uniqueid or #userid> { kick }
Use 0 minutes for permanent
Output: Usage:  banid <minutes> <uniqueid or #userid> { kick }
Use 0 minutes for permanent
__________________

Last edited by Black Rose; 06-08-2014 at 08:36.
Black Rose is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 06-08-2014 , 09:43   Re: How to log output of a server command?
Reply With Quote #13

With much <3
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 06-13-2014 , 18:48   Re: How to log output of a server command?
Reply With Quote #14

Sorry for the double post but I would like to ask you an additional question.
Is it possible to use such thing inside only one function, so that there is no set_task needed?
I was like you had for sure your reasons (to get output back from server probably) and I tried and the command crashed.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-13-2014 , 18:58   Re: How to log output of a server command?
Reply With Quote #15

The thing is I couldn't get socket_change() to work at all to wait for the response. Perhaps that's just how UDP works. I'm not really sure.
__________________
Black Rose 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 05:10.


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