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

[INC] GoldSRC RCON Query


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GordonFreeman (RU)
Veteran Member
Join Date: Jan 2010
Location: Uzbekistan
Old 12-15-2013 , 00:30   [INC] GoldSRC RCON Query
Reply With Quote #1

GoldSRC RCON Query Include [ SVN ]
Version: 0.1
You can send RCON commands for HLDS server from your AMXX plugin.
Im used "Thread Socket" method in this include, so it doesn't not interrupt gameplay while querying.
Functions:
rcon_send( ip[] , port , szPass[] , szCommand[] , szForward[] , Float:timeout = 5.0 ) - send RCON command to server.
  • ip[] - remote server IP address.
  • port - remove server port.
  • szPass[] - RCON password.
  • szCommand[] - RCON command.
  • szForward[] - forward function for receive result from server.
    • Forward( iRconStatus , szResult[] )
      • iRconStatus - RCON status.
      • szResult - RCON command result.
  • Float:timeout - timeout time.
  • @return - RCON_OK if OK or error code.

Error codes
  • RCON_CONNECTION_FAILED - connection to server failed.
  • RCON_GET_CHALLENGE_FAILED - failed to get rcon challenge number (successfully connetec, нbut something is goes wrong).
  • RCON_CREATE_FWD_FAIL - failed to create forward.
  • RCON_TIMEOUT - query timeout.
  • RCON_OK - there there should be error, but there is no.
Example usage:
Code:
#include <amxmodx> #include <rcon> #define SRV_IP      "localhost" #define SRV_PORT   27015 #define SRV_PASS   "1337" public plugin_init() {    register_plugin("RCON Test","test","serfreeman1337")        register_clcmd("amx_rcon_send","Try_Rcon_Send") } public Try_Rcon_Send(){    new cmd[128]    read_args(cmd,127)    trim(cmd)    remove_quotes(cmd)        new st = rcon_send(SRV_IP,SRV_PORT,SRV_PASS,cmd,"rcon_handler")        switch(st){       case RCON_CONNECTION_FAILED: server_print("[ RCON ] Connection to %s:%d failed successfully",          SRV_IP,SRV_PORT)       case RCON_CREATE_FWD_FAIL: server_print("[ RCON ] Forward create failed")    } } public rcon_handler(status,result[]){    switch(status){       case RCON_GET_CHALLENGE_FAILED:          server_print("[ RCON ] Get RCON challenge failed",status)       case RCON_TIMEOUT:          server_print("[ RCON ] Query timeout on %s",result)       case RCON_OK:          server_print("[ RCON ] Response: ^n%s",result)    } }

Notes
  • There is problem with large result, which take more than one packet from server.
  • If you execute many rcon_send at same time im same plugin something goes wrong.
Attached Files
File Type: inc rcon.inc (4.6 KB, 581 views)
File Type: sma Get Plugin or Get Source (rcon_test.sma - 1218 views - 554 Bytes)
__________________
The functional way is the right way

Last edited by GordonFreeman (RU); 12-15-2013 at 03:25.
GordonFreeman (RU) is offline
WiggPerson
Junior Member
Join Date: Dec 2013
Location: Slovakia
Old 12-15-2013 , 08:13   Re: [INC] GoldSRC RCON Query
Reply With Quote #2

Very cool, this can be very useful with servers comunication plugins. Will using, thank you . But here is a one question, is possible to get returned values by RCON?
__________________
It does not matter who you are, just who you become.

Last edited by WiggPerson; 12-15-2013 at 08:15.
WiggPerson is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 12-15-2013 , 09:27   Re: [INC] GoldSRC RCON Query
Reply With Quote #3

public rcon_handler(status,result[]){
__________________
Kia is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 12-17-2013 , 04:43   Re: [INC] GoldSRC RCON Query
Reply With Quote #4

Good job.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
kiki33hun
Veteran Member
Join Date: Jul 2011
Location: Magyarország
Old 12-20-2013 , 04:11   Re: [INC] GoldSRC RCON Query
Reply With Quote #5

Not bad idea
__________________
kiki33hun is offline
WiggPerson
Junior Member
Join Date: Dec 2013
Location: Slovakia
Old 12-31-2013 , 06:05   Re: [INC] GoldSRC RCON Query
Reply With Quote #6

Not possible to get returned value of RCON:
PHP Code:
public plugin_init() {
     
register_concmd("return100","return100function",ADMIN_RCON);
}

public 
return100function() {
     return 
100// Get this in szResult[] in plugin on second server

PHP Code:
public plugin_init() {
     
rcon_send("255.255.255.255",25555,"return100","password","rconforward")
}

public 
rconforward(iStatus,szResult[]) {
     
print_console("%s",szResult// This is not 100

__________________
It does not matter who you are, just who you become.

Last edited by WiggPerson; 12-31-2013 at 06:10.
WiggPerson is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 12-31-2013 , 07:29   Re: [INC] GoldSRC RCON Query
Reply With Quote #7

Shouldn't it be a integer (%i) since you're returning a number?
__________________
Kia is offline
WiggPerson
Junior Member
Join Date: Dec 2013
Location: Slovakia
Old 12-31-2013 , 09:36   Re: [INC] GoldSRC RCON Query
Reply With Quote #8

Quote:
Originally Posted by Kia View Post
Shouldn't it be a integer (%i) since you're returning a number?
The result is returned in string as 2nd parameter. (No 100 but "100")
__________________
It does not matter who you are, just who you become.
WiggPerson is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 12-31-2013 , 10:10   Re: [INC] GoldSRC RCON Query
Reply With Quote #9

PHP Code:
public return100function() {
     return 
100// Get this in szResult[] in plugin on second server

You return a Integer, not a string.

Your Code should be
PHP Code:
public rconforward(iStatusiResult) {
     
print_console("%i"iResult)

__________________

Last edited by Kia; 12-31-2013 at 10:10.
Kia is offline
WiggPerson
Junior Member
Join Date: Dec 2013
Location: Slovakia
Old 12-31-2013 , 13:13   Re: [INC] GoldSRC RCON Query
Reply With Quote #10

It think it does not matter 'cause rcon access return in string, please @GordonFreeman (RU) tell us, how it exactly works.
__________________
It does not matter who you are, just who you become.

Last edited by WiggPerson; 12-31-2013 at 13:13.
WiggPerson 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 03:33.


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