1. Code:
    function PLUGIN:Init()
        command.AddChatCommand("test", self.Plugin, "cmd_test")
    endfunction PLUGIN:cmd_test(player, cmd, args)
        rust.BroadcastChat("name", "message", player)
    end
    Code:
    [Error] Failed to call hook 'cmd_test'
    File: _.lua Line: _ invalid arguments to method call:
     
    Last edited by a moderator: Jul 13, 2015
  2. Code:
    function PLUGIN:cmd_test(player, cmd, args)
          rust.BroadcastChat("This is a message to everyone")
    endorfunction PLUGIN:cmd_test(player, cmd, args)
          rust.SendChatMessage(player, "This is a message sent to the player that used the command")
    end
    
     
  3. The documentation is displayed 3 argument, how to use them?
    Code:
    rust.BroadcastChat(name, message, userid)
     
  4. To my understanding, the first two is just the format of the message.

    in-game chat it will be displayed as
    Code:
    [format]
    Name : Message
    [example]
    Zuen : "Hello World"
    and userid it the id of the player?
     
  5. name is the name of the player the message is sent from, message is the chat message, userid is the steamid used to get the avatar from to display.
     
  6. My mistake was that I used the player, not the UserID
    Code:
    rust.BroadcastChat("name", "message", rust.UserIDFromPlayer(player))
     
  7. Wulf

    Wulf Community Admin

    The player or name is what it accepts, it needs to be the first item. The last you only need to set if you want that player's icon.
     
  8. Sorry, I wanted to make a simple command '/say ' to administrators (analogue console), but I can't :D
    Code:
    function PLUGIN:cmd_say(player, cmd, args)
        rust.BroadcastChat("Admin", args) -- fail code
    end
    I tried using ArgsToTable but chat only displays the last word
     
  9. Try
    Code:
    function PLUGIN:cmd_say(player, cmd, args)
       
        local text = tostring(args[0])
        rust.BroadcastChat("Admin", text)
        end
    -- Remember to type in Quotation Marks ""