AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Send commands to another server (https://forums.alliedmods.net/showthread.php?t=309162)

iceeedr 07-15-2018 22:17

[HELP] Send commands to another server
 
Good evening, friends, I need a north for something I've been trying to do:
  • Filter a command on say (Already ready, easy)
  • Send this command to a list of servers in an .ini, to appear in the say of those servers (create / read the .ini I do not need help, however send this command to the servers in the list I will need.)
  • If anything already exists, I am grateful to be shown for ideas.

iceeedr 07-15-2018 22:34

Re: [HELP] Send commands to another server
 
No..is not for any server, it will have to be in the list and somehow be required access to it, such as via RCON, or etc ... I do not intend to slowhack.

And the command would be something like, "XXX server needs 2 players", a message, that's because on XXX server someone typed .need 2 ... just an example

iceeedr 07-16-2018 09:13

Re: [HELP] Send commands to another server
 
Anyone indeed to help, or are we just doing a stand up comedy?

klippy 07-16-2018 11:38

Re: [HELP] Send commands to another server
 
You can do it over RCON with https://forums.alliedmods.net/showthread.php?t=231477

iceeedr 07-17-2018 22:40

Re: [HELP] Send commands to another server
 
Quote:

Originally Posted by KliPPy (Post 2604014)

Ok, I'm using as you indicated, initially I found it strange not to work on my linux server, I tried again trying to send the command to my home windows server.
On windows worked everything perfectly (I used changelevel as a command for testing purposes of sending command) but in linux after sending the command I get an "error" timeout, and nothing happens ... any suggestion of what might turn out to be?

Oh, to test again I used an app for android called "noobstrike" that has a function to send Rcon commands, again on the server windows (homemade) I was able to change the map, in linux "timeout".

Natsheh 07-17-2018 23:47

Re: [HELP] Send commands to another server
 
Try changing socket protocol to TCP

iceeedr 07-18-2018 23:35

Re: [HELP] Send commands to another server
 
Quote:

Originally Posted by Natsheh (Post 2604404)
Try changing socket protocol to TCP

Here's the full code.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <sockets>
#include <fakemeta>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new g_Socket
new g_Forward

enum _
:Data
{
    
DataHost[32],
    
DataPort,
    
DataPassword[32],
    
DataCommand[192]
}
new 
g_Hostg_Portg_Pass
new g_Rcon[Data]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
g_Host create_cvar("pug_hltv_host","IP:",FCVAR_NONE// With or without the ":"??
    
g_Port create_cvar("pug_hltv_port","port",FCVAR_NONE)
    
g_Pass create_cvar("pug_hltv_pass","Rcon pass",FCVAR_NONE)
}

RconCommand(Host[],Port,Password[],Command[])
{
    new 
Error;
    
g_Socket socket_open(Host,Port,SOCKET_UDP,Error,SOCK_NON_BLOCKING);
   
    if(
Error != -1)
    {
        new 
Send[256];
        
formatex(Send,sizeof(Send),"%c%c%c%cchallenge rcon",0xFF,0xFF,0xFF,0xFF);
       
        
socket_send2(g_Socket,Send,charsmax(Send));
       
        
copy(g_Rcon[DataHost],charsmax(g_Rcon[DataHost]),Host);
       
        
g_Rcon[DataPort] = Port;
   
        
copy(g_Rcon[DataPassword],charsmax(g_Rcon[DataPassword]),Password);
        
copy(g_Rcon[DataCommand],charsmax(g_Rcon[DataCommand]),Command);
 
        
g_Forward register_forward(FM_StartFrame,"FMStartFrame",true);
    }
    else
    {
        
socket_close(g_Socket);
    }
 
}  
 
public 
FMStartFrame()
{
    if(
socket_is_readable(g_Socket))
    {
        new 
Command[256],Rcon[32],None[64];
   
        
socket_recv(g_Socket,Command,charsmax(Command));
        
parse(Command,None,charsmax(None),None,charsmax(None),Rcon,charsmax(Rcon));
       
        
formatex(Command,sizeof(Command),"%c%c%c%crcon %s ^"%s^" %s",0xFF,0xFF,0xFF,0xFF,Rcon,g_Rcon[DataPassword],g_Rcon[DataCommand]);
        
socket_send2(g_Socket,Command,charsmax(Command));
       
        if(
socket_is_readable(g_Socket))
        {
            new 
Buffer[1024];
            
socket_recv(g_Socket,Buffer,charsmax(Buffer));
           
            
server_print(Buffer);
        }
       
        
socket_close(g_Socket);
       
        
unregister_forward(FM_StartFrame,g_Forward,true);
    }
}

public 
SendMessage()
{
    new 
HOST[32];
    
get_pcvar_string(g_Host,HOST,charsmax(HOST));
    
    new 
Command[60]
    
formatex(Commandcharsmax(Command), "changelevel de_inferno")
            
    new 
Password[32];
    
get_pcvar_string(g_Pass,Password,charsmax(Password));
    
    
RconCommand(HOST,get_pcvar_num(g_Port),Password,Command);


As you can see, I tried to use the changelevel command .. nothing happens .. I tried to send a say also nothing happens .. what's wrong?

iceeedr 01-15-2019 08:41

Re: [HELP] Send commands to another server
 
I think by the time already can make a "bump" right? haha

No one with a solution to the case?

klippy 01-15-2019 09:56

Re: [HELP] Send commands to another server
 
So wait, it works on Windows but not on Linux? Even when it comes to third party apps sending the request, not just your plugin?

iceeedr 01-15-2019 09:59

Re: [HELP] Send commands to another server
 
Quote:

Originally Posted by KliPPy (Post 2634882)
So wait, it works on Windows but not on Linux? Even when it comes to third party apps sending the request, not just your plugin?

Yes, at that time it happened exactly, I did not test on amx 1.9 (but I do not think anything should have changed in relation to that), and I was able to just send directly to a server already configured, I could not imagine ways to send to the added servers to the .ini file.


All times are GMT -4. The time now is 01:45.

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