Exemple #1
0
        protected override void Load()
        {
            instance    = this;
            lastUpdated = DateTime.Now;
            games       = new List <ArenaGame>();

            if (File.Exists(arenaPath))
            {
                try
                {
                    arenaList = DeserializeArena(arenaPath);
                }
                catch (SerializationException)
                {
                    arenaList = new List <Arena>();
                    Logger.Log("Deserialization of arenas datafile failed.");
                    Logger.Log("This is normal for the first run. If it persists, delete arenas.dat in this plugin's directory.");
                }
            }
            else
            {
                File.Create(arenaPath).Dispose();
                arenaList = new List <Arena>();
            }
            UnturnedPlayerEvents.OnPlayerUpdatePosition += PlayerUpdatedPosition;
            U.Events.OnPlayerDisconnected += OnDisconnected;
            DamageTool.playerDamaged      += OnPlayerDamage;
        }
Exemple #2
0
        public void Execute(IRocketPlayer caller, string[] args)
        {
            if (args.Length != 2)
            {
                UnturnedChat.Say(caller, Syntax, Color.red);
                return;
            }

            UnturnedPlayer challenged = UnturnedPlayer.FromName(args[0]);

            if (challenged == null)
            {
                UnturnedChat.Say(caller, Util.Translate("extraduel_invalid_player"), Color.red);
                return;
            }

            UnturnedPlayer p = (UnturnedPlayer)caller;

            if (challenged.CSteamID.m_SteamID == p.CSteamID.m_SteamID)
            {
                UnturnedChat.Say(caller, Util.Translate("extraduel_self_invoke"), Color.red);
                return;
            }

            ExtraPlayer ep = challenged.GetComponent <ExtraPlayer>();

            if (!ep.acceptingChallengers)
            {
                UnturnedChat.Say(caller, Util.Translate("extraduel_challenges_off"), Color.red);
                return;
            }
            if (!ExtraDuel.ArenaExists(args[1]))
            {
                UnturnedChat.Say(caller, Util.Translate("extraduel_removearena_fail_not_found"), Color.red);
                return;
            }

            if (ep.challenges.ContainsKey(p.CSteamID.m_SteamID))
            {
                UnturnedChat.Say(caller, Util.Translate("extraduel_already_challenged"), Color.red);
                return;
            }

            ep.CreateChallenge(challenged, DateTime.Now.AddSeconds(20), ExtraDuel.ArenaFromName(args[1]));
            UnturnedChat.Say(caller, Util.Translate("extraduel_challenge_success", challenged.DisplayName), Color.green);
        }