1. Hey, everybody has to start somewhere and I'm making a simple plugin.
    Code:
    namespace Oxide.Plugins
    {
        [Info("RespawnMessages", "Kappasaurus", 0.1)]
        [Description("Make customized notes players view on respawn!")]    class RespawnMessages : RustPlugin
        {
            void OnPlayerRespawned(BasePlayer player)
            {
                SendPlayer("Hey! Try not to die this time!");
            }
        }
    }
    
    Can someone show me how to make a config file, where the player can change the respawn message?
    [DOUBLEPOST=1467693581][/DOUBLEPOST]Error: SendPlayer, does not exist in the current context.
     
    Last edited by a moderator: Jul 5, 2016
  2. Ok, so I guess I need to get the player, because put shows in console.
    [DOUBLEPOST=1467694842][/DOUBLEPOST]Update:
    Code:
    namespace Oxide.Plugins
    {
        [Info("RespawnMessages", "Kappasaurus", 0.1)]
        [Description("Make customized notes players view on respawn!")]    class RespawnMessages : RustPlugin
        {
            void OnPlayerRespawn(BasePlayer player)
            {
            Puts("Test!");
            }
        }
    }
    
    So how do I change the puts to SendPlayer without getting errors?
    Sorry for being such a noob :p
     
  3. Instead of SendPlayer use SendReply. Examples:
    Code:
    SendReply(player, string message);
    So for that it would be:
    Code:
    SendReply(player, "Hey! Try not to die this time!");
    [DOUBLEPOST=1467695693][/DOUBLEPOST]Now if you wanted it so they could change it whenever they wanted(per player) you would have to use some sort of data system.
     
  4. Thanks man :), but how would I create a config file the owner/admin can edit, that is created in oxide config folder?
     
  5. If you wanted a config file:
    Code:
    void LoadDefaultConfig()
    {
       Config.Clear();
       Config["DeathMessage"] = "This is a test!";
       Config.Save();
    }
    Now if you wanted to add more to that just do another Config[""] and then delete the current config and reload the plugin.
    Config["This is where the name of the config goes"] = "This is what that config equals"

    If you wanted to pull that data try something like:
    Code:
            [ConsoleCommand("test")]
            void test()
            {
                Puts(Config["DefGroupName"].ToString());
            }        {
                Config.Clear();
                    Config["DefGroupName"] = _defGroupName;
                Config.Save();
            }
    [DOUBLEPOST=1467696293][/DOUBLEPOST]Now if its a integer or a float(vector, etc) you can try various methods to retrieve it:
    Code:
    Convert.ToInt32(Config[""]); which would convert a something to a int.
    Convert.ToInt64(Config[""]); which would convert something to a float.
    
     
    Last edited by a moderator: Jul 5, 2016
  6. Ok so say I changed the DeathMessage name to RespawnMessage, I would do
    Code:
    SendReply(player, "RespawnMessage")
    Is that correct? So when it is changed the message would rely on it?
     
  7. SendReply(player, Config["RespawnMessage"].ToString());
     
  8. Code:
    namespace Oxide.Plugins
    {
        [Info("RespawnMessages", "Kappasaurus", 0.1)]
        [Description("Make customized notes players view on respawn!")]    class RespawnMessages : RustPlugin
        {
            void LoadDefaultConfig()
            {
               Config.Clear();
               Config["RespawnMessage"] = "Hey, try not to die this time!";
               Config.Save();
            }        void OnPlayerRespawn(BasePlayer player)
            {
            SendReply(player, Config["RespawnMessage"].ToString());
            }
        }
    }
    
     
  9. Yes. That should work!
     
  10. Thanks man :) I'm going to try to upload this, my first plugin... I will site you, maybe I will be able to make something really cool in the future
     
  11. Cool. Make sure everything works in game of course! Also don't forget to check out other plugins as they contain a lot of information such as hooks and methods you might need.
     
  12. Yep, works perfectly, even the config, I will put you as an author.
    [DOUBLEPOST=1467697187][/DOUBLEPOST]
    Getting errors, unexpected symbols, 19, 32
    [DOUBLEPOST=1467697702][/DOUBLEPOST]
    Code:
            [Command("rmessage")]
            void TestCommand(IPlayer player, string command, string[] args)
            {
                SendReply(player, "<size=20>Respawn Messages v0.1</size><size=16>by <size=18>Kappasaurus</size><size=16> & </size>      <size=18>");
            }
    
     
    Last edited by a moderator: Jul 5, 2016
  13. Code:
    using Oxide.Core.Plugins;
    namespace Oxide.Plugins
    {
        [Info("RespawnMessages", "Kappasaurus", 0.2)]
        [Description("Make customized notes players view on respawn!")]    class RespawnMessages : RustPlugin
        {
            [PluginReference]
            Plugin PopupNotifications;
            void LoadDefaultConfig()
            {
                Config.Clear();
                Config["RespawnMessagePopup"] = "<size=20>Hey, <color=#cd422b>try not to die</color> this time!</size>";
                Config["RespawnMessageChat"] = "Hey, <color=#cd422b>try not to die</color> this time!";
                Config["Prefix"] = "<color=#cd422b>[</color> Server <color=#cd422b>]</color>";
                Config["PopupEnabled"] = false;
                Config["ChatEnabled"] = true;
                Config["PrefixEnabled"] = true;
                Config.Save();
            }
            void OnPlayerRespawn(BasePlayer player)
            {
                if ((bool)Config["PrefixEnabled"] == true)
                {  
                SendReply(player, "The prefic works (I haven't expanded fully on this system, I just need to make sure it works in the first place... I will include popup API and chat messages for the prefix option.)")
                }
                else;
                if ((bool)Config["PopupEnabled"] == true)
                {
                    PopupNotifications?.Call("CreatePopupNotification", Config["RespawnMessagePopup"].ToString());
                }
                if ((bool)Config["ChatEnabled"] == true)
                {
                    SendReply(player, Config["RespawnMessageChat"].ToString());
                }
            }
            [ChatCommand("rm")]
            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> with the help of </size><size=14>DylanSMR</size>");
            }
        }
    }
    
    When I try to reload it I get it saying I need a semi-colon at the end of the else, however even when I add it I still get the same error, does anyone know what is wrong with my if/else prefix statement.
     
  14. Wulf

    Wulf Community Admin

    I'd store i
    Just the missing ; is all I see so far on the line above that. The else should not have an ;.
     
  15. Seems to do the trick.
    [DOUBLEPOST=1467753628][/DOUBLEPOST]
    Just an OCD thing, why is my config genning like this
    Code:
    {
      "ChatEnabled": true,
      "PopupEnabled": false,
      "Prefix": "<color=#cd422b>[</color> Server <color=#cd422b>]</color>",
      "PrefixEnabled": true,
      "RespawnMessageChat": "Hey, <color=#cd422b>try not to die</color> this time!",
      "RespawnMessagePopup": "<size=20>Hey, <color=#cd422b>try not to die</color> this time!</size>"
    }
    
    when my code is
    Code:
     {
                Config.Clear();
                Config["RespawnMessagePopup"] = "<size=20>Hey, <color=#cd422b>try not to die</color> this time!</size>";
                Config["RespawnMessageChat"] = "Hey, <color=#cd422b>try not to die</color> this time!";
                Config["Prefix"] = "<color=#cd422b>[</color> Server <color=#cd422b>]</color>";
                Config["PopupEnabled"] = false;
                Config["ChatEnabled"] = true;
                Config["PrefixEnabled"] = true;
                Config.Save();
            }
    
     
  16. Wulf

    Wulf Community Admin

    It's A-Z.
     
  17. Nevermind, had to put the else action in brackets.
     
  18. Would there be anothrr way to organize it? A-Z is good but I would like to make sections.
     
  19. Wulf

    Wulf Community Admin

    You can make sections as much as you'd like.