コード例 #1
0
 public static void Check(ClientInfo _cInfo)
 {
     if (!Reward_Entity && dict.Count == 0)
     {
         Log.Out(string.Format("[SERVERTOOLS] No items available for reward. Check for an error in the VoteReward.xml file."));
         Phrases.Dict.TryGetValue(302, out string _phrase302);
         ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase302 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         return;
     }
     if (Delay_Between_Uses == 0)
     {
         CheckSite(_cInfo);
     }
     else
     {
         DateTime _lastVoteReward = PersistentContainer.Instance.Players[_cInfo.playerId].LastVote;
         TimeSpan varTime         = DateTime.Now - _lastVoteReward;
         double   fractionalHours = varTime.TotalHours;
         int      _timepassed     = (int)fractionalHours;
         if (_timepassed >= Delay_Between_Uses)
         {
             CheckSite(_cInfo);
         }
         else
         {
             int _timeleft = Delay_Between_Uses - _timepassed;
             Phrases.Dict.TryGetValue(301, out string _phrase301);
             _phrase301 = _phrase301.Replace("{DelayBetweenRewards}", Delay_Between_Uses.ToString());
             _phrase301 = _phrase301.Replace("{TimeRemaining}", _timeleft.ToString());
             _phrase301 = _phrase301.Replace("{CommandPrivate}", ChatHook.Command_Private);
             _phrase301 = _phrase301.Replace("{Command46}", Command46);
             ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase301 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
 }
コード例 #2
0
        private static void Execute(ClientInfo _cInfo)
        {
            RewardOpen = false;
            ServicePointManager.ServerCertificateValidationCallback += (send, certificate, chain, sslPolicyErrors) => { return(true); };
            var VoteUrl = string.Format("https://7daystodie-servers.com/api/?object=votes&element=claim&key={0}&username={1}", Uri.EscapeUriString(API_Key), Uri.EscapeUriString(_cInfo.playerName));

            using (var NewVote = new WebClient())
            {
                string VoteResult = NewVote.DownloadString(VoteUrl);
                if (VoteResult == "0")
                {
                    NoVote(_cInfo);
                }
                if (VoteResult == "1")
                {
                    if (!Reward_Entity)
                    {
                        if (dict.Count > 0 && Reward_Count > 0)
                        {
                            if (Reward_Count > dict.Count)
                            {
                                Reward_Count = dict.Count;
                            }
                            string _phrase701;
                            if (!Phrases.Dict.TryGetValue(701, out _phrase701))
                            {
                                _phrase701 = "Thank you for your vote {PlayerName}. You can vote and receive another reward in {VoteDelay} hours.";
                            }
                            _phrase701 = _phrase701.Replace("{PlayerName}", _cInfo.playerName);
                            _phrase701 = _phrase701.Replace("{VoteDelay}", Delay_Between_Uses.ToString());
                            _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase701), Config.Server_Response_Name, false, "ServerTools", false));
                            ItemOrBlock(_cInfo);
                        }
                        else
                        {
                            Log.Out("[SERVERTOOLS] Vote reward: dictionary empty or reward count is set to zero.");
                        }
                    }
                    else
                    {
                        Entity(_cInfo);
                    }
                }
                else
                {
                    Que();
                    string _phrase702;
                    if (!Phrases.Dict.TryGetValue(702, out _phrase702))
                    {
                        _phrase702 = "Unable to get a result from the website, {PlayerName}. Please try /reward again.";
                    }
                    _phrase702 = _phrase702.Replace("{PlayerName}", _cInfo.playerName);
                    _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase702), Config.Server_Response_Name, false, "ServerTools", false));
                }
            }
        }
