Well, I just started with C# and tried something easy, rewriting my Easy Broadcast plugin.
But, when I tried to use BroadcastChat or SendChatMessage and so on, it gave me an error, that it wasnt able to find that. (tried it with and without "rust.") For now I used the method Reneb used in AirdropControl:
Also I may be "using" stuff I don't really need. How do I know what I need for the stuff I want to do?Code:using System.Collections.Generic; using System.Reflection; using System; using System.Data; using Oxide.Core;namespace Oxide.Plugins { [Info("Easy Broadcast", "LaserHydra", 2.0)] class EasyBroadcast : RustPlugin { [ChatCommand("bcast")] void cmdBroadcast(BasePlayer player, string cmd, string[] args) { string allArgs, message; allArgs = ""; foreach(string arg in args) allArgs = allArgs + " " + arg; message = "<color=orange>BROADCAST</color>:" + allArgs; BroadcastToChat(message); } void BroadcastToChat(string msg) { ConsoleSystem.Broadcast("chat.add \"SERVER\" " + msg.QuoteSafe() + " 1.0", new object[0]); } } }
Solved Rust.SendChatMessage etc. [C#]
Discussion in 'Rust Development' started by LaserHydra, Jun 2, 2015.
-
Wulf Community Admin
Use PrintToChat and such instead. https://github.com/OxideMod/Oxide/blob/master/Oxide.Ext.Rust/RustPlugin.cs#L140
The library functions are meant for the non-C# languages. -
-
Wulf Community Admin
You don't need UserIDFromPlayer, that's only needed for languages that can't handle int64. Just grab the SteamID directly from the player or connection. -
I see some of them are rewritten as CSharp code in the docs but only a few
Thanks -
Wulf Community Admin
-
Another quick question. In the docs, its shown like that:
[Info("Easy Broadcast", "Broadcast a message around the server", "LaserHydra", "2.0.0", ResourceID = 863)]
But when I am using it like this, it tells me that it does not accept 4 args or more -
Wulf Community Admin
Code:[Info("Plugin", "Author", 1.0, ResourceId = 9999)] [Description("This is what my plugin does")]
-
-
Wulf Community Admin
-
[DOUBLEPOST=1433285705][/DOUBLEPOST]... Im always getting this message:
[Oxide] 12:59 AM [Debug] Plugin is already being loaded: EasyBroadcast
Reloading or unloading the plugin doesn't help. Even deleteing it doesn't help
[DOUBLEPOST=1433286732][/DOUBLEPOST]Also Im not getting the permissions to work....
Code:using System.Collections.Generic; using System.Reflection; using System; using System.Data; using UnityEngine; using Oxide.Core;namespace Oxide.Plugins { [Info("Easy Broadcast", "LaserHydra", "2.0.0", ResourceId = 863)] [Description("Broadcast a message around the server")] class EasyBroadcast : RustPlugin { [ChatCommand("bcast")] void cmdBroadcast(BasePlayer player, string cmd, string[] args) { string uid; uid = Convert.ToString(player.userID); if (!permission.UserHasPermission(uid, "canBroadcast")) { SendReply(player, "<color=orange>BROADCAST</color>: You have no permission to use this command!"); return; } if (args == null || args.Length < 1) { SendReply(player, "<color=orange>BROADCAST</color>: Syntax: /bcast [message]"); } string allArgs, message; allArgs = ""; foreach (string arg in args) allArgs = allArgs + " " + arg; PrintToChat("<color=orange>BROADCAST</color>:" + allArgs); } } }
Last edited by a moderator: Jun 3, 2015