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:
- Is there a way to intercept every message the server or a plugin sends to change the icon of these messages?
- How can i properly change the alternative cmds to Pleyer.Reply?
- 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
and the messages this plugin sends have the Steam accounts profile picture as icon.Code:"Chat Icon (SteamID)": "76561198125362467"
I figured that @LaserHydra (the Dev of DeathNotes) does it kind of like this:
Other Plugins like EasyChatCommands (EasyChatCommands) use:Code:foreach (var player in BasePlayer.activePlayerList) { public string ChatIcon = "76561198125362467"; Player.Reply(player, "Yay, one player less", ulong.Parse(ChatIcon); }
Thats itCode:PrintToChat(player, "Message"); SendReply(player, "Message"); player.ChatMessage("Message");
I would appreciate any help.
Greetings,
Michel
Solved Changing the chat icon from other plugins?
Discussion in 'Rust Development' started by AgentBallermann, Aug 22, 2018.
-
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 -
@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");
Code:OnServerMessage
-
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.
-
I've tried this with AutoBroadcast ()
The Stock:
Code:if (message.Key != null) { player.Message(Lang(message.Key, player.Id)); }
Code:if (message.Key != null) { player.Message(Lang(message.Key, player.Id)); player.Reply( player,"Test", ulong.Parse("76561198854867913") ); }
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'
Thank You -
Wulf Community Admin
tl;dr... you're going to have a lot of changes to make if you want to try to do this for every plugin. -
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. -
Wulf Community Admin
-
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.
-
Wulf Community Admin
-
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. -
Wulf Community Admin
-
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# :/ -
Wulf Community Admin