1. Can't seem to get the whole custom checks down. Looking to make it to where Donators receive a higher income than rather users. For example, players earn $1000 through Economy every 10 minutes. I am wanting VIP to earn $3500 every 10 minutes. I've tried to look around and can't find anything on it.

    I will pay $3 for this simple addition to Economy, the first to submit a working fix will be paid. Thank you.
     
  2. Code:
            float BasePayoutVIP => GetConfig("BasePayoutVIP", 100f);
    in LoadDefaultConfig()
                Config["BasePayoutVIP"] = BasePayoutVIP;in Loaded() change the foreach            foreach (var player in BasePlayer.activePlayerList){
                    if(permission.UserHasPermission(player.UserIDString, "moneytime.isvip"))
                        payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayoutVIP, ReceivedForPlaying));
                    else
                        payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayout, ReceivedForPlaying));
                }
    and anywhere else add        void Init()
            {
                permission.RegisterPermission("moneytime.isvip", this);
            }
    and change config to add
    Code:
      "BasePayoutVIP": 100.0,
    
    add permission to specific player or user group

    MoneyTime.isVIP
     
    Last edited by a moderator: May 30, 2016
  3. Wulf

    Wulf Community Admin

    You shouldn't check if a permission exists, only one plugin can register the same permission. You should also add the permission in Init or Loaded.
     
  4. Just add that to the bottom of the Economy plugin?
     
  5. Wulf

    Wulf Community Admin

    No, @sami37 was actually referring to the MoneyTime plugin that I develop.
     
  6. Also, I am going to have VIP and VIP Elite, can you make two separate payouts? Also, PM me your PayPal
     
  7. Wulf

    Wulf Community Admin

    You can just copy the bits and change it, but I'll likely just be adding something to allow dynamic payouts based on permissions soon.
     
  8. Code:
    /*
    TODO:
    - Add option to disable payout for AFK players (store last moved time)
    - Add option for daily/weekly login bonuses
    - Utilize player.net.connection.GetSecondsConnected() to multiplying
    */using System;
    using System.Collections.Generic;
    using System.Reflection;
    using ProtoBuf;
    using Oxide.Core;
    using Oxide.Core.Plugins;namespace Oxide.Plugins
    {
        [Info("MoneyTime", "Wulf/lukespragg", "1.0.2", ResourceId = 836)]
        [Description("Pays players money via Economics for playing on your server.")]    class MoneyTime : RustPlugin
        {
            // Do NOT edit this file, instead edit MoneyTime.json in server/<identity>/oxide/config        #region Configuration        // Messages
            string ReceivedForPlaying => GetConfig("ReceivedForPlaying", "You've received ${amount} for actively playing!");
            string ReceivedForTimeAlive => GetConfig("ReceivedForTimeAlive", "You've received ${amount} for staying alive for {time}!");
            string ReceivedWelcomeBonus => GetConfig("ReceivedWelcomeBonus", "You've received ${amount} as a welcome bonus!");        // Settings
            float BasePayout => GetConfig("BasePayout", 10f);
            int PayoutInterval => GetConfig("PayoutInterval", 600);
            bool TimeAliveBonus => GetConfig("TimeAliveBonus", true);
            float TimeAliveMultiplier => GetConfig("TimeAliveMultiplier", 2f);
            float WelcomeBonus => GetConfig("WelcomeBonus", 500f);        protected override void LoadDefaultConfig()
            {
                // Messages
                Config["ReceivedForPlaying"] = ReceivedForPlaying;
                Config["ReceivedForTimeAlive"] = ReceivedForTimeAlive;
                Config["ReceivedWelcomeBonus"] = ReceivedWelcomeBonus;            // Settings
                Config["BasePayout"] = BasePayout;
                Config["PayoutInterval"] = PayoutInterval;
                Config["TimeAliveBonus"] = TimeAliveBonus;
                Config["TimeAliveMultiplier"] = TimeAliveMultiplier;
                Config["WelcomeBonus"] = WelcomeBonus;            SaveConfig();
            }        #endregion        #region Data Storage        StoredData storedData;        class StoredData
            {
                public Dictionary<ulong, PlayerInfo> Players = new Dictionary<ulong, PlayerInfo>();            public StoredData()
                {
                }
            }        class PlayerInfo
            {
                public string Name;
                public bool WelcomeBonus;            public PlayerInfo()
                {
                }            public PlayerInfo(BasePlayer player)
                {
                    Name = player.displayName;
                    WelcomeBonus = true;
                }
            }        #endregion        #region General Setup/Cleanup        [PluginReference] Plugin Economics;
            [PluginReference] Plugin Reconomy;
            readonly Dictionary<ulong, Timer> payTimer = new Dictionary<ulong, Timer>();        void Loaded()
            {
                LoadDefaultConfig();
                storedData = Interface.Oxide.DataFileSystem.ReadObject<StoredData>(Name);            if (!Economics && !Reconomy) PrintWarning("No economy plugins found, plugin disabled");            foreach (var player in BasePlayer.activePlayerList)
                    payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayout, ReceivedForPlaying));
            }        void Unload()
            {
                foreach (var player in BasePlayer.activePlayerList) payTimer[player.userID].Destroy();
            }        #endregion        void Payout(BasePlayer player, double amount, string message)
            {
                if (!Economics && !Reconomy) return;            Economics?.Call("Deposit", player.userID, amount);
                Reconomy?.Call("Deposit", player.userID, amount);            PrintToChat(player, message.Replace("{amount}", amount.ToString()));
            }        #region Welcome Bonus/Repeat        void OnPlayerInit(BasePlayer player)
            {
                if (WelcomeBonus > 0f && !storedData.Players.ContainsKey(player.userID))
                {
                    var info = new PlayerInfo(player);
                    storedData.Players.Add(player.userID, info);
                    Interface.Oxide.DataFileSystem.WriteObject(Name, storedData);                Payout(player, WelcomeBonus, ReceivedWelcomeBonus);
                }            payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayout, ReceivedForPlaying));
            }        #endregion        #region Time Alive Bonus        readonly FieldInfo previousLifeStory = typeof(BasePlayer).GetField("previousLifeStory", BindingFlags.NonPublic | BindingFlags.Instance);        void OnPlayerRespawned(BasePlayer player)
            {
                if (!TimeAliveBonus) return;            var lifeStory = (PlayerLifeStory)previousLifeStory?.GetValue(player);
                if (lifeStory == null) return;            var secondsAlive = lifeStory.timeDied - lifeStory.timeBorn;
                const int math = 31 * 24 * 60 * 60;
                var amount = secondsAlive * TimeAliveMultiplier * ((1 - secondsAlive / math) + 2 * secondsAlive / math);
                var timeSpan = TimeSpan.FromSeconds(secondsAlive);
                var time = $"{timeSpan.TotalHours:00}h {timeSpan.Minutes:00}m {timeSpan.Seconds:00}s".TrimStart(' ', 'd', 'h', 'm', 's', '0');            Payout(player, amount, ReceivedForTimeAlive.Replace("{time}", time));
            }        void OnPlayerDisconnected(BasePlayer player) => payTimer[player.userID].Destroy();        #endregion        #region Helper Methods        T GetConfig<T>(string name, T defaultValue)
            {
                if (Config[name] == null) return defaultValue;
                return (T)Convert.ChangeType(Config[name], typeof(T));
            }        #endregion
        }
        float BasePayoutVIP => GetConfig("BasePayoutVIP", 100f);
    in LoadDefaultConfig()
        Config["BasePayoutVIP"] = BasePayoutVIP;in Loaded() change the foreach    foreach (var player in BasePlayer.activePlayerList){
            if(permission.UserHasPermission(player.UserIDString, "MoneyTime.isVIP"))
                payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayoutVIP, ReceivedForPlaying));
            else
                payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayout, ReceivedForPlaying));
        }
    and anywhere else addvoid Init()
    {
        permission.RegisterPermission("moneytime.isvipeite", this);
        float BasePayoutVIP => GetConfig("BasePayoutVIPElite", 100f);
    in LoadDefaultConfig()
        Config["BasePayoutVIPElite"] = BasePayoutVIP;in Loaded() change the foreach    foreach (var player in BasePlayer.activePlayerList){
            if(permission.UserHasPermission(player.UserIDString, "MoneyTime.isVIPElite"))
                payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayoutVIP, ReceivedForPlaying));
            else
                payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayout, ReceivedForPlaying));
        }
    and anywhere else addvoid Init()
    {
        permission.RegisterPermission("moneytime.isvipelite", this);
    }
    
    [Oxide] 14:07 [Error] MoneyTime plugin failed to compile!
    [Oxide] 14:07 [Error] MoneyTime.cs(183,36): error CS1525: Unexpected symbol `='
     
  9. You have to edit the part noted, not doing a copy paste of the whole code

    To explain you it should look like that :

    Code:
    /*
    TODO:
    - Add option to disable payout for AFK players (store last moved time)
    - Add option for daily/weekly login bonuses
    - Utilize player.net.connection.GetSecondsConnected() to multiplying
    */using System;
    using System.Collections.Generic;
    using System.Reflection;
    using ProtoBuf;
    using Oxide.Core;
    using Oxide.Core.Plugins;namespace Oxide.Plugins
    {
        [Info("MoneyTime", "Wulf/lukespragg", "1.0.2", ResourceId = 836)]
        [Description("Pays players money via Economics for playing on your server.")]    class MoneyTime : RustPlugin
        {
            // Do NOT edit this file, instead edit MoneyTime.json in server/<identity>/oxide/config        #region Configuration        // Messages
            string ReceivedForPlaying => GetConfig("ReceivedForPlaying", "You've received ${amount} for actively playing!");
            string ReceivedForTimeAlive => GetConfig("ReceivedForTimeAlive", "You've received ${amount} for staying alive for {time}!");
            string ReceivedWelcomeBonus => GetConfig("ReceivedWelcomeBonus", "You've received ${amount} as a welcome bonus!");        // Settings
            float BasePayout => GetConfig("BasePayout", 10f);
            float BasePayoutVIP => GetConfig("BasePayoutVIP", 100f);
    float BasePayoutElite => GetConfig("BasePayoutElite", 1000f);
            int PayoutInterval => GetConfig("PayoutInterval", 600);
            bool TimeAliveBonus => GetConfig("TimeAliveBonus", true);
            float TimeAliveMultiplier => GetConfig("TimeAliveMultiplier", 2f);
            float WelcomeBonus => GetConfig("WelcomeBonus", 500f);        protected override void LoadDefaultConfig()
            {
                // Messages
                Config["ReceivedForPlaying"] = ReceivedForPlaying;
                Config["ReceivedForTimeAlive"] = ReceivedForTimeAlive;
                Config["ReceivedWelcomeBonus"] = ReceivedWelcomeBonus;            // Settings
                Config["BasePayout"] = BasePayout;
                Config["BasePayoutVIP"] = BasePayoutVIP;
    Config["BasePayoutElite"] = BasePayoutElite;
                Config["PayoutInterval"] = PayoutInterval;
                Config["TimeAliveBonus"] = TimeAliveBonus;
                Config["TimeAliveMultiplier"] = TimeAliveMultiplier;
                Config["WelcomeBonus"] = WelcomeBonus;            SaveConfig();
            }        #endregion        #region Data Storage        StoredData storedData;        class StoredData
            {
                public Dictionary<ulong, PlayerInfo> Players = new Dictionary<ulong, PlayerInfo>();            public StoredData()
                {
                }
            }        class PlayerInfo
            {
                public string Name;
                public bool WelcomeBonus;            public PlayerInfo()
                {
                }            public PlayerInfo(BasePlayer player)
                {
                    Name = player.displayName;
                    WelcomeBonus = true;
                }
            }        #endregion        #region General Setup/Cleanup        [PluginReference] Plugin Economics;
            [PluginReference] Plugin Reconomy;
            readonly Dictionary<ulong, Timer> payTimer = new Dictionary<ulong, Timer>();        void Loaded()
            {
                LoadDefaultConfig();
                permission.RegisterPermission("MoneyTime.isVIP", this);
    permission.RegisterPermission("MoneyTime.isElite", this);
                storedData = Interface.Oxide.DataFileSystem.ReadObject<StoredData>(Name);            if (!Economics && !Reconomy) PrintWarning("No economy plugins found, plugin disabled");            foreach (var player in BasePlayer.activePlayerList){
                    if(permission.UserHasPermission(player.UserIDString, "MoneyTime.isVIP"))
                        payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayoutVIP, ReceivedForPlaying));
                    else if(permission.UserHasPermission(player.UserIDString, "MoneyTime.isElite"))
    payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayoutElite, ReceivedForPlaying));
    else
                        payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayout, ReceivedForPlaying));
                }
            }        void Unload()
            {
                foreach (var player in BasePlayer.activePlayerList) payTimer[player.userID].Destroy();
            }        #endregion        void Payout(BasePlayer player, double amount, string message)
            {
                if (!Economics && !Reconomy) return;            Economics?.Call("Deposit", player.userID, amount);
                Reconomy?.Call("Deposit", player.userID, amount);            PrintToChat(player, message.Replace("{amount}", amount.ToString()));
            }        #region Welcome Bonus/Repeat        void OnPlayerInit(BasePlayer player)
            {
                if (WelcomeBonus > 0f && !storedData.Players.ContainsKey(player.userID))
                {
                    var info = new PlayerInfo(player);
                    storedData.Players.Add(player.userID, info);
                    Interface.Oxide.DataFileSystem.WriteObject(Name, storedData);                Payout(player, WelcomeBonus, ReceivedWelcomeBonus);
                }            payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayout, ReceivedForPlaying));
            }        #endregion        #region Time Alive Bonus        readonly FieldInfo previousLifeStory = typeof(BasePlayer).GetField("previousLifeStory", BindingFlags.NonPublic | BindingFlags.Instance);
          
            void OnPlayerRespawned(BasePlayer player)
            {
                if (!TimeAliveBonus) return;            var lifeStory = (PlayerLifeStory)previousLifeStory?.GetValue(player);
                if (lifeStory == null) return;            var secondsAlive = lifeStory.timeDied - lifeStory.timeBorn;
                const int math = 31 * 24 * 60 * 60;
                var amount = secondsAlive * TimeAliveMultiplier * ((1 - secondsAlive / math) + 2 * secondsAlive / math);
                var timeSpan = TimeSpan.FromSeconds(secondsAlive);
                var time = $"{timeSpan.TotalHours:00}h {timeSpan.Minutes:00}m {timeSpan.Seconds:00}s".TrimStart(' ', 'd', 'h', 'm', 's', '0');            Payout(player, amount, ReceivedForTimeAlive.Replace("{time}", time));
            }        void OnPlayerDisconnected(BasePlayer player) => payTimer[player.userID].Destroy();        #endregion        #region Helper Methods        T GetConfig<T>(string name, T defaultValue)
            {
                if (Config[name] == null) return defaultValue;
                return (T)Convert.ChangeType(Config[name], typeof(T));
            }        #endregion
        }
    }
    
    and config like

    Code:
    {
      "BasePayout": 10.0,
      "BasePayoutVIP": 1000.0,
    "BasePayoutElite":3000.0,
      "PayoutInterval": 600,
      "ReceivedForPlaying": "You've received ${amount} for actively playing!",
      "ReceivedForTimeAlive": "You've received ${amount} for staying alive for {time}!",
      "ReceivedWelcomeBonus": "You've received ${amount} as a welcome bonus!",
      "TimeAliveBonus": true,
      "TimeAliveMultiplier": 2.0,
      "WelcomeBonus": 500.0
    }
     
    Last edited by a moderator: May 31, 2016
  10. Should this be possible with 3 ranks? 1 Normal Player 1 Silver Rank and 1 Bronze Rank?
     
  11. NVM got it fixed!
     
  12. Code:
    /*
    TODO:
    - Add option to disable payout for AFK players (store last moved time)
    - Add option for daily/weekly login bonuses
    - Utilize player.net.connection.GetSecondsConnected() to multiplying
    */using System;
    using System.Collections.Generic;
    using System.Reflection;
    using ProtoBuf;
    using Oxide.Core;
    using Oxide.Core.Plugins;namespace Oxide.Plugins
    {
        [Info("MoneyTime", "Wulf/lukespragg", "1.0.2", ResourceId = 836)]
        [Description("Pays players money via Economics for playing on your server.")]    class MoneyTime : RustPlugin
        {
            // Do NOT edit this file, instead edit MoneyTime.json in server/<identity>/oxide/config        #region Configuration        // Messages
            string ReceivedForPlaying => GetConfig("ReceivedForPlaying", "You've received ${amount} for actively playing!");
            string ReceivedForTimeAlive => GetConfig("ReceivedForTimeAlive", "You've received ${amount} for staying alive for {time}!");
            string ReceivedWelcomeBonus => GetConfig("ReceivedWelcomeBonus", "You've received ${amount} as a welcome bonus!");        // Settings
            float BasePayout => GetConfig("BasePayout", 10f);
            float BasePayoutVIP => GetConfig("BasePayoutVIP", 100f);
            float BasePayoutElite => GetConfig("BasePayoutElite", 1000f);
            float BasePayoutElite => GetConfig("BasePayoutPlayer", 2000f);
            int PayoutInterval => GetConfig("PayoutInterval", 600);
            bool TimeAliveBonus => GetConfig("TimeAliveBonus", true);
            float TimeAliveMultiplier => GetConfig("TimeAliveMultiplier", 2f);
            float WelcomeBonus => GetConfig("WelcomeBonus", 500f);        protected override void LoadDefaultConfig()
            {
                // Messages
                Config["ReceivedForPlaying"] = ReceivedForPlaying;
                Config["ReceivedForTimeAlive"] = ReceivedForTimeAlive;
                Config["ReceivedWelcomeBonus"] = ReceivedWelcomeBonus;            // Settings
                Config["BasePayout"] = BasePayout;
                Config["BasePayoutVIP"] = BasePayoutVIP;
                Config["BasePayoutElite"] = BasePayoutElite;
                Config["BasePayoutPlayer"] = BasePayoutPlayer;
                Config["PayoutInterval"] = PayoutInterval;
                Config["TimeAliveBonus"] = TimeAliveBonus;
                Config["TimeAliveMultiplier"] = TimeAliveMultiplier;
                Config["WelcomeBonus"] = WelcomeBonus;            SaveConfig();
            }        #endregion        #region Data Storage        StoredData storedData;        class StoredData
            {
                public Dictionary<ulong, PlayerInfo> Players = new Dictionary<ulong, PlayerInfo>();            public StoredData()
                {
                }
            }        class PlayerInfo
            {
                public string Name;
                public bool WelcomeBonus;            public PlayerInfo()
                {
                }            public PlayerInfo(BasePlayer player)
                {
                    Name = player.displayName;
                    WelcomeBonus = true;
                }
            }        #endregion        #region General Setup/Cleanup        [PluginReference] Plugin Economics;
            [PluginReference] Plugin Reconomy;
            readonly Dictionary<ulong, Timer> payTimer = new Dictionary<ulong, Timer>();        void Loaded()
            {
                LoadDefaultConfig();
                permission.RegisterPermission("MoneyTime.isVIP", this);
                permission.RegisterPermission("MoneyTime.isElite", this);
                permission.RegisterPermission("MoneyTime.isPlayer", this);
                storedData = Interface.Oxide.DataFileSystem.ReadObject<StoredData>(Name);            if (!Economics && !Reconomy) PrintWarning("No economy plugins found, plugin disabled");            foreach (var player in BasePlayer.activePlayerList){
                    if(permission.UserHasPermission(player.UserIDString, "MoneyTime.isVIP"))
                        payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayoutVIP, ReceivedForPlaying));
                    else if(permission.UserHasPermission(player.UserIDString, "MoneyTime.isElite"))
                        payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayoutElite, ReceivedForPlaying));
                    else if(permission.UserHasPermission(player.UserIDString, "MoneyTime.isPlayer"))
                        payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayoutPlayer, ReceivedForPlaying));
    else                    payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayout, ReceivedForPlaying));
                }
            }        void Unload()
            {
                foreach (var player in BasePlayer.activePlayerList) payTimer[player.userID].Destroy();
            }        #endregion        void Payout(BasePlayer player, double amount, string message)
            {
                if (!Economics && !Reconomy) return;            Economics?.Call("Deposit", player.userID, amount);
                Reconomy?.Call("Deposit", player.userID, amount);            PrintToChat(player, message.Replace("{amount}", amount.ToString()));
            }        #region Welcome Bonus/Repeat        void OnPlayerInit(BasePlayer player)
            {
                if (WelcomeBonus > 0f && !storedData.Players.ContainsKey(player.userID))
                {
                    var info = new PlayerInfo(player);
                    storedData.Players.Add(player.userID, info);
                    Interface.Oxide.DataFileSystem.WriteObject(Name, storedData);                Payout(player, WelcomeBonus, ReceivedWelcomeBonus);
                }            payTimer[player.userID] = timer.Repeat(PayoutInterval, 0, () => Payout(player, BasePayout, ReceivedForPlaying));
            }        #endregion        #region Time Alive Bonus        readonly FieldInfo previousLifeStory = typeof(BasePlayer).GetField("previousLifeStory", BindingFlags.NonPublic | BindingFlags.Instance);
        
            void OnPlayerRespawned(BasePlayer player)
            {
                if (!TimeAliveBonus) return;            var lifeStory = (PlayerLifeStory)previousLifeStory?.GetValue(player);
                if (lifeStory == null) return;            var secondsAlive = lifeStory.timeDied - lifeStory.timeBorn;
                const int math = 31 * 24 * 60 * 60;
                var amount = secondsAlive * TimeAliveMultiplier * ((1 - secondsAlive / math) + 2 * secondsAlive / math);
                var timeSpan = TimeSpan.FromSeconds(secondsAlive);
                var time = $"{timeSpan.TotalHours:00}h {timeSpan.Minutes:00}m {timeSpan.Seconds:00}s".TrimStart(' ', 'd', 'h', 'm', 's', '0');            Payout(player, amount, ReceivedForTimeAlive.Replace("{time}", time));
            }        void OnPlayerDisconnected(BasePlayer player) => payTimer[player.userID].Destroy();        #endregion        #region Helper Methods        T GetConfig<T>(string name, T defaultValue)
            {
                if (Config[name] == null) return defaultValue;
                return (T)Convert.ChangeType(Config[name], typeof(T));
            }        #endregion
        }
    Why does this not work lol :p @Wulf
     
    Last edited by a moderator: May 31, 2016
  13. You did
    Code:
            float BasePayoutElite => GetConfig("BasePayoutElite", 1000f);
            float BasePayoutElite => GetConfig("BasePayoutPlayer", 2000f);
    
    But it must be

    Code:
            float BasePayoutElite => GetConfig("BasePayoutElite", 1000f);
            float BasePayoutPlayer => GetConfig("BasePayoutPlayer", 2000f);