Some lua problems.

Discussion in 'Rust Development' started by JohnRU, Aug 8, 2015.

  1. I've tried many different lua plugins for the answers but none seem to work for what I need it for or It isn't simple enough for me to grasp. What I think is the argument is sent into a table and read from there for the 1st issue.

    1. Basically I need a function that outputs messages depending on the result so if someone types /test it outputs specific data and if someone typed /test 1 another set of data.

    2. Another is I need something like
    Code:
    function PLUGIN:cmdTesty(player)
        rust.SendChatMessage(player, "<color="/self.Config.TopColor/">", self.Config.TopMsg, "</color>")
    end
    but obviously this doesn't work so I'm not sure how to get customisable coloured text like that.

    I appriciate the help I've been given in the past and I'm always trying to implement low level ideas like this.
     
  2. Wulf

    Wulf Community Admin

    For the first, you'd need to hook into OnRunCommand and listen for the specific command.

    For the second, you aren't inserting the config variable properly.
    Code:
    function PLUGIN:cmdTesty(player)
        rust.SendChatMessage(player, "<color=" .. self.Config.TopColor .. ">" .. self.Config.TopMsg .. "</color>")
    end
     
  3. I tried
    Code:
    function PLUGIN:cmdTesty(player, _, args)
        if not player then return end
        local which = args[1]
        if which == "" then
        rust.SendChatMessage(player, "main")
        return
        end
    end
    
    based off the pm plugin but it don't work. What am i missing?
     
  4. Wulf

    Wulf Community Admin

    args[0] would actually be the first arg if you are only using one.
    Code:
    function PLUGIN:cmdTesty(player, cmd, args)
        if not player then return end
        if args[0] == "hello" then
            rust.SendChatMessage(player, "hello")
            return
        end
    end