Пример #1
0
        private void Loaded()
        {
            _ins = this;

            // Loading, purging, saving

            LoadData();

            if (_config.Purge)
            {
                var currentTime = _time.GetUnixTimestamp();
                for (var i = _data.Players.Count - 1; i >= 0; i--)
                {
                    var data = _data.Players[i];
                    if (data.LastUpdate + _config.PurgeTime < currentTime)
                    {
                        _data.Players.RemoveAt(i);
                        continue;
                    }

                    data.UpdateCurrencies();
                }
            }

            SaveData();
        }
Пример #2
0
 private void TryGiveCS(IPlayer player, double amount)
 {
     if (CashSystem.Call <bool>("AddTransaction", ulong.Parse(player.Id), config.CashSystemCurrency, amount, "Starter Money"))
     {
         data.Players.Add(player.Id);
     }
 }
Пример #3
0
        private double GetPlayerCash(ulong userId, string currency)
        {
            object checkedPoints = CashSystem?.Call("GetBalance", userId, currency);

            if (checkedPoints is double)
            {
                double val = (double)checkedPoints;
                if (double.IsNaN(val))
                {
                    return(0);
                }

                return(val);
            }

            return(0);
        }
Пример #4
0
        private void MagicPanelRegisterPanels()
        {
            if (MagicPanel == null)
            {
                PrintError("Missing plugin dependency MagicPanel: https://umod.org/plugins/magic-panel");
                return;
            }

            if (CashSystem == null)
            {
                PrintError("Missing plugin dependency CashSystem: https://umod.org/plugins/cash-system");
                return;
            }

            MagicPanel?.Call("RegisterPlayerPanel", this, Name, JsonConvert.SerializeObject(_pluginConfig.PanelSettings), nameof(GetPanel));
            _currencies = CashSystem.Call <List <string> >("GetCurrencies");
            InvokeHandler.Instance.InvokeRepeating(UpdatePlayerCash, Random.Range(0, _pluginConfig.UpdateRate), _pluginConfig.UpdateRate);
        }