The thing is, in the first line where it says Config["PopupEnabled"].ToString() doesn't work. How do I reference that part of the config in this format?Code:if (Config["PopupEnabled"].ToString() = true); { PopupNotifications?.Call("CreatePopupNotification",Config["RespawnMessage"].ToString()); } else { SendReply(player, Config["RespawnMessage"].ToString()); }
Solved If statement calling from config, thanks K1llY0u
Discussion in 'Rust Development' started by Kappasaurus, Jul 5, 2016.
-
Primary Constructor body is not allowed. Also ignore the uneven formatting, pasting it messed it up.Code:
using Oxide.Core.Plugins; namespace Oxide.Plugins { [Info("RespawnMessagesTest", "Kappasaurus & DylanSMR", 0.1)] [Description("Make customized notes players view on respawn!")] class RespawnMessagesTest : RustPlugin { [PluginReference] Plugin PopupNotifications; void LoadDefaultConfig() { Config.Clear(); Config["RespawnMessage"] = "Hey, try not to die this time!"; Config["PopupEnabled"] = "false"; Config.Save(); } void OnPlayerRespawn(BasePlayer player); if Config["PopupEnabled"] = "true"; { PopupNotifications?.Call("CreatePopupNotification",Config["RespawnMessage"].ToString()); } if Config["ChatEnabled"] = "true"; { SendReply(player, Config["RespawnMessage"].ToString()); } [ChatCommand("rmessage")] void TestCommand(BasePlayer player, string command, string[] args) { SendReply(player, "<size=22><color=#cd422b>Respawn Messages v0.1</color></size>"); SendReply(player, "<size=12>Created by </size><size=14>Kappasaurus</size><size=12> & </size><size=14>DylanSMR</size>"); } }Last edited by a moderator: Jul 5, 2016 -
Well when someone gets a chance can they show me the fix/tell me what I did wrong? Thanks
-
Few things, if statements need to be inside ( ), and don't finish the if line with ;
You were missing some { }
Code:using Oxide.Core.Plugins; namespace Oxide.Plugins { [Info("RespawnMessagesTest", "Kappasaurus & DylanSMR", 0.1)] [Description("Make customized notes players view on respawn!")] class RespawnMessagesTest : RustPlugin { [PluginReference] Plugin PopupNotifications; void LoadDefaultConfig() { Config.Clear(); Config["RespawnMessage"] = "Hey, try not to die this time!"; //Config["PopupEnabled"] = "false"; This is a string, should be bool Config["PopupEnabled"] = false; // Without the quotations marks makes it bool Config["ChatEnabled"] = false; Config.Save(); } void OnPlayerRespawn(BasePlayer player) { if ((bool)Config["PopupEnabled"] == true) // since you know the type cast it to bool with (bool) { PopupNotifications?.Call("CreatePopupNotification", Config["RespawnMessage"].ToString()); } if ((bool)Config["ChatEnabled"] == true) { SendReply(player, Config["RespawnMessage"].ToString()); } } [ChatCommand("rmessage")] void TestCommand(BasePlayer player, string command, string[] args) { SendReply(player, "<size=22><color=#cd422b>Respawn Messages v0.1</color></size>"); SendReply(player, "<size=12>Created by </size><size=14>Kappasaurus</size><size=12> & </size><size=14>DylanSMR</size>"); } } }Last edited by a moderator: Jul 5, 2016 -
Thanks
I'm terrible at this -
Get yourself a free copy of VS and set it up using this guide. It will show you any errors
Setting up a C# workspace in Visual Studio 2015 | Oxide -
Thanks, will do!
[DOUBLEPOST=1467712691][/DOUBLEPOST]Failed to call hook "OnPlayerRespawn" on plugin "RespawnMessages v0.1.0" (NullReferenceException: Object reference not set to an instance of an object.
Any idea? -
Delete your old config maybe
-
That did the trick
Will site you, appreciate it -
Have the program myself very handy
-
Yep, I do too, I didn't realize there was a way to use it with the oxide API.
[DOUBLEPOST=1467713313][/DOUBLEPOST]How do I update a resource that isn't approved? -
how to update a resource that is not approved You got to love google
-
I meant on oxide
I released my plugin at about 2
AM, I don't see an update option, @Wulf may have to approve it first.
[DOUBLEPOST=1467715210][/DOUBLEPOST]Here, you won't be able to access it yet.
http://oxidemod.org/plugins/respawn-messages.1995/Attached Files:
-
-
Wulf needs to approve it first
-
Yep, just waiting.
-
Wulf Community Admin
If you intended the plugin to provide a random message, you may want to go back to the drawing board.
As it stands right now, it only allows one message in the config you have setup. -
For a idea he could create a list full of strings and he could pull a random one each time!
-
Wulf Community Admin
Yes, but right now it's just a single string stored in the config and pulled. -
Ah, just an idea
Just learning.
Approve my plugin plz m8
[DOUBLEPOST=1467748671][/DOUBLEPOST]Yep, I believe there is even a random number API, that you can set to gen x through x, which I used for a random skin changer.

