Solved Chat messages (C#)

Discussion in 'Rust Development' started by HeroicHD, Jul 8, 2015.

  1. Hey guys,

    Do excuse me if there is something terribly wrong with this code, just switched to C# from Lua c: .

    I want to make a simple message that only the player that joined receives when they join the server, this is that I currently have:
    Code:
    void OnPlayerConnected(BasePlayer ply)
            {
                ply.ChatMessage("Welcome to the server!");
            }
    But this just throws me an error whenever a player joins.

    Any assistance appreciated!
    Cheers,
    Heroic
     
  2. Code:
    void OnPlayerConnected(BasePlayer player)
            {
                SendReply(player, "Welcome to the server!");
            }
    
     
  3. Ah great! Is there any way I can send a reply and change the chat image from the default Rust one?

    Cheers,
    Heroic
     
  4. Yeah only if i could remember how.. check this
    Code:
    SendReply(player, "MyMessage", null, "76561198127163614");
    
     
  5. Tried this. Unfortunately didn't work:
    Code:
    void OnPlayerConnected(BasePlayer ply)
            {
                SendReply(ply, "Welcome to the server!", null, 76561198127163614);
            }
        }
    With error:
    "Failed to call hook 'OnPlayerConnected' on plugin 'GRHungerGames-Test' (ArgumentException: failed to convert parameters)"
     
  6. I edited the post above check it. Just set the SteamId in quotation marks
     
  7. Code:
    void OnPlayerConnected(BasePlayer ply)
            {
                SendReply(ply, "Welcome to the server!", null, "76561198127163614");
            }
    Same error as before. Thanks for your help by the way, really appreciate it c:
     
  8. More examples :p

    I dont really remember how it goes.. maybe somenow who know can help him :p
    Code:
    void OnPlayerConnected(BasePlayer ply)
            {
                SendReply(ply, "Welcome to the server!", "76561198127163614");
            }
    
    If this wont work then it probably works with PrintToChat
    Code:
    void OnPlayerConnected(BasePlayer ply)
    {
    var message = string.Format("{0} has joined the server", ply.displayName);
    PrintToChat(message, null, "76561198127163614"); // or PrintToChat(message, "76561198127163614");
    }
     
  9. The parameter for OnPlayerConnected is not a BasePlayer... Check doc.
     
  10. Oh my bad! It's OnPlayerInit(), correct? Haha, thanks so much for picking up on that. I was pretty confused..

    Cheers,
    Heroic
     
    Last edited by a moderator: Jul 8, 2015
  11. LOL i forgot too.. its Packet Connection or sth like that.. what a fail.