コード例 #3
0
 private static void Entity(ClientInfo _cInfo)
 {
     Entityspawn(_cInfo);
     if (Weekly_Votes > 0)
     {
         DateTime _lastVoteWeek  = PersistentContainer.Instance.Players[_cInfo.playerId].LastVoteWeek;
         TimeSpan varTime        = DateTime.Now - _lastVoteWeek;
         double   fractionalDays = varTime.TotalDays;
         int      _timepassed    = (int)fractionalDays;
         if (_timepassed < 7)
         {
             int _voteWeekCount = PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount;
             if (_voteWeekCount + 1 == Weekly_Votes)
             {
                 PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount = 1;
                 PersistentContainer.Instance.Players[_cInfo.playerId].LastVoteWeek  = DateTime.Now;
                 PersistentContainer.Instance.Save();
                 Entityspawn(_cInfo);
                 Phrases.Dict.TryGetValue(305, out string _phrase305);
                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase305 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
             }
             else
             {
                 PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount = _voteWeekCount + 1;
                 PersistentContainer.Instance.Save();
                 int      _remainingVotes = Weekly_Votes - _voteWeekCount + 1;
                 DateTime _date2          = _lastVoteWeek.AddDays(7);
                 Phrases.Dict.TryGetValue(306, out string _phrase306);
                 _phrase306 = _phrase306.Replace("{Value}", _voteWeekCount + 1.ToString());
                 _phrase306 = _phrase306.Replace("{Date}", _lastVoteWeek.ToString());
                 _phrase306 = _phrase306.Replace("{Value2}", _remainingVotes.ToString());
                 _phrase306 = _phrase306.Replace("{Date2}", _date2.ToString());
                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase306 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
             }
         }
         else
         {
             PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount = 1;
             PersistentContainer.Instance.Players[_cInfo.playerId].LastVoteWeek  = DateTime.Now;
             PersistentContainer.Instance.Save();
             int      _remainingVotes = Weekly_Votes - 1;
             DateTime _date2          = DateTime.Now.AddDays(7);
             Phrases.Dict.TryGetValue(306, out string _phrase306);
             _phrase306 = _phrase306.Replace("{Value}", 1.ToString());
             _phrase306 = _phrase306.Replace("{Date}", _lastVoteWeek.ToString());
             _phrase306 = _phrase306.Replace("{Value2}", _remainingVotes.ToString());
             _phrase306 = _phrase306.Replace("{Date2}", _date2.ToString());
             ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase306 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
     Phrases.Dict.TryGetValue(307, out string _phrase307);
     _phrase307 = _phrase307.Replace("{Value}", Delay_Between_Uses.ToString());
     ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase307 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
 }
コード例 #4
0
ファイル: VoteReward.cs プロジェクト: Mink80/7dtd-ServerTools
 public static void Check(ClientInfo _cInfo)
 {
     if (!Reward_Entity && dict.Count == 0)
     {
         ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "Vote reward count is set to zero. Contact an administrator." + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         Log.Out(string.Format("[SERVERTOOLS] No items available for reward. Check for an error in the VoteReward.xml file."));
         return;
     }
     if (Delay_Between_Uses == 0)
     {
         CheckSite(_cInfo);
     }
     else
     {
         string    _sql    = string.Format("SELECT lastVoteReward FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
         DataTable _result = SQL.TQuery(_sql);
         DateTime  _lastVoteReward;
         DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastVoteReward);
         _result.Dispose();
         if (_lastVoteReward.ToString() == "10/29/2000 7:30:00 AM")
         {
             CheckSite(_cInfo);
         }
         else
         {
             TimeSpan varTime         = DateTime.Now - _lastVoteReward;
             double   fractionalHours = varTime.TotalHours;
             int      _timepassed     = (int)fractionalHours;
             if (_timepassed >= Delay_Between_Uses)
             {
                 CheckSite(_cInfo);
             }
             else
             {
                 int    _timeleft = Delay_Between_Uses - _timepassed;
                 string _phrase602;
                 if (!Phrases.Dict.TryGetValue(602, out _phrase602))
                 {
                     _phrase602 = " you can only use {CommandPrivate}{Command46} once every {DelayBetweenRewards} hours. Time remaining: {TimeRemaining} hour(s).";
                 }
                 _phrase602 = _phrase602.Replace("{DelayBetweenRewards}", Delay_Between_Uses.ToString());
                 _phrase602 = _phrase602.Replace("{TimeRemaining}", _timeleft.ToString());
                 _phrase602 = _phrase602.Replace("{CommandPrivate}", ChatHook.Command_Private);
                 _phrase602 = _phrase602.Replace("{Command46}", Command46);
                 ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase602 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
             }
         }
     }
 }
コード例 #5
0
 public static void Check(ClientInfo _cInfo)
 {
     if (dict.Count > 0)
     {
         if (Delay_Between_Uses == 0)
         {
             Open(_cInfo);
         }
         else
         {
             Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false];
             if (p == null || p.LastVoteReward == null)
             {
                 Open(_cInfo);
             }
             else
             {
                 TimeSpan varTime         = DateTime.Now - p.LastVoteReward;
                 double   fractionalHours = varTime.TotalHours;
                 int      _timepassed     = (int)fractionalHours;
                 if (_timepassed >= Delay_Between_Uses)
                 {
                     Open(_cInfo);
                 }
                 else
                 {
                     int    _timeleft = Delay_Between_Uses - _timepassed;
                     string _phrase602;
                     if (!Phrases.Dict.TryGetValue(602, out _phrase602))
                     {
                         _phrase602 = "{PlayerName} you can only use /reward once every {DelayBetweenRewards} hours. Time remaining: {TimeRemaining} hour(s).";
                     }
                     _phrase602 = _phrase602.Replace("{PlayerName}", _cInfo.playerName);
                     _phrase602 = _phrase602.Replace("{DelayBetweenRewards}", Delay_Between_Uses.ToString());
                     _phrase602 = _phrase602.Replace("{TimeRemaining}", _timeleft.ToString());
                     {
                         _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase602), Config.Server_Response_Name, false, "ServerTools", false));
                     }
                 }
             }
         }
     }
     else
     {
         Log.Out(string.Format("[SERVERTOOLS] No items available for reward. Check for an error in the file."));
     }
 }
