Beispiel #1
0
        public GiveStipends(SimpleCurrencyConfig options, IRegistryCore registry, SimpleCurrencyConnector CurrencyService)
        {
            m_enabled = options.GiveStipends;
            if (!m_enabled)
            {
                return;
            }

            m_currencyService  = CurrencyService;
            m_options          = options;
            m_registry         = registry;
            taskTimer.Interval = m_options.SchedulerInterval;
            taskTimer.Elapsed += TimerElapsed;
            m_scheduler        = registry.RequestModuleInterface <IScheduleService>();
            if (m_scheduler == null)
            {
                return;
            }
            m_scheduler.Register("StipendsPayout", StipendsPayOutEvent);
            if (m_options.StipendsLoadOldUsers)
            {
                taskTimer.Enabled = true;
            }
            registry.RequestModuleInterface <ISimulationBase>().EventManager.RegisterEventHandler("DeleteUserInformation", DeleteUserInformation);
            registry.RequestModuleInterface <ISimulationBase>().EventManager.RegisterEventHandler("CreateUserInformation", CreateUserInformation);
            registry.RequestModuleInterface <ISimulationBase>().EventManager.RegisterEventHandler("UpdateUserInformation", CreateUserInformation);
        }
        public void Initialize(IGenericData GenericData, IConfigSource source, IRegistryCore registry,
                               string defaultConnectionString)
        {
            m_gd       = GenericData;
            m_registry = registry;

            IConfig config = source.Configs["Currency"];

            if (config == null || source.Configs["Currency"].GetString("Module", "") != "SimpleCurrency")
            {
                return;
            }

            IConfig gridInfo = source.Configs["GridInfoService"];

            if (gridInfo != null)
            {
                InWorldCurrency = gridInfo.GetString("CurrencySymbol", String.Empty) + " ";
                RealCurrency    = gridInfo.GetString("RealCurrencySymbol", String.Empty) + " ";
            }

            if (source.Configs[Name] != null)
            {
                defaultConnectionString = source.Configs[Name].GetString("ConnectionString", defaultConnectionString);
            }

            if (GenericData != null)
            {
                GenericData.ConnectToDatabase(defaultConnectionString, "SimpleCurrency", true);
            }
            Framework.Utilities.DataManager.RegisterPlugin(Name, this);

            m_config = new SimpleCurrencyConfig(config);

            Init(m_registry, Name, "", "/currency/", "CurrencyServerURI");

            if (!m_doRemoteCalls)
            {
                MainConsole.Instance.Commands.AddCommand(
                    "money add",
                    "money add",
                    "Adds money to a user's account.",
                    AddMoney, false, true);

                MainConsole.Instance.Commands.AddCommand(
                    "money set",
                    "money set",
                    "Sets the amount of money a user has.",
                    SetMoney, false, true);

                MainConsole.Instance.Commands.AddCommand(
                    "money get",
                    "money get",
                    "Gets the amount of money a user has.",
                    GetMoney, false, true);

                MainConsole.Instance.Commands.AddCommand(
                    "show user transactions",
                    "show user transactions",
                    "Display user transactions for a period.",
                    HandleShowTransactions, false, true);

                MainConsole.Instance.Commands.AddCommand(
                    "show user purchases",
                    "show user purchases",
                    "Display user purchases for a period.",
                    HandleShowPurchases, false, true);
            }
        }