We've moved! Join us as we continue development on our new site at umod.org!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  1. Hey, i would like to write a plugin or modify other plugins if its not possible to intercept the messages of other plugins to change the chat icon messages are displayed with.

    My questions are:
    1. Is there a way to intercept every message the server or a plugin sends to change the icon of these messages?
    2. How can i properly change the alternative cmds to Pleyer.Reply?
    3. Why is there so many methods to send chat messages only 2 (one for the whole server and one for single players) would be better wouldn't it?

    As Example the Plugin DeathNotes (uMod - Death Notes by LaserHydra) has the option to specify
    Code:
    "Chat Icon (SteamID)": "76561198125362467"
    and the messages this plugin sends have the Steam accounts profile picture as icon.

    I figured that @LaserHydra (the Dev of DeathNotes) does it kind of like this:
    Code:
    foreach (var player in BasePlayer.activePlayerList)
    {
        public string ChatIcon = "76561198125362467";
        Player.Reply(player, "Yay, one player less", ulong.Parse(ChatIcon);
    }
    
    Other Plugins like EasyChatCommands (EasyChatCommands) use:
    Code:
    PrintToChat(player, "Message");
    SendReply(player, "Message");
    player.ChatMessage("Message");
    
    Thats it :)

    I would appreciate any help.

    Greetings,
    Michel
     
    Last edited by a moderator: Aug 22, 2018
  2. You can handle these with:

    object OnMessagePlayer(string message, BasePlayer player)
    {
    Puts("OnMessagePlayer works!");
    return null;
    }

    object OnServerMessage(string message, string name, string color, ulong id)
    {
    Puts("OnServerMessage works!");
    return null;
    }

    Returning a non-null value overrides default behaviour as docs say
     
    AgentBallermann likes this.
  3. @Kekafeti
    Thank you already helped me out.
    But i don't want to suppress the messages i want to change the icon them.
    Should i just paste this inside the function ?
    Code:
    Player.Reply(player, message, ulong.Parse("76561198125362467");
    What do the variables name and color from
    Code:
    OnServerMessage
    contain? The API Docs answer this.
     
  4. Wulf

    Wulf Community Admin

    The best option is to modify it in each plugin to send the ID for the icon you'd like. There is not catch-all that would grab every message that plugins send as there are different methods of sending them.
     
  5. I've tried this with AutoBroadcast ()
    The Stock:
    Code:
    if (message.Key != null) {
        player.Message(Lang(message.Key, player.Id));               
    }
    My is:
    Code:
    if (message.Key != null) {
        player.Message(Lang(message.Key, player.Id));
        player.Reply(
            player,"Test",
            ulong.Parse("76561198854867913")
        );
    }
    
    But when i now load / reload the plugin i do not get any messages. Not even from the stock line.

    AAAAND the Error I get:
    Code:
    00:43 [Warning] [DEBUG] Reload requested for plugin which is already loading: AutoBroadcast
    00:43 [Error] Error while compiling: AutoBroadcast.cs(85,29): error CS1503: Argument `#1' cannot convert `Oxide.Core.Libraries.Covalence.IPlayer' expression to type `string'
    Could you guys give me a little jump start?
    Thank You
     
  6. Wulf

    Wulf Community Admin

    Setting an icon for messages is Rust-specific, you cannot use the universal (Covalence) API in Oxide to do that. AutoBroadcast is a universal plugin, so if you want to change the icon, you'd need to use a game-specific method in it that allows setting the Steam ID for the icon.

    tl;dr... you're going to have a lot of changes to make if you want to try to do this for every plugin.
     
    Garbage Collector likes this.
  7. What do you mean by saying this (you said game-specific but a brief explanation what this means would be great)?
    Can you give me any directions where i have to look for said methods or who i can contact to help me?

    Sorry for being so niggling but i need this help to get started somewhere.

    Thanks for your help!

    P.s. Can you @Wulf tell me if there are some Documentations to get started (which explain a little bit more than just the API Docs) or how i can gain knowledge a little bit better than just reading through other plugins. I didn't find what i am looking for, yet.
     
  8. Wulf

    Wulf Community Admin

    I’m not able to explain in detail right now, but you see all of the available methods hat Oxide provides at https://github.com/oxidemod/oxide.rust.When working with a universal plugin, you’d need to get the BasePlayer from the IPlayer.Object in order to use Rust-specific methods such as the ones you’d need to set the chat icon. This BasePlayer would be used with methods such as Player.Reply (not the one you see in universal plugins like AutoBroadcast) or others from Rust directly.
     
    AgentBallermann likes this.
  9. Ok. Thank you.
    I didn't know that BasePlayer is required but of course it doesn't work if its not defined in scope *facepalm*

    By the Way, you had a "When" too much in you link.
     
  10. Wulf

    Wulf Community Admin

    Replying on mobile, so missed that part. You can get the BasePlayer by casting the IPlayer.Object.
     
  11. Do i have to port a CovalencePlugin to a RustPlugin to be able to use BasePlayer?

    I did not find any Plugin that uses IPlayer.object. All of them use BasePlayer right of the bat.
     
  12. Wulf

    Wulf Community Admin

    No, but you’d need to be a bit familiar with how casting works in order to understand it. I do have an example of what you want in another plugin of mine, BabelChat I think.
     
  13. It doesn't seem that you have casted IPlayer to BasePlayer in BabelChat.
    Could you Please provide a small snippet how i should do this?
    What clas do i need to import to use both
    1. IPlayer
    and
    2. BasePlayer ?

    Yeah, i have no idea how casting works in c# in general.
    I'm a Java Programmer and never really touched c# :/
     
  14. Wulf

    Wulf Community Admin

    var basePlayer = player.Object as BasePlayer;