Solved Nickname colors

Discussion in 'Plugin Requests' started by Axy, Apr 20, 2015.

  1. Axy

    Axy

    It'd be very nice if we could set nickname colors.

    In my server, people are annoyed by the fact that admins have different colors on their nicknames. They think it's not fair to have admins playing in the same server.

    It would be very nice if we have a way to set admin nicknames to the default color, or create different user groups (with differnt nickname colors).

    Not sure how easy/hard this would be though.

    Cheers.
    [DOUBLEPOST=1429515351][/DOUBLEPOST]I've made a very simple lua file to do this, however it just adds the prefix instead of changing the color. Here is my codebit:

    Code:
    function PLUGIN:OnPlayerConnected(packet)    if not packet then return end
        if not packet.connection then return end
       
        local userDispName = ( "[color #FF0000] " .. packet.connection.username )
        packet.connection.username = userDispName
       
    end
    
    [DOUBLEPOST=1429516151][/DOUBLEPOST]Replaced the coloring bit with this, now I can see colored nicknames when I type "status" to the console, however in the actual chat it's still showing the unnecessary code.

    Code:
    local userDispName = ( "<color=#CC3A2D>" .. packet.connection.username  .. "</color>" )
    [DOUBLEPOST=1429516173][/DOUBLEPOST]Okay, I have no clues on how to continue with this further, so looking for some support :)
     
  2. No way to change color of NickName
     
  3. Axy

    Axy

    The plugin you suggested in the other thread seems to do the trick, not sure how.
     
  4. If you want to change the color that name is displayed in in the chat you need to change this when a player sends out a chat message, you'd want to capture the input and send the message yourself instead of letting Rust handle it. When you send a chat message Rust will automatically determine the name and add a color to this by checking the authLevel for that player, so even if you've already set the color in the displayname it will encapsulate that name with the color with the default admin color, so you'd want to use the OnPlayerChat hook and broadcast the chatmessage yourself.

    If you intend to change the color on the name floating above the actual characters then it is something I'd need to look into before I give an answer as I'm not entirely sure if that is even possible.
     
  5. Axy

    Axy

    Thank you for the answer @Mughisi
    After checking the plugin (chathandler) I got tht I need to capture&recreate the message as a whole instead of trying to modify it's bits. I think it's good in a way, otherwise (I believe) people would be able to change their nickname colors by altering their steam names.
     
  6. One thing to keep in mind when using the OnPlayerChat hook, if it is used to modify the normal behaviour (i.e.: stopping the message from sending normally and sending it manually yourself) it could conflict with other plugins using the hook so it is recommended to only use one of such plugins :)
     
  7. Axy

    Axy

    thank you very much!
     
  8. Axy

    Axy