Hey,
For a while now, rust.BroadcastChat({ }); does not work.. Ever..
I have NO idea why and I have updated it to the latest version (2.0.622).
Please help,
This is my code:
Code:namespace Oxide.Plugins { [Info("Commands!", "Krazi", "1.0.0")] public class Commands : RustPlugin { [ChatCommand("afkc")] void cmdAfk(BasePlayer player, string cmd, string[] args) { player.StartSleeping(); if(player.IsSleeping()) { var messageT = string.Format("{0} is now awake", player.displayName); rust.BroadcastChat({ messageT }); //HERE IS WHERE IT DOES NOT WORK //Notice how I use PrintToChat down there because I can't use BroadcastChat.. //And I don't think PrintToChat goes to everyone because it uses BasePlayer. :P } } void OnPlayerInit(BasePlayer player) { PrintToChat(player, "<color=#008080ff>QUARK:</color> {0} has joined the server!", player.displayName); } } }
Solved Rust.BroadcastChat({ }); does not work
Discussion in 'Rust Development' started by ItsAnderson, Mar 30, 2015.
-
Try it:
Code:ConsoleSystem.Broadcast("chat.add", new object[] { "0", "<color=lime>[Server]:</color> Test Message" });
-
-
Wulf Community Admin
It does work, you're both just using it wrong. You should be calling it natively too, not through the rust.BroadcastChat function.
https://github.com/OxideMod/Oxide/blob/master/Oxide.Ext.Rust/Libraries/Rust.cs#L76 -
[DOUBLEPOST=1427730814][/DOUBLEPOST]Well that doesn't work lol.
Can yuo show me how I could use that in my code?
And explain what the arguments are. :3 sorry I just want to understand what I'm doing. -
Wulf Community Admin
-
It's working fine -
-
Wulf Community Admin
-
-
If you could help me with what I told Wulf it'd be great, thanks. -
You need to use it:
Code:ConsoleSystem.Broadcast("chat.add", "0", "<color=lime>[Server]:</color> Test Message", 1);
-
Wulf Community Admin
Code:ConsoleSystem.Broadcast("chat.add", 0, string.Format("<color=orange>{0}:</color> {1}", "SERVER", "Hello World"), 1.0);
-
But can you guys explain what it all means? Like ConsoleSystem.Broadcast(arg1, arg2, arg3, arg4); and explain what the arguments are.
lol sorry,
thanks for the feedback! -
-
Wulf Community Admin
-
"0" chat icon, if 0 then it will be Rust icon else it will be avatar that have this steamid (like "75653242346") [1 argument]
"<color=lime>[Server]:</color> Test Message" message [2 argument]
"1" global chat [3 argument] -
So the command is "chat.add", cuz your 'adding to the chat' lol, steamid64 which we don't need in this case so 0, message formatting which is the actualy message, and then global chat setting which I assume needs to be 1 since it's declaring it's 'global-ness' and if I where 0 then it wouldn't work or not be global.
Something like that lol.
[DOUBLEPOST=1427733088][/DOUBLEPOST]
I was so terribly wrong XD LOL
Both of you are awesome!
Thanks SO much! -
Wulf Community Admin
-
I love the Oxide API lol.. It's so fun to learn stuff like this.
Before the rust.BroadcastChat was working fine, then I updated and it must've been removed or something lol.
Thanks again!
[DOUBLEPOST=1427733474][/DOUBLEPOST]Hey, just want to ask one more easy question for yall before you go,
Why do we need the string.*Format* there? Why can't we do string("{0}", "SERVER"); or something?
lol thanks