1. How am I able to get the used command in "OnRunCommand"?
    found
    local command = arg.cmd.name
    somewhere in the forum, which does not work for me. It just gets hooked by every command used. So its even getting hooked if someone writes anything into the chat :c
     
  2. Wulf

    Wulf Community Admin

    That's for the partial name. To get the full command name, you'd need to catch arg.cmd.namefull.
     
  3. also tried that which didnt work either. Imma try it again and check for the error exactly.
     
  4. Wulf

    Wulf Community Admin

    Works fine. I use it. ;)
    Code:
    function PLUGIN:OnRunCommand(arg)
        local console = arg.cmd.namefull
        print(console)
    end
     
  5. yeah right. just got another failure nothing to do with this part. ^^
    [DOUBLEPOST=1430421665][/DOUBLEPOST]
    attempt to index field 'Args' (a nil value):
    :c -> Also just how I read it somewhere as I never used / detected console commands with args
    Code:
    unformattedmsg = arg.Args[0]
     
  6. Wulf

    Wulf Community Admin

    To use something like that, you'd need to convert it to a table, which is unnecessary. Using what I gave you would work fine. I'm not sure what you are doing, but the code works fine. You can see it used in my Logger plugin and many others.
     
  7. Yes but I need to get the Arg of the console command :c
     
  8. Wulf

    Wulf Community Admin

    local arg = arg:GetString(0, "text")
     
  9. ah yeah XD We got that already and I forgot it. Damn. Always getting confused by that ^^ Thanks
     
  10. That was one of the first things ive done when Oxide 2 came out. Make a function to make handling args in chat and console commands easier and more intuitive. You can use it if you want.
    In chat commands use it like
    local args = self:ArgsToTable(args, "chat")
    and in console commands
    local args = self:ArgsToTable(args, "console")
    It returns all args as a lua table starting with index 1.
    Code:
    -- --------------------------------
    -- returns args as a table
    -- --------------------------------
    function PLUGIN:ArgsToTable(args, src)
        local argsTbl = {}
        if src == "chat" then
            local length = args.Length
            for i = 0, length - 1, 1 do
                argsTbl[i + 1] = args[i]
            end
            return argsTbl
        end
        if src == "console" then
            local i = 1
            while args:HasArgs(i) do
                argsTbl[i] = args:GetString(i - 1)
                i = i + 1
            end
            return argsTbl
        end
        return argsTbl
    end
     
  11. You cant detect the say command can you?
    Code:
    if command == "say" then
    I replaced it with oxide.reload for example and that worked.
     
  12. Wulf

    Wulf Community Admin

    chat.say is the actual command. You can catch "say" if you use arg.cmd.name, not namefull.
     
  13. well now also it just get called everytime anyone wrote something into the chat. I ment the say command used by server console which gives out SERVER CONSOLE text
     
  14. Wulf

    Wulf Community Admin

    Pretty sure it's all the same. chat.add, chat.say, etc.
     
  15. ? Yeah it works but It also gets called if a player writes now because that seems to use say too
     
  16. Wulf

    Wulf Community Admin

    Right, just check if it comes from a player or not.
     
  17. Never did it, just tried and it worked :D
    Code:
    if not arg.connection == false then return
     
  18. Wulf

    Wulf Community Admin

    Are you trying to check if it's a player or not? That snippet is a bit redundant and odd.
     
  19. but it worked XD
    -- Anyhow
     
  20. Wulf

    Wulf Community Admin

    Doesn't mean you should use it. :p

    If you are trying to block players, then use:
    Code:
    if arg.connection then return end