1. Code:
    if (Config["PopupEnabled"].ToString() = true);
    {
    PopupNotifications?.Call("CreatePopupNotification",Config["RespawnMessage"].ToString());
    }
    else
    {
    SendReply(player, Config["RespawnMessage"].ToString());
    }
    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?
     
    Last edited by a moderator: Jul 5, 2016
  2. 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>");
            } 
        }
    
    Primary Constructor body is not allowed. Also ignore the uneven formatting, pasting it messed it up.
     
    Last edited by a moderator: Jul 5, 2016
  3. Well when someone gets a chance can they show me the fix/tell me what I did wrong? Thanks ;)
     
  4. 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
  5. Thanks ;) I'm terrible at this
     
  6. 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?
     
  7. Delete your old config maybe
     
  8. That did the trick :) Will site you, appreciate it
     
  9. Have the program myself very handy
     
  10. 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?
     
  11. Attached Files:

  12. Wulf needs to approve it first
     
  13. Yep, just waiting.
     
  14. Wulf

    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.
     
  15. For a idea he could create a list full of strings and he could pull a random one each time!
     
  16. Wulf

    Wulf Community Admin

    Yes, but right now it's just a single string stored in the config and pulled.
     
  17. Ah, just an idea ;) Just learning.
    Approve my plugin plz m8 :D
    [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.