1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Send message

Discussion in 'Development' started by #A6543, Feb 2, 2017.

  1. #A6543

    #A6543 Zombie

    Messages:
    267
    Is there a way to to something with players on another server? Like sending messages
     
  2. Magicode

    Magicode Baby Zombie

    Messages:
    183
    GitHub:
    magicode1
    On another server? Possibly. But not with any plugin that I know of.
     
  3. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    You'd need two plugins. One on each server
     
  4. #A6543

    #A6543 Zombie

    Messages:
    267
    Ok. Can u tell me how it's possible?
     
  5. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    theoretical example
    receiver plugin listens on port 2nd:19133
    sender plugin will just send something to 2nd:19132
    receiver plugin will phrases the massage and execute it, if it is a valid authenticated command
     
  6. #A6543

    #A6543 Zombie

    Messages:
    267
    But how can I send it to the other server?
     
  7. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    learn php sockets or stream, whatever works best for you will do the trick
     
  8. #A6543

    #A6543 Zombie

    Messages:
    267
    I now connected using this:
    But how can I accept it from another server and send a message?
    PHP:
    <?php
     
    if(!($sock socket_create(AF_INETSOCK_STREAM0)))
    {
        
    $errorcode socket_last_error();
        
    $errormsg socket_strerror($errorcode);
        
        die(
    "Couldn't create socket: [$errorcode$errormsg \n");
    }
     
    echo 
    "Socket created \n";
     
    if(!
    socket_connect($sock '0.0.0.0' 19132))
    {
        
    $errorcode socket_last_error();
        
    $errormsg socket_strerror($errorcode);
        
        die(
    "Could not connect: [$errorcode$errormsg \n");
    }
     
    echo 
    "Connection established \n";
     
    ?>
     
  9. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    no not 19132 you need another port where your plugin will open a listening stream on(so means php need root)
    something like fput or streamput not very certain what it called but you would put some msg
    example (auth code)-(send to player)-(msg here)
    auth code is just some mockup way to prevent unauthorized people using it to spam players
     
  10. #A6543

    #A6543 Zombie

    Messages:
    267
    How would you do it?
     
  11. kaliiks

    kaliiks Zombie

    Messages:
    250
    PHP:
    $message "YourMessage";

    //Send the message to the server
    if( ! socket_send $sock $message strlen($message) , 0))
    {
        
    $errorcode socket_last_error();
        
    $errormsg socket_strerror($errorcode);
        
        die(
    "Could not send data: [$errorcode$errormsgPHP_EOL);
    }

    echo 
    "Message send successfully" PHP_EOL;
     
    Last edited: Feb 2, 2017
  12. #A6543

    #A6543 Zombie

    Messages:
    267
    And how can I send the message using sendMessage on the other server?
     
  13. xBeastMode

    xBeastMode Shog Chips

    Messages:
    0
  14. #A6543

    #A6543 Zombie

    Messages:
    267
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.