Hello. I've started using C sharp because most plugins are coded using it and I can learn from them. I am trying to make it so when someone says "purge" in the chat it displays privately what Purge means.
Here's the code:
Here's the startup error:Code:using Oxide.Core;namespace Oxide.Plugins { [Info("Purge", "Matthew Lang", 0.1, ResourceId = 0)] [Description("Adds a Purge element into the game.")] public class TestPlugin : RustPlugin { void Init() { Puts("Purge Plugin has loaded."); } void Unload() { Puts("Purge Plugin has been unloaded."); } var purge = "Raiding and killing on sight is not allowed, unless there is a purge, which happens every Saturday and Friday."; void OnPlayerChat(NetUser netuser, string purge) { rust.SendChatMessage({ netuser, purge }); } } }
[Oxide] 2:09 PM [Error] TestPlugin plugin failed to compile!
[Oxide] 2:09 PM [Error] TestPlugin.cs(24,0): error CS1525: Unexpected symbol `}'
Displaying chat message to player (C#)
Discussion in 'Rust Development' started by Captain. Knee Gell, Aug 2, 2015.
-
Again you are using netuser... netuser is for Rust Legacy...
player, is for experimental.
Also to send message to player use
Code:string message = "This is the message"; SendReply(player, message);
-
Ok thank you.
-
Wulf Community Admin
-
-
Wulf Community Admin
Code:using Oxide.Core;namespace Oxide.Plugins { [Info("Purge", "Matthew Lang", 0.1)] [Description("Adds a Purge element into the game.")] public class Purge : RustPlugin { string purge = "Raiding and killing on sight is not allowed, unless there is a purge, which happens every Saturday and Friday"; void OnPlayerChat(ConsoleSystem.Arg arg) { string message = arg.GetString(0, "text"); BasePlayer player = (BasePlayer) arg.connection.player; if (message.Contains("purge")) { PrintToChat(player, purge); } } } }
-
string researched = "Congratulations! You got the blueprint.";
SendReply(player, "RUST RP", researched);
I get this error:
[Oxide] 4:53 PM [Error] TestPlugin.cs(30,23): error CS0103: The name `player' does not exist in the current context
and how do I return the float in OnItemResearchEnd to become a success? so if they player successfully gets the blueprint it only says it, instead of even if he loses it says it? -
-
Code:
using Oxide.Core;namespace Oxide.Plugins { [Info("Purge", "Matthew Lang", 0.1, ResourceId = 0)] [Description("Adds a Purge element into the game.")] class TestPlugin : RustPlugin { void Init() { Puts("Purge Plugin has loaded."); } void Unload() { Puts("Purge Plugin has been unloaded."); } void OnPlayerRespawned(BasePlayer player) { string kos = "Think you've been killed on sight, and there is no purge? Contact an admin."; string tradezone = "You've been respawned at the Trade Zone. This is a safe, non-pvp area."; SendReply(player, "RUST RP", kos); SendReply(player, "RUST RP", tradezone); rust.ForcePlayerPosition(player, 1400, 6, -1882); } void OnItemResearchEnd(ResearchTable table, float chance) { string researched = "Congratulations! You got the blueprint."; SendReply(player, "RUST RP", researched); } string purge = "Raiding and killing on sight is not allowed, unless there is a purge, which happens every Saturday and Friday"; void OnPlayerChat(ConsoleSystem.Arg arg) { string message = arg.GetString(0, "text"); BasePlayer player = (BasePlayer) arg.connection.player; if (message.Contains("purge")) { PrintToChat(player, purge); } } } }
-