コード例 #6
0
 public static void Check(ClientInfo _cInfo)
 {
     try
     {
         if (!Reward_Entity && Dict.Count == 0)
         {
             Log.Out(string.Format("[SERVERTOOLS] No items available for reward. Check for an error in the VoteReward.xml file"));
             Phrases.Dict.TryGetValue("VoteReward2", out string phrase);
             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             return;
         }
         if (Delay_Between_Uses == 0)
         {
             CheckSite(_cInfo);
         }
         else
         {
             DateTime lastVoteReward = DateTime.Now;
             if (PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastVote != null)
             {
                 lastVoteReward = PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastVote;
             }
             TimeSpan varTime         = DateTime.Now - lastVoteReward;
             double   fractionalHours = varTime.TotalHours;
             int      timepassed      = (int)fractionalHours;
             if (timepassed >= Delay_Between_Uses)
             {
                 CheckSite(_cInfo);
             }
             else
             {
                 int timeleft = Delay_Between_Uses - timepassed;
                 Phrases.Dict.TryGetValue("VoteReward1", out string phrase);
                 phrase = phrase.Replace("{DelayBetweenRewards}", Delay_Between_Uses.ToString());
                 phrase = phrase.Replace("{TimeRemaining}", timeleft.ToString());
                 phrase = phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1);
                 phrase = phrase.Replace("{Command_reward}", Command_reward);
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in VoteReward.Check: {0}", e.Message));
     }
 }
コード例 #7
0
 public static void Check(ClientInfo _cInfo)
 {
     if (!Reward_Entity && dict.Count == 0)
     {
         ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "Vote reward count is set to zero. Contact an administrator." + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         Log.Out(string.Format("[SERVERTOOLS] No items available for reward. Check for an error in the VoteReward.xml file."));
         return;
     }
     if (Delay_Between_Uses == 0)
     {
         CheckSite(_cInfo);
     }
     else
     {
         DateTime _lastVoteReward = PersistentContainer.Instance.Players[_cInfo.playerId].LastVote;
         TimeSpan varTime         = DateTime.Now - _lastVoteReward;
         double   fractionalHours = varTime.TotalHours;
         int      _timepassed     = (int)fractionalHours;
         if (_timepassed >= Delay_Between_Uses)
         {
             CheckSite(_cInfo);
         }
         else
         {
             int    _timeleft = Delay_Between_Uses - _timepassed;
             string _phrase602;
             if (!Phrases.Dict.TryGetValue(602, out _phrase602))
             {
                 _phrase602 = " you can only use {CommandPrivate}{Command46} once every {DelayBetweenRewards} hours. Time remaining: {TimeRemaining} hour(s).";
             }
             _phrase602 = _phrase602.Replace("{DelayBetweenRewards}", Delay_Between_Uses.ToString());
             _phrase602 = _phrase602.Replace("{TimeRemaining}", _timeleft.ToString());
             _phrase602 = _phrase602.Replace("{CommandPrivate}", ChatHook.Command_Private);
             _phrase602 = _phrase602.Replace("{Command46}", Command46);
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase602 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
 }
コード例 #8
0
        private static void Entity(ClientInfo _cInfo)
        {
            EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];

            if (_player.IsSpawned())
            {
                Vector3 pos = _player.GetPosition();
                float   x = pos.x;
                float   y = pos.y;
                float   z = pos.z;
                int     _x, _y, _z;
                posFound = true;
                posFound = GameManager.Instance.World.FindRandomSpawnPointNearPosition(new Vector3((float)x, (float)y, (float)z), 15, out _x, out _y, out _z, new Vector3((float)5, (float)5, (float)5), true);
                if (!posFound)
                {
                    posFound = GameManager.Instance.World.FindRandomSpawnPointNearPosition(new Vector3((float)x, (float)y, (float)z), 15, out _x, out _y, out _z, new Vector3((float)5 + 5, (float)5 + 10, (float)5 + 5), true);
                }
                if (posFound)
                {
                    int counter = 1;
                    Dictionary <int, EntityClass> .KeyCollection entityTypesCollection = EntityClass.list.Dict.Keys;
                    foreach (int i in entityTypesCollection)
                    {
                        EntityClass eClass = EntityClass.list[i];
                        if (!eClass.bAllowUserInstantiate)
                        {
                            continue;
                        }
                        if (Entity_Id == counter)
                        {
                            Entity entity = EntityFactory.CreateEntity(i, new Vector3((float)_x, (float)_y, (float)_z));
                            GameManager.Instance.World.SpawnEntityInWorld(entity);
                            string _sql = string.Format("UPDATE Players SET lastVoteReward = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
                            SQL.FastQuery(_sql);
                            string _message = "spawned a {EntityName} near you.";
                            _message = _message.Replace("{EntityName}", eClass.entityClassName);
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                            string _phrase701;
                            if (!Phrases.Dict.TryGetValue(701, out _phrase701))
                            {
                                _phrase701 = "Thank you for your vote {PlayerName}. You can vote and receive another reward in {VoteDelay} hours.";
                            }
                            _phrase701 = _phrase701.Replace("{PlayerName}", _cInfo.playerName);
                            _phrase701 = _phrase701.Replace("{VoteDelay}", Delay_Between_Uses.ToString());
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase701 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                            Log.Out(string.Format("[SERVERTOOLS] Spawned an entity reward {0} at {1} x, {2} y, {3} z for {4}", eClass.entityClassName, _x, _y, _z, _cInfo.playerName));
                            Que();
                        }
                        counter++;
                    }
                    if (counter == entityTypesCollection.Count + 1)
                    {
                        Log.Out(string.Format("[SERVERTOOLS] Failed to spawn entity Id {0} as a reward. Check your entity spawn list in console.", Entity_Id));
                        Que();
                    }
                }
                else
                {
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", no spawn point was found near you. Please move locations and try again.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    Que();
                }
            }
            else
            {
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", can not give you a vote reward unless spawned. Please type /reward again.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                Que();
            }
        }
コード例 #9
0
ファイル: VoteReward.cs プロジェクト: Mink80/7dtd-ServerTools
        private static void Entity(ClientInfo _cInfo)
        {
            Entityspawn(_cInfo);
            string _sql2 = string.Format("UPDATE Players SET lastVoteReward = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);

            SQL.FastQuery(_sql2, "VoteReward");
            if (Weekly_Votes > 0)
            {
                string    _sql    = string.Format("SELECT lastVoteWeekly FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                DataTable _result = SQL.TQuery(_sql);
                DateTime  _lastVoteWeekly;
                DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastVoteWeekly);
                _result.Dispose();
                TimeSpan varTime        = DateTime.Now - _lastVoteWeekly;
                double   fractionalDays = varTime.TotalDays;
                int      _timepassed    = (int)fractionalDays;
                if (_timepassed < 7)
                {
                    _sql = string.Format("SELECT weeklyVoteCount FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                    DataTable _result2 = SQL.TQuery(_sql);
                    int       _weeklyVoteCount;
                    int.TryParse(_result2.Rows[0].ItemArray.GetValue(0).ToString(), out _weeklyVoteCount);
                    _result2.Dispose();
                    if (_weeklyVoteCount + 1 == Weekly_Votes)
                    {
                        _sql = string.Format("UPDATE Players SET weeklyVoteCount = 1, lastVoteWeekly = {0} WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
                        SQL.FastQuery(_sql, "VoteReward");
                        Entityspawn(_cInfo);
                        string _phrase704;
                        if (!Phrases.Dict.TryGetValue(704, out _phrase704))
                        {
                            _phrase704 = " you have reached the votes needed in a week. Thank you! Sent you an extra reward and reset your weekly votes to 1.";
                        }
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase704 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                    else
                    {
                        _sql = string.Format("UPDATE Players SET weeklyVoteCount = {0} WHERE steamid = '{1}'", _weeklyVoteCount + 1, _cInfo.playerId);
                        SQL.FastQuery(_sql, "VoteReward");
                        int      _remainingVotes = Weekly_Votes - _weeklyVoteCount + 1;
                        DateTime _date2          = _lastVoteWeekly.AddDays(7);
                        string   _phrase705;
                        if (!Phrases.Dict.TryGetValue(705, out _phrase705))
                        {
                            _phrase705 = " you have voted {Votes} time since {Date}. You need {Count} more votes before {Date2} to reach the bonus.";
                        }
                        _phrase705 = _phrase705.Replace("{Votes}", _weeklyVoteCount + 1.ToString());
                        _phrase705 = _phrase705.Replace("{Date}", _lastVoteWeekly.ToString());
                        _phrase705 = _phrase705.Replace("{Count}", _remainingVotes.ToString());
                        _phrase705 = _phrase705.Replace("{Date2}", _date2.ToString());
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase705 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
                else
                {
                    _sql = string.Format("UPDATE Players SET weeklyVoteCount = 1, lastVoteWeekly = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
                    SQL.FastQuery(_sql, "VoteReward");
                    int      _remainingVotes = Weekly_Votes - 1;
                    DateTime _date2          = DateTime.Now.AddDays(7);
                    string   _phrase705;
                    if (!Phrases.Dict.TryGetValue(705, out _phrase705))
                    {
                        _phrase705 = " you have voted 1 time since {Date}. You need {Count} more votes before {Date2} to reach the bonus.";
                    }
                    _phrase705 = _phrase705.Replace("{Date}", DateTime.Now.ToString());
                    _phrase705 = _phrase705.Replace("{Count}", _remainingVotes.ToString());
                    _phrase705 = _phrase705.Replace("{Date2}", _date2.ToString());
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase705 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                }
            }
            string _phrase701;

            if (!Phrases.Dict.TryGetValue(701, out _phrase701))
            {
                _phrase701 = "Thank you for your vote {PlayerName}. You can vote and receive another reward in {VoteDelay} hours.";
            }
            _phrase701 = _phrase701.Replace("{PlayerName}", _cInfo.playerName);
            _phrase701 = _phrase701.Replace("{VoteDelay}", Delay_Between_Uses.ToString());
            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase701 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
        }
コード例 #10
0
        private static void Entity(ClientInfo _cInfo)
        {
            Entityspawn(_cInfo);
            if (Weekly_Votes > 0)
            {
                DateTime _lastVoteWeek  = PersistentContainer.Instance.Players[_cInfo.playerId].LastVoteWeek;
                TimeSpan varTime        = DateTime.Now - _lastVoteWeek;
                double   fractionalDays = varTime.TotalDays;
                int      _timepassed    = (int)fractionalDays;
                if (_timepassed < 7)
                {
                    int _voteWeekCount = PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount;
                    if (_voteWeekCount + 1 == Weekly_Votes)
                    {
                        PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount = 1;
                        PersistentContainer.Instance.Players[_cInfo.playerId].LastVoteWeek  = DateTime.Now;
                        PersistentContainer.Instance.Save();
                        Entityspawn(_cInfo);
                        string _phrase704;
                        if (!Phrases.Dict.TryGetValue(704, out _phrase704))
                        {
                            _phrase704 = " you have reached the votes needed in a week. Thank you! Sent you an extra reward and reset your weekly votes to 1.";
                        }
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase704 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                    else
                    {
                        PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount = _voteWeekCount + 1;
                        PersistentContainer.Instance.Save();
                        int      _remainingVotes = Weekly_Votes - _voteWeekCount + 1;
                        DateTime _date2          = _lastVoteWeek.AddDays(7);
                        string   _phrase705;
                        if (!Phrases.Dict.TryGetValue(705, out _phrase705))
                        {
                            _phrase705 = " you have voted {Votes} time since {Date}. You need {Count} more votes before {Date2} to reach the bonus.";
                        }
                        _phrase705 = _phrase705.Replace("{Votes}", _voteWeekCount + 1.ToString());
                        _phrase705 = _phrase705.Replace("{Date}", _lastVoteWeek.ToString());
                        _phrase705 = _phrase705.Replace("{Count}", _remainingVotes.ToString());
                        _phrase705 = _phrase705.Replace("{Date2}", _date2.ToString());
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase705 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
                else
                {
                    PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount = 1;
                    PersistentContainer.Instance.Players[_cInfo.playerId].LastVoteWeek  = DateTime.Now;
                    PersistentContainer.Instance.Save();
                    int      _remainingVotes = Weekly_Votes - 1;
                    DateTime _date2          = DateTime.Now.AddDays(7);
                    string   _phrase705;
                    if (!Phrases.Dict.TryGetValue(705, out _phrase705))
                    {
                        _phrase705 = " you have voted 1 time since {Date}. You need {Count} more votes before {Date2} to reach the bonus.";
                    }
                    _phrase705 = _phrase705.Replace("{Date}", DateTime.Now.ToString());
                    _phrase705 = _phrase705.Replace("{Count}", _remainingVotes.ToString());
                    _phrase705 = _phrase705.Replace("{Date2}", _date2.ToString());
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase705 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                }
            }
            string _phrase701;

            if (!Phrases.Dict.TryGetValue(701, out _phrase701))
            {
                _phrase701 = "Thank you for your vote. You can vote and receive another reward in {VoteDelay} hours.";
            }
            _phrase701 = _phrase701.Replace("{VoteDelay}", Delay_Between_Uses.ToString());
            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase701 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
        }
コード例 #11
0
        private static void Entity(ClientInfo _cInfo)
        {
            EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];

            if (_player.IsSpawned())
            {
                Vector3 pos = _player.GetPosition();
                float   x = pos.x;
                float   y = pos.y;
                float   z = pos.z;
                int     _x, _y, _z;
                posFound = true;
                posFound = GameManager.Instance.World.FindRandomSpawnPointNearPosition(new Vector3((float)x, (float)y, (float)z), 15, out _x, out _y, out _z, new Vector3((float)5, (float)5, (float)5), true);
                if (!posFound)
                {
                    posFound = GameManager.Instance.World.FindRandomSpawnPointNearPosition(new Vector3((float)x, (float)y, (float)z), 15, out _x, out _y, out _z, new Vector3((float)5 + 5, (float)5 + 10, (float)5 + 5), true);
                }
                if (posFound)
                {
                    int counter = 1;
                    Dictionary <int, EntityClass> .KeyCollection entityTypesCollection = EntityClass.list.Keys;
                    foreach (int i in entityTypesCollection)
                    {
                        EntityClass eClass = EntityClass.list[i];
                        if (!eClass.bAllowUserInstantiate)
                        {
                            continue;
                        }
                        if (Entity_Id == counter)
                        {
                            Entity entity = EntityFactory.CreateEntity(i, new Vector3((float)_x, (float)_y, (float)_z));
                            GameManager.Instance.World.SpawnEntityInWorld(entity);
                            PersistentContainer.Instance.Players[_cInfo.playerId, true].LastVoteReward = DateTime.Now;
                            PersistentContainer.Instance.Save();
                            _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}Spawned a {1} near you.[-]", Config.Chat_Response_Color, eClass.entityClassName), Config.Server_Response_Name, false, "ServerTools", false));
                            string _phrase701;
                            if (!Phrases.Dict.TryGetValue(701, out _phrase701))
                            {
                                _phrase701 = "Thank you for your vote {PlayerName}. You can vote and receive another reward in {VoteDelay} hours.";
                            }
                            _phrase701 = _phrase701.Replace("{PlayerName}", _cInfo.playerName);
                            _phrase701 = _phrase701.Replace("{VoteDelay}", Delay_Between_Uses.ToString());
                            _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase701), Config.Server_Response_Name, false, "ServerTools", false));
                            Log.Out(string.Format("[SERVERTOOLS] Spawned an entity reward {0} at {1} x, {2} y, {3} z for {4}", eClass.entityClassName, _x, _y, _z, _cInfo.playerName));
                            Que();
                        }
                        counter++;
                    }
                    if (counter == entityTypesCollection.Count + 1)
                    {
                        Log.Out(string.Format("[SERVERTOOLS] Failed to spawn entity Id {0} as a reward. Check your entity spawn list in console.", Entity_Id));
                        Que();
                    }
                }
                else
                {
                    _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}No spawn point was found near you. Please move locations and try again.[-]", Config.Chat_Response_Color), Config.Server_Response_Name, false, "ServerTools", false));
                    Que();
                }
            }
            else
            {
                _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}Can not give you a vote reward unless spawned. Please type /reward again.[-]", Config.Chat_Response_Color), Config.Server_Response_Name, false, "ServerTools", false));
                Que();
            }
        }
コード例 #12
0
 public static void ItemOrBlockCounter(ClientInfo _cInfo, int _counter)
 {
     ItemOrBlockRandom(_cInfo);
     _counter--;
     if (_counter != 0)
     {
         ItemOrBlockCounter(_cInfo, _counter);
     }
     else
     {
         if (Weekly_Votes > 1)
         {
             DateTime _lastVoteWeek;
             if (PersistentContainer.Instance.Players[_cInfo.playerId].LastVoteWeek != null)
             {
                 _lastVoteWeek = PersistentContainer.Instance.Players[_cInfo.playerId].LastVoteWeek;
             }
             else
             {
                 _lastVoteWeek = DateTime.Now;
             }
             TimeSpan varTime        = DateTime.Now - _lastVoteWeek;
             double   fractionalDays = varTime.TotalDays;
             int      _timepassed    = (int)fractionalDays;
             if (_timepassed < 7)
             {
                 int _voteWeekCount = PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount;
                 if (_voteWeekCount + 1 == Weekly_Votes)
                 {
                     PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount = 1;
                     PersistentContainer.Instance.Players[_cInfo.playerId].LastVoteWeek  = DateTime.Now;
                     PersistentContainer.Instance.Save();
                     ItemOrBlockRandom(_cInfo);
                     string _phrase704;
                     if (!Phrases.Dict.TryGetValue(704, out _phrase704))
                     {
                         _phrase704 = "You have reached the votes needed in a week. Thank you! Sent you an extra reward and reset your weekly votes to 1.";
                     }
                     ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase704 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
                 else
                 {
                     PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount = _voteWeekCount + 1;
                     PersistentContainer.Instance.Save();
                     int      _remainingVotes = Weekly_Votes - _voteWeekCount + 1;
                     DateTime _date2          = _lastVoteWeek.AddDays(7);
                     string   _phrase705;
                     if (!Phrases.Dict.TryGetValue(705, out _phrase705))
                     {
                         _phrase705 = "You have voted {Votes} time since {Date}. You need {Count} more votes before {Date2} to reach the bonus.";
                     }
                     _phrase705 = _phrase705.Replace("{Votes}", _voteWeekCount + 1.ToString());
                     _phrase705 = _phrase705.Replace("{Date}", _lastVoteWeek.ToString());
                     _phrase705 = _phrase705.Replace("{Count}", _remainingVotes.ToString());
                     _phrase705 = _phrase705.Replace("{Date2}", _date2.ToString());
                     ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase705 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
             else
             {
                 PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount = 1;
                 PersistentContainer.Instance.Players[_cInfo.playerId].LastVoteWeek  = DateTime.Now;
                 PersistentContainer.Instance.Save();
                 int      _remainingVotes = Weekly_Votes - 1;
                 DateTime _date2          = DateTime.Now.AddDays(7);
                 string   _phrase705;
                 if (!Phrases.Dict.TryGetValue(705, out _phrase705))
                 {
                     _phrase705 = "You have voted {Votes} time since {Date}. You need {Count} more votes before {Date2} to reach the bonus.";
                 }
                 _phrase705 = _phrase705.Replace("{Votes}", 1.ToString());
                 _phrase705 = _phrase705.Replace("{Date}", DateTime.Now.ToString());
                 _phrase705 = _phrase705.Replace("{Count}", _remainingVotes.ToString());
                 _phrase705 = _phrase705.Replace("{Date2}", _date2.ToString());
                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase705 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
             }
         }
         string _phrase701;
         if (!Phrases.Dict.TryGetValue(701, out _phrase701))
         {
             _phrase701 = "Thank you for your vote. You can vote and receive another reward in {VoteDelay} hours.";
         }
         _phrase701 = _phrase701.Replace("{VoteDelay}", Delay_Between_Uses.ToString());
         ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase701 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         string _phrase703;
         if (!Phrases.Dict.TryGetValue(703, out _phrase703))
         {
             _phrase703 = "Reward items were sent to your inventory. If it is full, check the ground.";
         }
         ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase703 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
     }
 }
コード例 #13
0
 public static void ItemOrBlockCounter(ClientInfo _cInfo, int _counter)
 {
     try
     {
         ItemOrBlockRandom(_cInfo);
         _counter--;
         if (_counter != 0)
         {
             ItemOrBlockCounter(_cInfo, _counter);
         }
         else
         {
             if (Weekly_Votes > 1)
             {
                 DateTime lastVoteWeek;
                 if (PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastVoteWeek != null)
                 {
                     lastVoteWeek = PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastVoteWeek;
                 }
                 else
                 {
                     lastVoteWeek = DateTime.Now;
                 }
                 TimeSpan varTime        = DateTime.Now - lastVoteWeek;
                 double   fractionalDays = varTime.TotalDays;
                 int      timepassed     = (int)fractionalDays;
                 if (timepassed < 7)
                 {
                     int voteWeekCount = PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].VoteWeekCount;
                     if (voteWeekCount + 1 == Weekly_Votes)
                     {
                         PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].VoteWeekCount = 1;
                         PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastVoteWeek  = DateTime.Now;
                         ItemOrBlockRandom(_cInfo);
                         Phrases.Dict.TryGetValue("VoteReward5", out string phrase);
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                     else
                     {
                         PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].VoteWeekCount = voteWeekCount + 1;
                         int      remainingVotes = Weekly_Votes - voteWeekCount + 1;
                         DateTime date2          = lastVoteWeek.AddDays(7);
                         Phrases.Dict.TryGetValue("VoteReward6", out string phrase);
                         phrase = phrase.Replace("{Value}", voteWeekCount + 1.ToString());
                         phrase = phrase.Replace("{Date}", lastVoteWeek.ToString());
                         phrase = phrase.Replace("{Value2}", remainingVotes.ToString());
                         phrase = phrase.Replace("{Date2}", date2.ToString());
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
                 else
                 {
                     PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].VoteWeekCount = 1;
                     PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastVoteWeek  = DateTime.Now;
                     int      remainingVotes = Weekly_Votes - 1;
                     DateTime date2          = DateTime.Now.AddDays(7);
                     Phrases.Dict.TryGetValue("VoteReward6", out string phrase);
                     phrase = phrase.Replace("{Value}", 1.ToString());
                     phrase = phrase.Replace("{Date}", lastVoteWeek.ToString());
                     phrase = phrase.Replace("{Value2}", remainingVotes.ToString());
                     phrase = phrase.Replace("{Date2}", date2.ToString());
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
                 PersistentContainer.DataChange = true;
             }
             Phrases.Dict.TryGetValue("VoteReward7", out string phrase1);
             phrase1 = phrase1.Replace("{Value}", Delay_Between_Uses.ToString());
             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase1 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             Phrases.Dict.TryGetValue("VoteReward8", out phrase1);
             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase1 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             Phrases.Dict.TryGetValue("VoteReward11", out phrase1);
             phrase1 = phrase1.Replace("{PlayerName}", _cInfo.playerName);
             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase1 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null);
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in VoteReward.ItemOrBlockCounter: {0}", e.Message));
     }
 }
コード例 #14
0
 public static void ItemOrBlockCounter(ClientInfo _cInfo, int _counter)
 {
     ItemOrBlockRandom(_cInfo);
     _counter--;
     if (_counter != 0)
     {
         ItemOrBlockCounter(_cInfo, _counter);
     }
     else
     {
         if (Weekly_Votes > 1)
         {
             DateTime _lastVoteWeek;
             if (PersistentContainer.Instance.Players[_cInfo.playerId].LastVoteWeek != null)
             {
                 _lastVoteWeek = PersistentContainer.Instance.Players[_cInfo.playerId].LastVoteWeek;
             }
             else
             {
                 _lastVoteWeek = DateTime.Now;
             }
             TimeSpan varTime        = DateTime.Now - _lastVoteWeek;
             double   fractionalDays = varTime.TotalDays;
             int      _timepassed    = (int)fractionalDays;
             if (_timepassed < 7)
             {
                 int _voteWeekCount = PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount;
                 if (_voteWeekCount + 1 == Weekly_Votes)
                 {
                     PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount = 1;
                     PersistentContainer.Instance.Players[_cInfo.playerId].LastVoteWeek  = DateTime.Now;
                     PersistentContainer.DataChange = true;
                     ItemOrBlockRandom(_cInfo);
                     Phrases.Dict.TryGetValue(305, out string _phrase305);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase305 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
                 else
                 {
                     PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount = _voteWeekCount + 1;
                     PersistentContainer.DataChange = true;
                     int      _remainingVotes = Weekly_Votes - _voteWeekCount + 1;
                     DateTime _date2          = _lastVoteWeek.AddDays(7);
                     Phrases.Dict.TryGetValue(306, out string _phrase306);
                     _phrase306 = _phrase306.Replace("{Value}", _voteWeekCount + 1.ToString());
                     _phrase306 = _phrase306.Replace("{Date}", _lastVoteWeek.ToString());
                     _phrase306 = _phrase306.Replace("{Value2}", _remainingVotes.ToString());
                     _phrase306 = _phrase306.Replace("{Date2}", _date2.ToString());
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase306 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
             else
             {
                 PersistentContainer.Instance.Players[_cInfo.playerId].VoteWeekCount = 1;
                 PersistentContainer.Instance.Players[_cInfo.playerId].LastVoteWeek  = DateTime.Now;
                 PersistentContainer.DataChange = true;
                 int      _remainingVotes = Weekly_Votes - 1;
                 DateTime _date2          = DateTime.Now.AddDays(7);
                 Phrases.Dict.TryGetValue(306, out string _phrase306);
                 _phrase306 = _phrase306.Replace("{Value}", 1.ToString());
                 _phrase306 = _phrase306.Replace("{Date}", _lastVoteWeek.ToString());
                 _phrase306 = _phrase306.Replace("{Value2}", _remainingVotes.ToString());
                 _phrase306 = _phrase306.Replace("{Date2}", _date2.ToString());
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase306 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             }
         }
         Phrases.Dict.TryGetValue(307, out string _phrase307);
         _phrase307 = _phrase307.Replace("{Value}", Delay_Between_Uses.ToString());
         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase307 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
         Phrases.Dict.TryGetValue(308, out string _phrase308);
         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase308 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
         Phrases.Dict.TryGetValue(311, out string _phrase311);
         _phrase311 = _phrase311.Replace("{PlayerName}", _cInfo.playerName);
         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase311 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null);
     }
 }