1. How do I get the player who wrote anything, in the OnPlayerChat hook?
    just adding player to the hook doesn't work:

    Code:
    function PLUGIN:OnPlayerChat(arg, player)
         print("[" .. player.displayName .. "]: " .. arg)
    end
    --------------------------

    I also think that simply using the arg variable here wouldn't work like this, would it?
    Does it work the same way as the way to use in commands?
    message = tostring(arg[0]) for example?
     
  2. Code:
    local player = arg.connection.player
     
  3. so the arg actually isn't ment to be the args of the written msg, is it?
     
  4. So, is there a way to get the written message with it? Im looking into the decompiled data for it at the moment, but im not sure with it.
    I found this but im not sure if it is what im searching for:
    Screenshot_8.png
     
  5. Wulf

    Wulf Community Admin

    local chat = arg:GetString(0, "text")
     
  6. kk
    Thanks
    [DOUBLEPOST=1429627451][/DOUBLEPOST]Okay that works fine thanks, but I can't get it to stop the original message from being in the chat.
    Code:
    function PLUGIN:OnPlayerChat(arg, player)
         local message = arg:GetString(0, "text")
         local player = arg.connection.player
         print("[" .. player.displayName .. "]: " .. message)
    return
    end
    return does not work, let me guess... Am I doing a simple failure?

    ---------

    And also, is it possible to get the player icon and use it with rust.BroadcastChat?
    - would need that for my Player Talk plugin ^^
     
  7. You need to get player as BasePlayer, cause arg.connection.player returns MonoBehavior
     
  8. so you mean just
    player = BasePlayer? or arg.BasePlayer? or arg.connection.BasePlayer
    anyway however I do it, it does not work.
     
  9. Not neccessary in lua. Its working the way i posted.
     
  10. well whats the problem then?

     
  11. The answer to how to cancel the default chat can be found in the docs. A hint: returning nothing in lua means you returning null

    For the player icon: The icon is simply pulled by the steamID. The syntax for that can also be found in the docs.
     
  12. these?
    http://docs.oxidemod.org
    [DOUBLEPOST=1429643563][/DOUBLEPOST]Okay I found the way to get the picture but I wasn't able to fix that return yet
    [DOUBLEPOST=1429644130][/DOUBLEPOST]Nevermind, I got it. #JustUnderstoodWhatYourHintMent...
    Code:
    return ""