Ejemplo n.º 1
0
        public static void TeleFriend(ClientInfo _cInfo, int _friendToTele)
        {
            EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
            ClientInfo   _cInfo2 = ConnectionManager.Instance.Clients.ForEntityId(_friendToTele);

            if (_cInfo2 != null)
            {
                Players.NoFlight.Add(_cInfo2.entityId);
                _cInfo2.SendPackage(new NetPackageTeleportPlayer(new Vector3((int)_player.position.x, (int)_player.position.y, (int)_player.position.z), null, false));
                string _sql;
                if (Wallet.IsEnabled && Command_Cost >= 1)
                {
                    Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost);
                }
                _sql = string.Format("UPDATE Players SET lastFriendTele = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo2.playerId);
                SQL.FastQuery(_sql);
                string _phrase631;
                if (!Phrases.Dict.TryGetValue(631, out _phrase631))
                {
                    _phrase631 = "your request was accepted. Teleporting you to your friend.";
                }
                ChatHook.ChatMessage(_cInfo2, LoadConfig.Chat_Response_Color + _cInfo2.playerName + _phrase631 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
        }
Ejemplo n.º 2
0
        public static void CheckBox(ClientInfo _cInfo, string _price)
        {
            string    _sql    = string.Format("SELECT auctionid, steamid FROM Auction WHERE steamid = '{0}'", _cInfo.playerId);
            DataTable _result = SQL.TQuery(_sql);

            if (_result.Rows.Count > 0)
            {
                int _auctionid;
                int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _auctionid);
                string _message = "you have auction item # {Value} in the auction already. Wait for it to sell or cancel it with /auction cancel.";
                _message = _message.Replace("{Value}", _auctionid.ToString());
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
            else
            {
                int _p;
                if (int.TryParse(_price, out _p))
                {
                    if (_p > 0)
                    {
                        ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
                        for (int i = 0; i < chunklist.Count; i++)
                        {
                            ChunkCluster chunk = chunklist[i];
                            chunkArray = chunk.GetChunkArray();
                            foreach (Chunk _c in chunkArray)
                            {
                                tiles = _c.GetTileEntities();
                                foreach (TileEntity tile in tiles.dict.Values)
                                {
                                    TileEntityType type = tile.GetTileEntityType();
                                    if (type.ToString().Equals("SecureLoot"))
                                    {
                                        EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                                        TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                                        Vector3i vec3i = SecureLoot.ToWorldPos();
                                        if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 1.5 * 1.5)
                                        {
                                            int _playerCount = ConnectionManager.Instance.ClientCount();
                                            if (_playerCount > 1)
                                            {
                                                List <ClientInfo> _cInfoList = ConnectionManager.Instance.Clients.List.ToList();
                                                for (int k = 0; k < _cInfoList.Count; k++)
                                                {
                                                    ClientInfo _cInfo2 = _cInfoList[k];
                                                    if (_cInfo != _cInfo2)
                                                    {
                                                        EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId];
                                                        if ((vec3i.x - _player2.position.x) * (vec3i.x - _player2.position.x) + (vec3i.z - _player2.position.z) * (vec3i.z - _player2.position.z) <= 8 * 8)
                                                        {
                                                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you are too close to another player to use auction. Tell them to back off and get their own moldy sandwich.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                            return;
                                                        }
                                                    }
                                                }
                                            }
                                            List <string> boxUsers = SecureLoot.GetUsers();
                                            if (!boxUsers.Contains(_cInfo.playerId) && !SecureLoot.GetOwner().Equals(_cInfo.playerId))
                                            {
                                                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", the local secure loot is not owned by you or a friend. You can only auction an item through a secure loot you own.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                return;
                                            }
                                            ItemStack[] items      = SecureLoot.items;
                                            int         count      = 0;
                                            int         slotNumber = 0;
                                            foreach (ItemStack item in items)
                                            {
                                                if (!item.IsEmpty())
                                                {
                                                    if (count < 1)
                                                    {
                                                        ItemClass _itemClass = ItemClass.list[item.itemValue.type];
                                                        string    _itemName  = _itemClass.GetItemName();
                                                        SecureLoot.UpdateSlot(slotNumber, ItemStack.Empty);
                                                        _sql = string.Format("INSERT INTO Auction (steamid, itemName, itemCount, itemQuality, itemPrice, cancelTime, sellDate) VALUES ('{0}', '{1}', {2}, {3}, {4}, '{5}', '{6}')", _cInfo.playerId, _itemName, item.count, item.itemValue.Quality, _price, DateTime.Now, DateTime.Now);
                                                        SQL.FastQuery(_sql);
                                                        string _message = "your auction item {Name} has been removed from the secure loot and added to the auction.";
                                                        _message = _message.Replace("{Name}", _itemName);
                                                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                        using (StreamWriter sw = new StreamWriter(filepath, true))
                                                        {
                                                            sw.WriteLine(string.Format("{0}: {1} has added {2} {3}, {4} quality to the auction for {5} {6}.", DateTime.Now, _cInfo.playerName, item.count, _itemName, item.itemValue.Quality, _price, Wallet.Coin_Name));
                                                            sw.WriteLine();
                                                            sw.Flush();
                                                            sw.Close();
                                                        }
                                                        count++;
                                                    }
                                                }
                                                slotNumber++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you need to input a price greater than zero. This is not a transfer system.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
                else
                {
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", your sell price must be an integer and greater than zero.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                }
            }
            _result.Dispose();
        }
Ejemplo n.º 3
0
 public void PlayerSpawning(ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile)
 {
     if (_cInfo != null)
     {
         if (CountryBan.IsEnabled && _cInfo.ip != "127.0.0.1" && !_cInfo.ip.StartsWith("192.168"))
         {
             if (CountryBan.IsCountryBanned(_cInfo))
             {
                 return;
             }
         }
         string    _sql    = string.Format("SELECT steamid FROM Players WHERE steamid = '{0}'", _cInfo.playerId);;
         DataTable _result = SQL.TQuery(_sql);
         string    _name   = SQL.EscapeString(_cInfo.playerName);
         if (_result.Rows.Count == 0)
         {
             _sql = string.Format("INSERT INTO Players (steamid, playername, last_joined) VALUES ('{0}', '{1}', '{2}')", _cInfo.playerId, _name, DateTime.Now);
         }
         else
         {
             _sql = string.Format("UPDATE Players SET playername = '{0}', last_joined = '{1}' WHERE steamid = '{2}'", _name, DateTime.Now, _cInfo.playerId);
         }
         _result.Dispose();
         SQL.FastQuery(_sql);
         if (StopServer.NoEntry)
         {
             int    _seconds = (60 - Timers._sSCD);
             string _phrase452;
             if (!Phrases.Dict.TryGetValue(452, out _phrase452))
             {
                 _phrase452 = "Shutdown is in {Minutes} minutes {Seconds} seconds. Please come back after the server restarts.";
             }
             _phrase452 = _phrase452.Replace("{Minutes}", Timers._sSC.ToString());
             _phrase452 = _phrase452.Replace("{Seconds}", _seconds.ToString());
             SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.entityId, _phrase452), (ClientInfo)null);
         }
         if (ReservedSlots.IsEnabled)
         {
             if (ReservedSlots.Kicked.ContainsKey(_cInfo.playerName))
             {
                 DateTime _dateTime;
                 ReservedSlots.Kicked.TryGetValue(_cInfo.playerId, out _dateTime);
                 TimeSpan varTime           = DateTime.Now - _dateTime;
                 double   fractionalMinutes = varTime.TotalMinutes;
                 int      _timepassed       = (int)fractionalMinutes;
                 if (_timepassed >= 5)
                 {
                     int    _timeleft = 5 - _timepassed;
                     string _phrase22;
                     if (!Phrases.Dict.TryGetValue(22, out _phrase22))
                     {
                         _phrase22 = "Sorry {PlayerName} you have reached the max session time. Please wait {TimeRemaining} minutes before rejoining.";
                     }
                     _phrase22 = _phrase22.Replace("{PlayerName}", _cInfo.playerName);
                     _phrase22 = _phrase22.Replace("{TimeRemaining}", _timeleft.ToString());
                     SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.playerId, _phrase22), (ClientInfo)null);
                 }
                 else
                 {
                     ReservedSlots.CheckReservedSlot(_cInfo);
                 }
             }
             else
             {
                 ReservedSlots.CheckReservedSlot(_cInfo);
             }
         }
         if (CredentialCheck.IsEnabled)
         {
             CredentialCheck.AccCheck(_cInfo);
         }
         if (Motd.IsEnabled && !Motd.Show_On_Respawn)
         {
             Motd.Send(_cInfo);
         }
         if (AutoShutdown.IsEnabled)
         {
             if (AutoShutdown.Alert_On_Login)
             {
                 AutoShutdown.CheckNextShutdown(_cInfo, false);
             }
         }
         if (Bloodmoon.Show_On_Login && !Bloodmoon.Show_On_Respawn)
         {
             Bloodmoon.GetBloodmoon(_cInfo, false);
         }
         if (LoginNotice.IsEnabled)
         {
             LoginNotice.PlayerCheck(_cInfo);
         }
         Players.SessionTime(_cInfo);
     }
 }
Ejemplo n.º 4
0
 public void PlayerSpawnedInWorld(ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _pos)
 {
     if (_cInfo != null)
     {
         string _name = SQL.EscapeString(_cInfo.playerName);
         if (Motd.IsEnabled & Motd.Show_On_Respawn)
         {
             Motd.Send(_cInfo);
         }
         if (Bloodmoon.Show_On_Login && Bloodmoon.Show_On_Respawn)
         {
             Bloodmoon.GetBloodmoon(_cInfo, false);
         }
         if (_respawnReason == RespawnType.EnterMultiplayer)
         {
             if (NewPlayer.IsEnabled)
             {
                 NewPlayer.Exec(_cInfo);
             }
             if (NewSpawnTele.IsEnabled)
             {
                 NewSpawnTele.TeleNewSpawn(_cInfo);
             }
             if (StartingItems.IsEnabled)
             {
                 if (!NewSpawnTele.IsEnabled)
                 {
                     StartingItems.StartingItemCheck(_cInfo);
                 }
                 else if (NewSpawnTele.IsEnabled && NewSpawnTele.New_Spawn_Tele_Position != "0,0,0")
                 {
                     StartingItems.Que.Add(_cInfo.playerId);
                 }
                 else if (NewSpawnTele.IsEnabled && NewSpawnTele.New_Spawn_Tele_Position == "0,0,0")
                 {
                     StartingItems.StartingItemCheck(_cInfo);
                 }
             }
             string    _sql     = "SELECT pollOpen FROM Polls WHERE pollOpen = 'true'";
             DataTable _result1 = SQL.TQuery(_sql);
             if (_result1.Rows.Count > 0 && !PollConsole.PolledYes.Contains(_cInfo.playerId) && !PollConsole.PolledNo.Contains(_cInfo.playerId))
             {
                 PollConsole.Message(_cInfo);
             }
             _result1.Dispose();
             if (Hardcore.IsEnabled)
             {
                 Hardcore.Announce(_cInfo);
             }
             _sql = string.Format("UPDATE Players SET playername = '{0}', wallet = 0, playerSpentCoins = 0, sessionTime = 0, zkills = 0, kills = 0, deaths = 0 WHERE steamid = '{1}'", _name, _cInfo.playerId);
             SQL.FastQuery(_sql);
         }
         if (_respawnReason == RespawnType.JoinMultiplayer)
         {
             EntityPlayer _player     = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             int          _zCount     = XUiM_Player.GetZombieKills(_player);
             int          _deathCount = XUiM_Player.GetDeaths(_player);
             int          _killCount  = XUiM_Player.GetPlayerKills(_player);
             string       _sql        = "SELECT pollOpen FROM Polls WHERE pollOpen = 'true'";
             DataTable    _result     = SQL.TQuery(_sql);
             if (_result.Rows.Count > 0 && !PollConsole.PolledYes.Contains(_cInfo.playerId) && !PollConsole.PolledNo.Contains(_cInfo.playerId))
             {
                 PollConsole.Message(_cInfo);
             }
             _result.Dispose();
             if (Event.Open)
             {
                 if (!Event.PlayersTeam.ContainsKey(_cInfo.playerId))
                 {
                     if (Hardcore.IsEnabled)
                     {
                         Hardcore.Check(_cInfo);
                     }
                 }
                 else
                 {
                     _sql = string.Format("SELECT eventRespawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                     DataTable _result1 = SQL.TQuery(_sql);
                     bool      _eventRespawn;
                     bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventRespawn);
                     _result1.Dispose();
                     if (_eventRespawn)
                     {
                         Event.Died(_cInfo);
                     }
                     else
                     {
                         _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                         DataTable _result2 = SQL.TQuery(_sql);
                         bool      _return1 = false, _return2 = false;
                         bool.TryParse(_result2.Rows[0].ItemArray.GetValue(0).ToString(), out _return1);
                         bool.TryParse(_result2.Rows[0].ItemArray.GetValue(1).ToString(), out _return2);
                         _result2.Dispose();
                         if (_return1)
                         {
                             if (_return2)
                             {
                                 _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                 SQL.FastQuery(_sql);
                             }
                             _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                             SQL.FastQuery(_sql);
                             Event.EventReturn(_cInfo);
                         }
                         else if (_return2)
                         {
                             Event.EventSpawn(_cInfo);
                         }
                     }
                 }
             }
             else
             {
                 if (Hardcore.IsEnabled)
                 {
                     Hardcore.Check(_cInfo);
                 }
             }
             _sql = string.Format("UPDATE Players SET playername = '{0}', zkills = {1}, kills = {2}, deaths = {3} WHERE steamid = '{4}'", _name, _zCount, _killCount, _deathCount, _cInfo.playerId);
             SQL.FastQuery(_sql);
             if (Mogul.IsEnabled)
             {
                 if (Wallet.IsEnabled)
                 {
                     int currentCoins = Wallet.GetcurrentCoins(_cInfo);
                     _sql = string.Format("UPDATE Players SET wallet = {0} WHERE steamid = '{1}'", currentCoins, _cInfo.playerId);
                     SQL.FastQuery(_sql);
                 }
             }
         }
         if (_respawnReason == RespawnType.Died)
         {
             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             if (Event.Open)
             {
                 if (!Event.PlayersTeam.ContainsKey(_cInfo.playerId))
                 {
                     if (Wallet.Lose_On_Death)
                     {
                         Wallet.ClearWallet(_cInfo);
                     }
                     if (Hardcore.IsEnabled)
                     {
                         Hardcore.Check(_cInfo);
                     }
                     string    _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                     DataTable _result1 = SQL.TQuery(_sql);
                     bool      _return1 = false, _return2 = false;
                     bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _return1);
                     bool.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _return2);
                     _result1.Dispose();
                     if (_return1)
                     {
                         if (_return2)
                         {
                             _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                             SQL.FastQuery(_sql);
                         }
                         _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                         SQL.FastQuery(_sql);
                         Event.EventReturn(_cInfo);
                     }
                 }
                 else
                 {
                     string    _sql    = string.Format("SELECT eventRespawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                     DataTable _result = SQL.TQuery(_sql);
                     bool      _eventRespawn;
                     bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _eventRespawn);
                     _result.Dispose();
                     if (_eventRespawn)
                     {
                         Event.Died(_cInfo);
                     }
                     else
                     {
                         _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                         DataTable _result1 = SQL.TQuery(_sql);
                         bool      _return1 = false, _return2 = false;
                         bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _return1);
                         bool.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _return2);
                         _result1.Dispose();
                         if (_return1)
                         {
                             if (_return2)
                             {
                                 _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                 SQL.FastQuery(_sql);
                             }
                             _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                             SQL.FastQuery(_sql);
                             Event.EventReturn(_cInfo);
                         }
                         else if (_return2)
                         {
                             Event.EventSpawn(_cInfo);
                         }
                     }
                 }
             }
             else
             {
                 if (Wallet.Lose_On_Death)
                 {
                     Wallet.ClearWallet(_cInfo);
                 }
                 if (Hardcore.IsEnabled)
                 {
                     Hardcore.Check(_cInfo);
                 }
                 string    _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                 DataTable _result1 = SQL.TQuery(_sql);
                 bool      _return1 = false, _return2 = false;
                 bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _return1);
                 bool.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _return2);
                 _result1.Dispose();
                 if (_return1)
                 {
                     if (_return2)
                     {
                         _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                         SQL.FastQuery(_sql);
                     }
                     _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                     SQL.FastQuery(_sql);
                     Event.EventReturn(_cInfo);
                 }
             }
             string _sql2 = string.Format("UPDATE Players SET deaths = {0} WHERE steamid = '{1}'", XUiM_Player.GetDeaths(_player), _cInfo.playerId);
             SQL.FastQuery(_sql2);
             if (Zones.IsEnabled && Players.Victim.ContainsKey(_cInfo.entityId))
             {
                 ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + ", type /return to teleport back to your death position. There is a time limit.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 _sql2 = string.Format("UPDATE Players SET respawnTime = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
                 SQL.FastQuery(_sql2);
                 if (Players.Forgive.ContainsKey(_cInfo.entityId))
                 {
                     ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + ", type /forgive to release your killer from jail.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
             if (Mogul.IsEnabled)
             {
                 if (Wallet.IsEnabled)
                 {
                     int currentCoins = Wallet.GetcurrentCoins(_cInfo);
                     _sql2 = string.Format("UPDATE Players SET wallet = {0} WHERE steamid = '{1}'", currentCoins, _cInfo.playerId);
                     SQL.FastQuery(_sql2);
                 }
             }
         }
         if (_respawnReason == RespawnType.Teleport)
         {
             if (StartingItems.IsEnabled && StartingItems.Que.Contains(_cInfo.playerId))
             {
                 StartingItems.StartingItemCheck(_cInfo);
                 StartingItems.Que.Remove(_cInfo.playerId);
             }
             if (Players.NoFlight.Contains(_cInfo.entityId))
             {
                 Players.NoFlight.Remove(_cInfo.entityId);
             }
             if (HatchElevator.IsEnabled)
             {
                 HatchElevator.LastPositionY.Remove(_cInfo.entityId);
             }
         }
         if (Players.Dead.Contains(_cInfo.entityId))
         {
             Players.Dead.Remove(_cInfo.entityId);
         }
     }
 }
        public static void Exec()
        {
            foreach (string _id in PersistentContainer.Instance.Players.SteamIDs)
            {
                string    _sql    = string.Format("SELECT steamid FROM Players WHERE steamid = '{0}'", _id);
                DataTable _result = SQL.TQuery(_sql);
                if (_result.Rows.Count == 0)
                {
                    Player   p = PersistentContainer.Instance.Players[_id, false];
                    DateTime _last_gimme;
                    DateTime _lastkillme;
                    int      _bank                = p.Bank;
                    int      _wallet              = p.Wallet;
                    int      _playerSpentCoins    = p.PlayerSpentCoins;
                    int      _hardcoreSessionTime = p.HardcoreSessionTime;
                    int      _hardcoreKills       = p.HardcoreKills;
                    int      _hardcoreZKills      = p.HardcoreZKills;
                    int      _hardcoreScore       = p.HardcoreScore;
                    int      _hardcoreDeaths      = p.HardcoreDeaths;
                    string   _hardcoreName        = "Unknown";
                    int      _bounty              = p.Bounty;
                    int      _bountyHunter        = p.BountyHunter;
                    int      _sessionTime         = p.SessionTime;
                    int      _bikeId              = p.BikeId;
                    DateTime _lastBike;
                    int      _jailTime = p.JailTime;
                    string   _jailName = "Unknown";
                    DateTime _jailDate;
                    int      _muteTime = p.MuteTime;
                    string   _muteName = "Unknown";
                    DateTime _muteDate;
                    int      _zkills        = p.ZKills;
                    int      _kills         = p.Kills;
                    int      _deaths        = p.Deaths;
                    string   _eventReturn   = "Unknown";
                    string   _marketReturn  = "Unknown";
                    string   _lobbyReturn   = "Unknown";
                    string   _newTeleSpawn  = "Unknown";
                    string   _homeposition  = "Unknown";
                    string   _homeposition2 = "Unknown";
                    DateTime _lastsethome;
                    string   _lastwhisper = "Unknown";
                    DateTime _lastWaypoint;
                    DateTime _lastMarket;
                    DateTime _lastStuck;
                    DateTime _lastLobby;
                    DateTime _lastLog;
                    DateTime _lastDied;
                    DateTime _lastFriendTele;
                    DateTime _respawnTime;
                    DateTime _lastTravel;
                    DateTime _lastAnimals;
                    DateTime _lastVoteReward;
                    string   _firstClaim    = "false";
                    string   _ismuted       = "false";
                    string   _isjailed      = "false";
                    string   _startingItems = "false";
                    string   _clanname      = "Unknown";
                    string   _invitedtoclan = "Unknown";
                    string   _isclanowner   = "false";
                    string   _isclanofficer = "false";
                    DateTime _customCommand1;
                    DateTime _customCommand2;
                    DateTime _customCommand3;
                    DateTime _customCommand4;
                    DateTime _customCommand5;
                    DateTime _customCommand6;
                    DateTime _customCommand7;
                    DateTime _customCommand8;
                    DateTime _customCommand9;
                    DateTime _customCommand10;
                    if (p.LastGimme != null)
                    {
                        _last_gimme = p.LastGimme;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _last_gimme);
                    }
                    if (p.LastKillme != null)
                    {
                        _lastkillme = p.LastKillme;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastkillme);
                    }
                    if (p.HardcoreName != null)
                    {
                        _hardcoreName = p.HardcoreName;
                    }
                    if (p.LastBike != null)
                    {
                        _lastBike = p.LastBike;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastBike);
                    }
                    if (p.JailName != null)
                    {
                        _jailName = p.JailName;
                    }
                    if (p.JailDate != null)
                    {
                        _jailDate = p.JailDate;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _jailDate);
                    }
                    if (p.MuteName != null)
                    {
                        _muteName = p.MuteName;
                    }
                    if (p.MuteDate != null)
                    {
                        _muteDate = p.MuteDate;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _muteDate);
                    }
                    if (p.EventReturn != null)
                    {
                        _eventReturn = p.EventReturn;
                    }
                    if (p.MarketReturn != null)
                    {
                        _marketReturn = p.MarketReturn;
                    }
                    if (p.LobbyReturn != null)
                    {
                        _lobbyReturn = p.LobbyReturn;
                    }
                    if (p.NewTeleSpawn != null)
                    {
                        _newTeleSpawn = p.NewTeleSpawn;
                    }
                    if (p.HomePosition != null)
                    {
                        _homeposition = p.HomePosition;
                    }
                    if (p.HomePosition2 != null)
                    {
                        _homeposition2 = p.HomePosition2;
                    }
                    if (p.LastSetHome != null)
                    {
                        _lastsethome = p.LastSetHome;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastsethome);
                    }
                    if (p.LastWhisper != null)
                    {
                        _lastwhisper = p.LastWhisper;
                    }
                    if (p.LastWaypoint != null)
                    {
                        _lastWaypoint = p.LastWaypoint;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastWaypoint);
                    }
                    if (p.LastMarket != null)
                    {
                        _lastMarket = p.LastMarket;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastMarket);
                    }
                    if (p.LastStuck != null)
                    {
                        _lastStuck = p.LastStuck;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastStuck);
                    }
                    if (p.LastLobby != null)
                    {
                        _lastLobby = p.LastLobby;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastLobby);
                    }
                    if (p.Log != null)
                    {
                        _lastLog = p.Log;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastLog);
                    }
                    if (p.LastDied != null)
                    {
                        _lastDied = p.LastDied;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastDied);
                    }
                    if (p.LastFriendTele != null)
                    {
                        _lastFriendTele = p.LastFriendTele;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastFriendTele);
                    }
                    if (p.RespawnTime != null)
                    {
                        _respawnTime = p.RespawnTime;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _respawnTime);
                    }
                    if (p.LastTravel != null)
                    {
                        _lastTravel = p.LastTravel;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastTravel);
                    }
                    if (p.LastAnimals != null)
                    {
                        _lastAnimals = p.LastAnimals;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastAnimals);
                    }
                    if (p.LastVoteReward != null)
                    {
                        _lastVoteReward = p.LastVoteReward;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastVoteReward);
                    }
                    if (p.FirstClaim)
                    {
                        _firstClaim = "true";
                    }
                    if (p.IsMuted)
                    {
                        _ismuted = "true";
                    }
                    if (p.IsJailed)
                    {
                        _isjailed = "true";
                    }
                    if (p.StartingItems)
                    {
                        _startingItems = "true";
                    }
                    if (p.ClanName != null)
                    {
                        _clanname = p.ClanName;
                    }
                    if (p.InvitedToClan != null)
                    {
                        _invitedtoclan = p.InvitedToClan;
                    }
                    if (p.IsClanOwner)
                    {
                        _isclanowner = "true";
                    }
                    if (p.IsClanOfficer)
                    {
                        _isclanofficer = "true";
                    }
                    if (p.CustomCommand1 != null)
                    {
                        _customCommand1 = p.CustomCommand1;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand1);
                    }
                    if (p.CustomCommand2 != null)
                    {
                        _customCommand2 = p.CustomCommand2;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand2);
                    }
                    if (p.CustomCommand3 != null)
                    {
                        _customCommand3 = p.CustomCommand3;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand3);
                    }
                    if (p.CustomCommand4 != null)
                    {
                        _customCommand4 = p.CustomCommand4;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand4);
                    }
                    if (p.CustomCommand5 != null)
                    {
                        _customCommand5 = p.CustomCommand5;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand5);
                    }
                    if (p.CustomCommand6 != null)
                    {
                        _customCommand6 = p.CustomCommand6;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand6);
                    }
                    if (p.CustomCommand7 != null)
                    {
                        _customCommand7 = p.CustomCommand7;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand7);
                    }
                    if (p.CustomCommand8 != null)
                    {
                        _customCommand8 = p.CustomCommand8;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand8);
                    }
                    if (p.CustomCommand9 != null)
                    {
                        _customCommand9 = p.CustomCommand9;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand9);
                    }
                    if (p.CustomCommand10 != null)
                    {
                        _customCommand10 = p.CustomCommand10;
                    }
                    else
                    {
                        DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand10);
                    }
                    _hardcoreName = SQL.EscapeString(_hardcoreName);
                    _jailName     = SQL.EscapeString(_jailName);
                    _muteName     = SQL.EscapeString(_muteName);
                    _clanname     = SQL.EscapeString(_clanname);
                    _sql          = string.Format("INSERT INTO Players (steamid, last_gimme, lastkillme, bank, wallet, playerSpentCoins, hardcoreSessionTime, hardcoreKills, hardcoreZKills, hardcoreScore, hardcoreDeaths, hardcoreName, bounty, bountyHunter, sessionTime, bikeId, lastBike, jailTime, jailName, jailDate, muteTime, muteName, muteDate, zkills, kills, deaths, eventReturn, marketReturn, lobbyReturn, newTeleSpawn, homeposition, homeposition2, lastsethome, lastwhisper, lastWaypoint, lastMarket, lastStuck, lastLobby, lastLog, lastDied, lastFriendTele, respawnTime, lastTravel, lastAnimals, lastVoteReward, firstClaim, ismuted, isjailed, startingItems, clanname, invitedtoclan, isclanowner, isclanofficer, customCommand1, customCommand2, customCommand3, customCommand4, customCommand5, customCommand6, customCommand7, customCommand8, customCommand9, customCommand10) VALUES ('{0}', '{1}', '{2}', {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, '{11}', {12}, {13}, {14}, {15}, '{16}', {17}, '{18}', '{19}', {20}, '{21}', '{22}', {23}, {24}, {25}, '{26}', '{27}', '{28}', '{29}', '{30}', '{31}', '{32}', '{33}', '{34}', '{35}', '{36}', '{37}', '{38}', '{39}', '{40}', '{41}', '{42}', '{43}', '{44}', '{45}', '{46}', '{47}', '{48}', '{49}', '{50}', '{51}', '{52}', '{53}', '{54}', '{55}', '{56}', '{57}', '{58}', '{59}', '{60}', '{61}', '{62}')", _id, _last_gimme, _lastkillme, _bank, _wallet, _playerSpentCoins, _hardcoreSessionTime, _hardcoreKills, _hardcoreZKills, _hardcoreScore, _hardcoreDeaths, _hardcoreName, _bounty, _bountyHunter, _sessionTime, _bikeId, _lastBike, _jailTime, _jailName, _jailDate, _muteTime, _muteName, _muteDate, _zkills, _kills, _deaths, _eventReturn, _marketReturn, _lobbyReturn, _newTeleSpawn, _homeposition, _homeposition2, _lastsethome, _lastwhisper, _lastWaypoint, _lastMarket, _lastStuck, _lastLobby, _lastLog, _lastDied, _lastFriendTele, _respawnTime, _lastTravel, _lastAnimals, _lastVoteReward, _firstClaim, _ismuted, _isjailed, _startingItems, _clanname, _invitedtoclan, _isclanowner, _isclanofficer, _customCommand1, _customCommand2, _customCommand3, _customCommand4, _customCommand5, _customCommand6, _customCommand7, _customCommand8, _customCommand9, _customCommand10);
                    SQL.FastQuery(_sql);
                    if (p.AuctionItem != null)
                    {
                        string   _itemName = p.AuctionItem[1];
                        int      _itemCount;
                        int      _itemQuality;
                        int      _itemPrice;
                        DateTime _cancelTime = p.CancelTime;
                        int.TryParse(p.AuctionItem[0], out _itemCount);
                        int.TryParse(p.AuctionItem[2], out _itemQuality);
                        int.TryParse(p.AuctionItem[3], out _itemPrice);
                        _sql = string.Format("INSERT INTO Auction (steamid, itemName, itemCount, itemQuality, itemPrice, cancelTime) VALUES ('{0}', '{1}', {2}, {3}, {4}, '{5}')", _id, _itemName, _itemCount, _itemQuality, _itemPrice, _cancelTime);
                        SQL.FastQuery(_sql);
                    }
                }
                _result.Dispose();
            }
            string _binpath = string.Format("{0}/ServerTools.bin", GameUtils.GetSaveGameDir());

            File.Delete(_binpath);
            LoadProcess.Load(4);
        }
Ejemplo n.º 6
0
        private static void ItemOrBlock(ClientInfo _cInfo)
        {
            EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];

            if (_player.IsSpawned())
            {
                string _item = list.RandomObject();
                int[]  _values;
                if (dict.TryGetValue(_item, out _values))
                {
                    int count = 0;
                    if (_values[0] != _values[1])
                    {
                        count = rnd.Next(_values[0], _values[1] + 1);
                    }
                    else
                    {
                        count = _values[0];
                    }
                    if (count > 0)
                    {
                        int quality = rnd.Next(_values[2], _values[3] + 1);
                        if (quality < 1 || quality > 6)
                        {
                            quality = rnd.Next(1, 7);
                        }
                        ItemValue _itemValue = ItemClass.GetItem(_item, true);
                        if (Equals(_itemValue, ItemValue.None))
                        {
                            list.Remove(_item);
                            ItemOrBlock(_cInfo);
                            Log.Warning(string.Format("[SERVERTOOLS] Item or block not found: {0}. Item or block was not given as a reward.", _item));
                            return;
                        }
                        else
                        {
                            _itemValue = new ItemValue(ItemClass.GetItem(_item).type, quality, quality, true);
                        }
                        World world = GameManager.Instance.World;
                        if (world.Players.dict[_cInfo.entityId].IsSpawned())
                        {
                            var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                            {
                                entityClass     = EntityClass.FromString("item"),
                                id              = EntityFactory.nextEntityID++,
                                itemStack       = new ItemStack(_itemValue, count),
                                pos             = world.Players.dict[_cInfo.entityId].position,
                                rot             = new Vector3(20f, 0f, 20f),
                                lifetime        = 60f,
                                belongsPlayerId = _cInfo.entityId
                            });
                            world.SpawnEntityInWorld(entityItem);
                            _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId));
                            world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
                            _counter++;
                        }
                        if (_counter != Reward_Count)
                        {
                            ItemOrBlock(_cInfo);
                        }
                        else
                        {
                            list.Clear();
                            list     = new List <string>(dict.Keys);
                            _counter = 0;
                            string _sql = string.Format("UPDATE Players SET lastVoteReward = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
                            SQL.FastQuery(_sql);
                            string _phrase703;
                            if (!Phrases.Dict.TryGetValue(703, out _phrase703))
                            {
                                _phrase703 = "reward items were sent to your inventory. If it is full, check the ground.";
                            }
                            _phrase703 = _phrase703.Replace("{PlayerName}", _cInfo.playerName);
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase703 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                            Que();
                        }
                    }
                    else
                    {
                        list.Remove(_item);
                        ItemOrBlock(_cInfo);
                    }
                }
            }
            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();
            }
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
 private static void PlayerSpawnedInWorld(ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _pos)//Spawning player
 {
     try
     {
         if (_cInfo != null)
         {
             if (_respawnReason == RespawnType.EnterMultiplayer)//New player spawned
             {
                 PersistentContainer.Instance.Players[_cInfo.playerId].PlayerName = _cInfo.playerName;
                 PersistentContainer.Instance.Save();
                 PersistentOperations.SessionTime(_cInfo);
                 Timers.NewPlayerExecTimer(_cInfo);
             }
             else if (_respawnReason == RespawnType.JoinMultiplayer)//Old player spawned
             {
                 PersistentContainer.Instance.Players[_cInfo.playerId].PlayerName = _cInfo.playerName;
                 PersistentContainer.Instance.Save();
                 PersistentOperations.SessionTime(_cInfo);
                 if (!PersistentContainer.Instance.Players[_cInfo.playerId].OldPlayer)
                 {
                     Timers.NewPlayerExecTimer(_cInfo);
                 }
                 else
                 {
                     if (Hardcore.IsEnabled && !Hardcore.Optional)
                     {
                         string    _sql    = string.Format("SELECT * FROM Hardcore WHERE steamid = '{0}'", _cInfo.playerId);
                         DataTable _result = SQL.TypeQuery(_sql);
                         if (_result.Rows.Count == 0)
                         {
                             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                             if (_player != null)
                             {
                                 int    _deaths     = XUiM_Player.GetDeaths(_player);
                                 string _playerName = SQL.EscapeString(_cInfo.playerName);
                                 SQL.FastQuery(string.Format("INSERT INTO Hardcore (steamid, playerName, deaths) VALUES ('{0}', '{1}', {2})", _cInfo.playerId, _playerName, _deaths), null);
                             }
                         }
                         _result.Dispose();
                     }
                     if (LoginNotice.IsEnabled && LoginNotice.dict.ContainsKey(_cInfo.playerId))
                     {
                         LoginNotice.PlayerNotice(_cInfo);
                     }
                     if (Motd.IsEnabled)
                     {
                         Motd.Send(_cInfo);
                     }
                     if (Bloodmoon.IsEnabled)
                     {
                         Bloodmoon.Exec(_cInfo);
                     }
                     if (AutoShutdown.IsEnabled && AutoShutdown.Alert_On_Login)
                     {
                         AutoShutdown.NextShutdown(_cInfo);
                     }
                     if (Hardcore.IsEnabled)
                     {
                         if (!Hardcore.Optional)
                         {
                             Hardcore.Alert(_cInfo);
                         }
                         else if (PersistentContainer.Instance.Players[_cInfo.playerId].Hardcore)
                         {
                             Hardcore.Alert(_cInfo);
                         }
                     }
                     if (BattleLogger.IsEnabled)
                     {
                         BattleLogger.AlertPlayer(_cInfo);
                     }
                     if (PollConsole.IsEnabled)
                     {
                         string _sql = "SELECT pollOpen FROM Polls WHERE pollOpen = 'true'";
                         if (!string.IsNullOrEmpty(_sql))
                         {
                             DataTable _result = SQL.TypeQuery(_sql);
                             if (_result.Rows.Count > 0 && !PollConsole.PolledYes.Contains(_cInfo.playerId) && !PollConsole.PolledNo.Contains(_cInfo.playerId))
                             {
                                 PollConsole.Message(_cInfo);
                             }
                             _result.Dispose();
                         }
                     }
                     if (Event.Open)
                     {
                         if (Event.PlayersTeam.ContainsKey(_cInfo.playerId))
                         {
                             string _sql = string.Format("SELECT eventRespawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                             if (!string.IsNullOrEmpty(_sql))
                             {
                                 DataTable _result1      = SQL.TypeQuery(_sql);
                                 bool      _eventRespawn = false;
                                 if (_result1.Rows.Count > 0)
                                 {
                                     bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventRespawn);
                                 }
                                 _result1.Dispose();
                                 if (_eventRespawn)
                                 {
                                     Event.Died(_cInfo);
                                 }
                                 else
                                 {
                                     _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                                     DataTable _result2 = SQL.TypeQuery(_sql);
                                     bool      _return1 = false, _return2 = false;
                                     if (_result2.Rows.Count > 0)
                                     {
                                         bool.TryParse(_result2.Rows[0].ItemArray.GetValue(0).ToString(), out _return1);
                                         bool.TryParse(_result2.Rows[0].ItemArray.GetValue(1).ToString(), out _return2);
                                     }
                                     _result2.Dispose();
                                     if (_return1)
                                     {
                                         if (_return2)
                                         {
                                             _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                             SQL.FastQuery(_sql, "API");
                                         }
                                         _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                         SQL.FastQuery(_sql, "API");
                                         Event.EventSpawn(_cInfo);
                                     }
                                     else if (_return2)
                                     {
                                         Event.EventSpawn(_cInfo);
                                     }
                                 }
                             }
                         }
                     }
                     if (ClanManager.IsEnabled)
                     {
                         List <string[]> _clanRequests = PersistentContainer.Instance.Players[_cInfo.playerId].ClanRequestToJoin;
                         if (_clanRequests != null && _clanRequests.Count > 0)
                         {
                             string[] _request    = _clanRequests[0];
                             string   _playerName = _request[1];
                             ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "There is a request to join the group from " + _playerName + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                         }
                     }
                 }
             }
             else if (_respawnReason == RespawnType.Died)//Player Died
             {
                 PersistentOperations.SessionTime(_cInfo);
                 if (Bloodmoon.IsEnabled && Bloodmoon.Show_On_Respawn)
                 {
                     Bloodmoon.Exec(_cInfo);
                 }
                 if (BattleLogger.IsEnabled)
                 {
                     BattleLogger.AlertPlayer(_cInfo);
                 }
                 if (Event.Open)
                 {
                     if (!Event.PlayersTeam.ContainsKey(_cInfo.playerId))
                     {
                         string _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                         if (!string.IsNullOrEmpty(_sql))
                         {
                             DataTable _result1 = SQL.TypeQuery(_sql);
                             bool      _return1 = false, _return2 = false;
                             if (_result1.Rows.Count > 0)
                             {
                                 bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _return1);
                                 bool.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _return2);
                             }
                             _result1.Dispose();
                             if (_return1)
                             {
                                 if (_return2)
                                 {
                                     _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                     SQL.FastQuery(_sql, "API");
                                 }
                                 _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                 SQL.FastQuery(_sql, "API");
                                 Event.EventSpawn(_cInfo);
                                 return;
                             }
                         }
                     }
                     else
                     {
                         string _sql = string.Format("SELECT eventRespawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                         if (!string.IsNullOrEmpty(_sql))
                         {
                             DataTable _result       = SQL.TypeQuery(_sql);
                             bool      _eventRespawn = false;
                             if (_result.Rows.Count > 0)
                             {
                                 bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _eventRespawn);
                             }
                             _result.Dispose();
                             if (_eventRespawn)
                             {
                                 Event.Died(_cInfo);
                                 return;
                             }
                             else
                             {
                                 _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                                 DataTable _result1 = SQL.TypeQuery(_sql);
                                 bool      _return1 = false, _return2 = false;
                                 if (_result1.Rows.Count > 0)
                                 {
                                     bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _return1);
                                     bool.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _return2);
                                 }
                                 _result1.Dispose();
                                 if (_return1)
                                 {
                                     if (_return2)
                                     {
                                         _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                         SQL.FastQuery(_sql, "API");
                                     }
                                     _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                     SQL.FastQuery(_sql, "API");
                                     Event.EventSpawn(_cInfo);
                                     return;
                                 }
                                 else if (_return2)
                                 {
                                     Event.EventSpawn(_cInfo);
                                     return;
                                 }
                             }
                         }
                     }
                 }
                 else
                 {
                     string _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                     if (!string.IsNullOrEmpty(_sql))
                     {
                         DataTable _result1 = SQL.TypeQuery(_sql);
                         bool      _return1 = false, _return2 = false;
                         if (_result1.Rows.Count > 0)
                         {
                             bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _return1);
                             bool.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _return2);
                         }
                         _result1.Dispose();
                         if (_return1)
                         {
                             if (_return2)
                             {
                                 _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                 SQL.FastQuery(_sql, "API");
                             }
                             _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                             SQL.FastQuery(_sql, "API");
                             Event.EventSpawn(_cInfo);
                             return;
                         }
                     }
                 }
                 if (Wallet.IsEnabled)
                 {
                     if (Wallet.Lose_On_Death)
                     {
                         Wallet.ClearWallet(_cInfo);
                     }
                     else if (Wallet.Deaths > 0)
                     {
                         Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Wallet.Deaths);
                     }
                 }
                 if (Hardcore.IsEnabled)
                 {
                     if (!Hardcore.Optional)
                     {
                         Hardcore.Check(_cInfo);
                     }
                     else if (PersistentContainer.Instance.Players[_cInfo.playerId].Hardcore)
                     {
                         Hardcore.Check(_cInfo);
                     }
                 }
                 if (Zones.IsEnabled && Zones.Victim.ContainsKey(_cInfo.entityId))
                 {
                     string _response = " type {CommandPrivate}{Command50} to teleport back to your death position. There is a time limit.";
                     _response = _response.Replace("{CommandPrivate}", ChatHook.Command_Private);
                     _response = _response.Replace("{Command50}", Zones.Command50);
                     ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _response + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     PersistentContainer.Instance.Players[_cInfo.playerId].ZoneDeathTime = DateTime.Now;
                     PersistentContainer.Instance.Save();
                     if (Zones.Forgive.ContainsKey(_cInfo.entityId))
                     {
                         string _response2 = " type {CommandPrivate}{Command55} to release your killer from jail.";
                         _response2 = _response2.Replace("{CommandPrivate}", ChatHook.Command_Private);
                         _response2 = _response2.Replace("{Command55}", Jail.Command55);
                         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _response2 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
             }
             else if (_respawnReason == RespawnType.Teleport)
             {
             }
             string _ip = _cInfo.ip;
             if (_ip.Contains(":"))
             {
                 _ip = _ip.Split(':').First();
             }
             if (!string.IsNullOrEmpty(_ip) && BattleLogger.IsEnabled && BattleLogger.LogFound && !StopServer.StopServerCountingDown && !StopServer.Shutdown && GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo.playerId).PermissionLevel > BattleLogger.Admin_Level)
             {
                 if (!BattleLogger.Players.ContainsKey(_cInfo.playerId))
                 {
                     BattleLogger.Players.Add(_cInfo.playerId, _cInfo.ip);
                 }
                 else
                 {
                     string _recordedIp;
                     BattleLogger.Players.TryGetValue(_cInfo.playerId, out _recordedIp);
                     if (_recordedIp != _ip)
                     {
                         BattleLogger.Players[_cInfo.playerId] = _ip;
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerSpawnedInWorld: {0}.", e.Message));
     }
 }
Ejemplo n.º 9
0
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params.Count < 1 || _params.Count > 3)
         {
             SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1 to 3, found {0}.", _params.Count));
             return;
         }
         if (_params[0].ToLower().Equals("off"))
         {
             Jail.IsEnabled = false;
             SdtdConsole.Instance.Output(string.Format("Jail has been set to off"));
             return;
         }
         else if (_params[0].ToLower().Equals("on"))
         {
             Jail.IsEnabled = true;
             SdtdConsole.Instance.Output(string.Format("Jail has been set to on"));
             return;
         }
         else if (_params[0].ToLower().Equals("add"))
         {
             if (_params.Count != 3)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 3, found {0}.", _params.Count));
                 return;
             }
             if (_params[1].Length < 1 || _params[1].Length > 17)
             {
                 SdtdConsole.Instance.Output(string.Format("Can not add Id: Invalid Id {0}.", _params[1]));
                 return;
             }
             if (Jail.Jailed.Contains(_params[1]))
             {
                 SdtdConsole.Instance.Output(string.Format("Can not add Id. {0} is already in the Jail list.", _params[1]));
                 return;
             }
             int _jailTime;
             if (!int.TryParse(_params[2], out _jailTime))
             {
                 SdtdConsole.Instance.Output(string.Format("Jail time is not valid: {0}", _params[2]));
                 return;
             }
             if (Jail.Jail_Position == "0,0,0" || Jail.Jail_Position == "0 0 0" || Jail.Jail_Position == "")
             {
                 SdtdConsole.Instance.Output(string.Format("Can not put a player in jail: Jail position has not been set."));
                 return;
             }
             else
             {
                 ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]);
                 if (_cInfo != null)
                 {
                     if (Jail.Jailed.Contains(_cInfo.playerId))
                     {
                         SdtdConsole.Instance.Output(string.Format("Player with Id {0} is already in jail.", _params[1]));
                         return;
                     }
                     else
                     {
                         EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                         if (_player.IsSpawned())
                         {
                             int      x, y, z;
                             string[] _cords = Jail.Jail_Position.Split(',');
                             int.TryParse(_cords[0], out x);
                             int.TryParse(_cords[1], out y);
                             int.TryParse(_cords[2], out z);
                             _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(x, y, z), null, false));
                         }
                         Jail.Jailed.Add(_cInfo.playerId);
                         if (_jailTime >= 0)
                         {
                             string _phrase500;
                             if (!Phrases.Dict.TryGetValue(500, out _phrase500))
                             {
                                 _phrase500 = "you have been sent to jail.";
                             }
                             _phrase500 = _phrase500.Replace("{Minutes}", _jailTime.ToString());
                             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase500 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                             SdtdConsole.Instance.Output(string.Format("You have put {0} in jail for {1} minutes.", _cInfo.playerName, _jailTime));
                         }
                         if (_jailTime == -1)
                         {
                             string _phrase500;
                             if (!Phrases.Dict.TryGetValue(500, out _phrase500))
                             {
                                 _phrase500 = "you have been sent to jail.";
                             }
                             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase500 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                             SdtdConsole.Instance.Output(string.Format("You have put {0} in jail for life.", _cInfo.playerName));
                         }
                         string _sql = string.Format("UPDATE Players SET jailTime = {0}, jailName = '{1}', jailDate = '{2}' WHERE steamid = '{3}'", _jailTime, _cInfo.playerName, DateTime.Now, _cInfo.playerId);
                         SQL.FastQuery(_sql);
                     }
                 }
                 else
                 {
                     string _id  = SQL.EscapeString(_params[1]);
                     string _sql = string.Format("UPDATE Players SET jailTime = {0}, jailName = 'Unknown', jailDate = '{1}' WHERE steamid = '{2}'", _jailTime, DateTime.Now, _id);
                     SQL.FastQuery(_sql);
                     SdtdConsole.Instance.Output(string.Format("Player with Id {0} can not be found online but has been set for jail.", _id));
                     return;
                 }
             }
         }
         else if (_params[0].ToLower().Equals("remove"))
         {
             if (_params.Count != 2)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}.", _params.Count));
                 return;
             }
             if (_params[1].Length != 17)
             {
                 SdtdConsole.Instance.Output(string.Format("Can not remove player Id: Invalid steam Id {0}.", _params[1]));
                 return;
             }
             else
             {
                 if (!Jail.Jailed.Contains(_params[1]))
                 {
                     SdtdConsole.Instance.Output(string.Format("Player with steam Id {0} is not in jail. ", _params[1]));
                     return;
                 }
                 else
                 {
                     ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_params[1]);
                     if (_cInfo != null)
                     {
                         EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                         EntityBedrollPositionList _position = _player.SpawnPoints;
                         Jail.Jailed.Remove(_cInfo.playerId);
                         if (_position.Count > 0)
                         {
                             _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(_position[0].x, -1, _position[0].z), null, false));
                         }
                         else
                         {
                             Vector3[] _pos = GameManager.Instance.World.GetRandomSpawnPointPositions(1);
                             _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(_pos[0].x, -1, _pos[0].z), null, false));
                         }
                         string _phrase501;
                         if (!Phrases.Dict.TryGetValue(501, out _phrase501))
                         {
                             _phrase501 = "you have been released from jail.";
                         }
                         _phrase501 = _phrase501.Replace("{PlayerName}", _cInfo.playerName);
                         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase501 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                         string _sql = string.Format("UPDATE Players SET jailTime = 0 WHERE steamid = '{0}'", _cInfo.playerId);
                         SQL.FastQuery(_sql);
                         SdtdConsole.Instance.Output(string.Format("You have released a player with steam id {0} from jail. ", _params[1]));
                         return;
                     }
                     else
                     {
                         string _id  = SQL.EscapeString(_params[1]);
                         string _sql = string.Format("UPDATE Players SET jailTime = 0 WHERE steamid = '{0}'", _id);
                         SQL.FastQuery(_sql);
                         Jail.Jailed.Remove(_cInfo.playerId);
                         SdtdConsole.Instance.Output(string.Format("Player with steam Id {0} has been removed from the jail list.", _params[1]));
                         return;
                     }
                 }
             }
         }
         else if (_params[0].ToLower().Equals("list"))
         {
             if (_params.Count != 1)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, found {0}.", _params.Count));
                 return;
             }
             if (Jail.Jailed.Count == 0)
             {
                 SdtdConsole.Instance.Output("There are no Ids on the Jail list.");
                 return;
             }
             else
             {
                 for (int i = 0; i < Jail.Jailed.Count; i++)
                 {
                     string    _id     = Jail.Jailed[i];
                     string    _sql    = string.Format("SELECT jailTime, jailName, jailDate FROM Players WHERE steamid = '{0}'", _id);
                     DataTable _result = SQL.TQuery(_sql);
                     int       _jailTime;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _jailTime);
                     DateTime _jailDate;
                     DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _jailDate);
                     if (_jailTime > 0)
                     {
                         TimeSpan varTime           = DateTime.Now - _jailDate;
                         double   fractionalMinutes = varTime.TotalMinutes;
                         int      _timepassed       = (int)fractionalMinutes;
                         int      _timeleft         = _jailTime - _timepassed;
                         SdtdConsole.Instance.Output(string.Format("Jailed player: steam Id {0} named {1} for {2} more minutes.", _id, _result.Rows[0].ItemArray.GetValue(1).ToString(), _timeleft));
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("Jailed player: steam Id {0} named {1} forever.", _id, _result.Rows[0].ItemArray.GetValue(1).ToString()));
                     }
                     _result.Dispose();
                 }
             }
         }
         else
         {
             SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0]));
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in CommandJailConsole.Run: {0}.", e));
     }
 }
Ejemplo n.º 10
0
        public static void NewBounty(ClientInfo _cInfo, string _message, string _playerName)
        {
            int _id;

            string[] _idAndBounty = { };
            int      _cost;

            if (_message.Contains(" "))
            {
                _idAndBounty = _message.Split(' ').ToArray();
                if (int.TryParse(_idAndBounty[0], out _id))
                {
                    if (int.TryParse(_idAndBounty[1], out _cost))
                    {
                        ClientInfo _cInfo1 = ConnectionManager.Instance.Clients.ForEntityId(_id);
                        if (_cInfo1 != null)
                        {
                            EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo1.entityId];
                            if (_cost < Minimum_Bounty)
                            {
                                _cost = Minimum_Bounty;
                            }
                            int _currentCoins = Wallet.GetcurrentCoins(_cInfo);
                            if (_currentCoins >= _cost)
                            {
                                Wallet.SubtractCoinsFromWallet(_cInfo.playerId, _cost);
                                string    _sql    = string.Format("SELECT bounty FROM Players WHERE steamid = '{0}'", _cInfo1.playerId);
                                DataTable _result = SQL.TQuery(_sql);
                                int       _bounty;
                                int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _bounty);
                                _result.Dispose();
                                _sql = string.Format("UPDATE Players SET bounty = {0} WHERE steamid = '{1}'", _bounty + _cost, _cInfo1.playerId);
                                SQL.FastQuery(_sql);
                                string _message1 = " you have added {Value} bounty to {PlayerName}.[-]";
                                _message1 = _message1.Replace("{Value}", _cost.ToString());
                                _message1 = _message1.Replace("{PlayerName}", _cInfo1.playerName);
                                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message1 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                            }
                            else
                            {
                                string _message1 = " you do not have enough in your wallet for this bounty: {Value}.[-]";
                                _message1 = _message1.Replace("{Value}", _cost.ToString());
                                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message1 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                            }
                        }
                    }
                    else
                    {
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", to add a custom bounty value, type " + ChatHook.Command_Private + Command83 + " Id# Value, or the minimum with " + ChatHook.Command_Private + Command83 + " Id#.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
            }
            else
            {
                if (int.TryParse(_message, out _id))
                {
                    ClientInfo _cInfo1 = ConnectionManager.Instance.Clients.ForEntityId(_id);
                    if (_cInfo1 != null)
                    {
                        EntityPlayer _player       = GameManager.Instance.World.Players.dict[_cInfo1.entityId];
                        int          _currentCoins = Wallet.GetcurrentCoins(_cInfo);
                        if (_currentCoins >= Minimum_Bounty)
                        {
                            Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Minimum_Bounty);
                            string    _sql    = string.Format("SELECT bounty FROM Players WHERE steamid = '{0}'", _cInfo1.playerId);
                            DataTable _result = SQL.TQuery(_sql);
                            int       _bounty;
                            int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _bounty);
                            _result.Dispose();
                            _sql = string.Format("UPDATE Players SET bounty = {0} WHERE steamid = '{1}'", _bounty + Minimum_Bounty, _cInfo1.playerId);
                            SQL.FastQuery(_sql);
                            string _message1 = " you have added {Value} bounty to {PlayerName}.[-]";
                            _message1 = _message1.Replace("{Value}", Minimum_Bounty.ToString());
                            _message1 = _message1.Replace("{PlayerName}", _cInfo1.playerName);
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message1 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                        }
                        else
                        {
                            string _message1 = " you do not have enough in your wallet for this bounty: {Value}.[-]";
                            _message1 = _message1.Replace("{Value}", Minimum_Bounty.ToString());
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message1 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
 public static void PlayerKilled(EntityPlayer _player1, EntityPlayer _player2, ClientInfo _cInfo1, ClientInfo _cInfo2)
 {
     if (!_player1.IsFriendsWith(_player2) && !_player2.IsFriendsWith(_player1) && !_player1.Party.ContainsMember(_player2))
     {
         if (ClanManager.IsEnabled)
         {
             if (ClanManager.ClanMember.Contains(_cInfo1.playerId) && ClanManager.ClanMember.Contains(_cInfo2.playerId))
             {
                 string    _sql1     = string.Format("SELECT clanname FROM Players WHERE steamid = '{0}'", _cInfo1.playerId);
                 DataTable _result1  = SQL.TQuery(_sql1);
                 string    _clanName = _result1.Rows[0].ItemArray.GetValue(0).ToString();
                 _result1.Dispose();
                 _sql1 = string.Format("SELECT clanname FROM Players WHERE steamid = '{0}'", _cInfo2.playerId);
                 DataTable _result2   = SQL.TQuery(_sql1);
                 string    _clanName2 = _result2.Rows[0].ItemArray.GetValue(0).ToString();
                 _result2.Dispose();
                 if (_clanName != "Unknown" && _clanName2 != "Unknown")
                 {
                     if (_clanName == _clanName2)
                     {
                         return;
                     }
                 }
             }
         }
         string    _sql    = string.Format("SELECT bounty, bountyHunter FROM Players WHERE steamid = '{0}'", _cInfo1.playerId);
         DataTable _result = SQL.TQuery(_sql);
         int       _bounty;
         int       _hunterCountVictim;
         int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _bounty);
         int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _hunterCountVictim);
         _result.Dispose();
         if (_bounty > 0)
         {
             _sql = string.Format("SELECT playerSpentCoins, bountyHunter FROM Players WHERE steamid = '{0}'", _cInfo2.playerId);
             DataTable _result2 = SQL.TQuery(_sql);
             int       _playerSpentCoins;
             int       _hunterCountKiller;
             int.TryParse(_result2.Rows[0].ItemArray.GetValue(0).ToString(), out _playerSpentCoins);
             int.TryParse(_result2.Rows[0].ItemArray.GetValue(1).ToString(), out _hunterCountKiller);
             _result2.Dispose();
             if (Bonus > 0 && _hunterCountVictim >= Bonus)
             {
                 _sql = string.Format("UPDATE Players SET playerSpentCoins = {0}, bountyHunter = {1} WHERE steamid = '{2}'", _playerSpentCoins + _bounty + Bonus, _hunterCountKiller + 1, _cInfo2.playerId);
                 SQL.FastQuery(_sql);
             }
             else
             {
                 _sql = string.Format("UPDATE Players SET playerSpentCoins = {0}, bountyHunter = {1} WHERE steamid = '{2}'", _playerSpentCoins + _bounty, _hunterCountKiller + 1, _cInfo2.playerId);
                 SQL.FastQuery(_sql);
             }
             _sql = string.Format("UPDATE Players SET bounty = 0, bountyHunter = 0 WHERE steamid = '{0}'", _cInfo1.playerId);
             SQL.FastQuery(_sql);
             string _phrase912;
             if (!Phrases.Dict.TryGetValue(912, out _phrase912))
             {
                 _phrase912 = "{PlayerName} is a bounty hunter! {Victim} was snuffed out.";
             }
             _phrase912 = _phrase912.Replace("{PlayerName}", _cInfo2.playerName);
             _phrase912 = _phrase912.Replace("{Victim}", _cInfo1.playerName);
             ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _phrase912, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
             using (StreamWriter sw = new StreamWriter(filepath, true))
             {
                 sw.WriteLine(string.Format("{0}: {1} is a bounty hunter! {2} was snuffed out. Bounty was worth {3}", DateTime.Now, _cInfo2.playerName, _cInfo1.playerName, _bounty));
                 sw.WriteLine();
                 sw.Flush();
                 sw.Close();
             }
         }
         if (Kill_Streak > 0)
         {
             if (KillStreak.ContainsKey(_cInfo1.entityId))
             {
                 KillStreak.Remove(_cInfo1.entityId);
                 using (StreamWriter sw = new StreamWriter(filepath, true))
                 {
                     sw.WriteLine(string.Format("{0}: Player {1} kill streak has come to an end by {2}.", DateTime.Now, _cInfo1.playerName, _cInfo2.playerName));
                     sw.WriteLine();
                     sw.Flush();
                     sw.Close();
                 }
             }
             if (KillStreak.ContainsKey(_cInfo2.entityId))
             {
                 int _value;
                 if (KillStreak.TryGetValue(_cInfo2.entityId, out _value))
                 {
                     int _newValue = _value + 1;
                     KillStreak[_cInfo2.entityId] = _newValue;
                     if (_newValue == Bounties.Kill_Streak)
                     {
                         string _phrase913;
                         if (!Phrases.Dict.TryGetValue(913, out _phrase913))
                         {
                             _phrase913 = "{PlayerName} is on a kill streak! Their bounty has increased.";
                         }
                         _phrase913 = _phrase913.Replace("{PlayerName}", _cInfo2.playerName);
                         ChatHook.ChatMessage(_cInfo1, LoadConfig.Chat_Response_Color + _phrase913, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                     }
                     if (_newValue >= Bounties.Kill_Streak)
                     {
                         _sql = string.Format("SELECT bounty FROM Players WHERE steamid = '{0}'", _cInfo2.playerId);
                         DataTable _result3 = SQL.TQuery(_sql);
                         int       _oldBounty;
                         int.TryParse(_result3.Rows[0].ItemArray.GetValue(0).ToString(), out _oldBounty);
                         _result3.Dispose();
                         _sql = string.Format("UPDATE Players SET bounty = {0} WHERE steamid = '{1}'", _oldBounty + Bounties.Bonus, _cInfo1.playerId);
                         SQL.FastQuery(_sql);
                         using (StreamWriter sw = new StreamWriter(filepath, true))
                         {
                             sw.WriteLine(string.Format("{0}: {1} is on a kill streak of {2}. Their bounty has increased.", DateTime.Now, _cInfo2.playerName, _newValue));
                             sw.WriteLine();
                             sw.Flush();
                             sw.Close();
                         }
                     }
                 }
             }
             else
             {
                 KillStreak.Add(_cInfo2.entityId, 1);
             }
         }
     }
 }
Ejemplo n.º 12
0
        public static void Tele(ClientInfo _cInfo, bool _announce)
        {
            EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];

            Flag.Clear();
            int _playerX = (int)_player.position.x;
            int _playerY = (int)_player.position.y;
            int _playerZ = (int)_player.position.z;

            if (Box.Count > 0)
            {
                foreach (KeyValuePair <string, string[]> kvpCorners in Box)
                {
                    string[] _xyzCorner1 = { };
                    if (kvpCorners.Value[0].Contains(","))
                    {
                        _xyzCorner1 = kvpCorners.Value[0].Split(',');
                    }
                    else
                    {
                        _xyzCorner1 = kvpCorners.Value[0].Split(' ');
                    }
                    int xMin, yMin, zMin;
                    int.TryParse(_xyzCorner1[0], out xMin);
                    int.TryParse(_xyzCorner1[1], out yMin);
                    int.TryParse(_xyzCorner1[2], out zMin);
                    string[] _xyzCorner2 = { };
                    if (kvpCorners.Value[1].Contains(","))
                    {
                        _xyzCorner2 = kvpCorners.Value[1].Split(',');
                    }
                    else
                    {
                        _xyzCorner2 = kvpCorners.Value[1].Split(' ');
                    }
                    int xMax, yMax, zMax;
                    int.TryParse(_xyzCorner2[0], out xMax);
                    int.TryParse(_xyzCorner2[1], out yMax);
                    int.TryParse(_xyzCorner2[2], out zMax);
                    string[] _xyzDestCords = { };
                    if (kvpCorners.Value[2].Contains(","))
                    {
                        _xyzDestCords = kvpCorners.Value[2].Split(',');
                    }
                    else
                    {
                        _xyzDestCords = kvpCorners.Value[2].Split(' ');
                    }
                    int xDest, yDest, zDest;
                    int.TryParse(_xyzDestCords[0], out xDest);
                    int.TryParse(_xyzDestCords[1], out yDest);
                    int.TryParse(_xyzDestCords[2], out zDest);

                    if (xMin >= 0 & xMax >= 0)
                    {
                        if (xMin < xMax)
                        {
                            if (_playerX >= xMin)
                            {
                                _xMinCheck = 1;
                            }
                            else
                            {
                                _xMinCheck = 0;
                            }
                            if (_playerX <= xMax)
                            {
                                _xMaxCheck = 1;
                            }
                            else
                            {
                                _xMaxCheck = 0;
                            }
                        }
                        else
                        {
                            if (_playerX <= xMin)
                            {
                                _xMinCheck = 1;
                            }
                            else
                            {
                                _xMinCheck = 0;
                            }
                            if (_playerX >= xMax)
                            {
                                _xMaxCheck = 1;
                            }
                            else
                            {
                                _xMaxCheck = 0;
                            }
                        }
                    }
                    else if (xMin <= 0 & xMax <= 0)
                    {
                        if (xMin < xMax)
                        {
                            if (_playerX >= xMin)
                            {
                                _xMinCheck = 1;
                            }
                            else
                            {
                                _xMinCheck = 0;
                            }
                            if (_playerX <= xMax)
                            {
                                _xMaxCheck = 1;
                            }
                            else
                            {
                                _xMaxCheck = 0;
                            }
                        }
                        else
                        {
                            if (_playerX <= xMin)
                            {
                                _xMinCheck = 1;
                            }
                            else
                            {
                                _xMinCheck = 0;
                            }
                            if (_playerX >= xMax)
                            {
                                _xMaxCheck = 1;
                            }
                            else
                            {
                                _xMaxCheck = 0;
                            }
                        }
                    }
                    else if (xMin <= 0 & xMax >= 0)
                    {
                        if (_playerX >= xMin)
                        {
                            _xMinCheck = 1;
                        }
                        else
                        {
                            _xMinCheck = 0;
                        }
                        if (_playerX <= xMax)
                        {
                            _xMaxCheck = 1;
                        }
                        else
                        {
                            _xMaxCheck = 0;
                        }
                    }
                    else if (xMin >= 0 & xMax <= 0)
                    {
                        if (_playerX <= xMin)
                        {
                            _xMinCheck = 1;
                        }
                        else
                        {
                            _xMinCheck = 0;
                        }
                        if (_playerX >= xMax)
                        {
                            _xMaxCheck = 1;
                        }
                        else
                        {
                            _xMaxCheck = 0;
                        }
                    }

                    if (yMin >= 0 & yMax >= 0)
                    {
                        if (yMin < yMax)
                        {
                            if (_playerY >= yMin)
                            {
                                _yMinCheck = 1;
                            }
                            else
                            {
                                _yMinCheck = 0;
                            }
                            if (_playerY <= yMax)
                            {
                                _yMaxCheck = 1;
                            }
                            else
                            {
                                _yMaxCheck = 0;
                            }
                        }
                        else
                        {
                            if (_playerY <= yMin)
                            {
                                _yMinCheck = 1;
                            }
                            else
                            {
                                _yMinCheck = 0;
                            }
                            if (_playerY >= yMax)
                            {
                                _yMaxCheck = 1;
                            }
                            else
                            {
                                _yMaxCheck = 0;
                            }
                        }
                    }
                    else if (yMin <= 0 & yMax <= 0)
                    {
                        if (yMin < yMax)
                        {
                            if (_playerY >= yMin)
                            {
                                _yMinCheck = 1;
                            }
                            else
                            {
                                _yMinCheck = 0;
                            }
                            if (_playerY <= yMax)
                            {
                                _yMaxCheck = 1;
                            }
                            else
                            {
                                _yMaxCheck = 0;
                            }
                        }
                        else
                        {
                            if (_playerY <= yMin)
                            {
                                _yMinCheck = 1;
                            }
                            else
                            {
                                _yMinCheck = 0;
                            }
                            if (_playerY >= yMax)
                            {
                                _yMaxCheck = 1;
                            }
                            else
                            {
                                _yMaxCheck = 0;
                            }
                        }
                    }
                    else if (yMin <= 0 & yMax >= 0)
                    {
                        if (_playerY >= yMin)
                        {
                            _yMinCheck = 1;
                        }
                        else
                        {
                            _yMinCheck = 0;
                        }
                        if (_playerY <= yMax)
                        {
                            _yMaxCheck = 1;
                        }
                        else
                        {
                            _yMaxCheck = 0;
                        }
                    }
                    else if (yMin >= 0 & yMax <= 0)
                    {
                        if (_playerY <= yMin)
                        {
                            _yMinCheck = 1;
                        }
                        else
                        {
                            _yMinCheck = 0;
                        }
                        if (_playerY >= yMax)
                        {
                            _yMaxCheck = 1;
                        }
                        else
                        {
                            _yMaxCheck = 0;
                        }
                    }

                    if (zMin >= 0 & zMax >= 0)
                    {
                        if (zMin < zMax)
                        {
                            if (_playerZ >= zMin)
                            {
                                _zMinCheck = 1;
                            }
                            else
                            {
                                _zMinCheck = 0;
                            }
                            if (_playerZ <= zMax)
                            {
                                _zMaxCheck = 1;
                            }
                            else
                            {
                                _zMaxCheck = 0;
                            }
                        }
                        else
                        {
                            if (_playerZ <= zMin)
                            {
                                _zMinCheck = 1;
                            }
                            else
                            {
                                _zMinCheck = 0;
                            }
                            if (_playerZ >= zMax)
                            {
                                _zMaxCheck = 1;
                            }
                            else
                            {
                                _zMaxCheck = 0;
                            }
                        }
                    }
                    else if (zMin <= 0 & zMax <= 0)
                    {
                        if (zMin < zMax)
                        {
                            if (_playerZ >= zMin)
                            {
                                _zMinCheck = 1;
                            }
                            else
                            {
                                _zMinCheck = 0;
                            }
                            if (_playerZ <= zMax)
                            {
                                _zMaxCheck = 1;
                            }
                            else
                            {
                                _zMaxCheck = 0;
                            }
                        }
                        else
                        {
                            if (_playerZ <= zMin)
                            {
                                _zMinCheck = 1;
                            }
                            else
                            {
                                _zMinCheck = 0;
                            }
                            if (_playerZ >= zMax)
                            {
                                _zMaxCheck = 1;
                            }
                            else
                            {
                                _zMaxCheck = 0;
                            }
                        }
                    }
                    else if (zMin <= 0 & zMax >= 0)
                    {
                        if (_playerZ >= zMin)
                        {
                            _zMinCheck = 1;
                        }
                        else
                        {
                            _zMinCheck = 0;
                        }
                        if (_playerZ <= zMax)
                        {
                            _zMaxCheck = 1;
                        }
                        else
                        {
                            _zMaxCheck = 0;
                        }
                    }
                    else if (zMin >= 0 & zMax <= 0)
                    {
                        if (_playerY <= zMin)
                        {
                            _zMinCheck = 1;
                        }
                        else
                        {
                            _zMinCheck = 0;
                        }
                        if (_playerY >= zMax)
                        {
                            _zMaxCheck = 1;
                        }
                        else
                        {
                            _zMaxCheck = 0;
                        }
                    }
                    if (_xMinCheck == 1 & _yMinCheck == 1 & _zMinCheck == 1 & _xMaxCheck == 1 & _yMaxCheck == 1 & _zMaxCheck == 1)
                    {
                        if (PvP_Check)
                        {
                            if (Teleportation.PCheck(_cInfo, _player))
                            {
                                return;
                            }
                        }
                        if (Zombie_Check)
                        {
                            if (Teleportation.ZCheck(_cInfo, _player))
                            {
                                return;
                            }
                        }
                        Players.NoFlight.Add(_cInfo.entityId);
                        _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(xDest, yDest, zDest), null, false));
                        string _sql;
                        if (Wallet.IsEnabled && Command_Cost >= 1)
                        {
                            Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost);
                        }
                        _sql = string.Format("UPDATE Players SET lastTravel = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
                        SQL.FastQuery(_sql);
                        string _phrase603;
                        if (!Phrases.Dict.TryGetValue(603, out _phrase603))
                        {
                            _phrase603 = " you have traveled to {Destination}.";
                        }
                        _phrase603 = _phrase603.Replace("{Destination}", kvpCorners.Key);
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase603 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                    else
                    {
                        Flag.Add(_cInfo.entityId + 1);
                        if (Flag.Count == Box.Count)
                        {
                            string _phrase604;
                            if (!Phrases.Dict.TryGetValue(604, out _phrase604))
                            {
                                _phrase604 = " you are not in a travel location.";
                            }
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase604 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                        }
                    }
                }
            }
        }
Ejemplo n.º 13
0
        public static void CancelAuction(ClientInfo _cInfo)
        {
            string    _sql    = string.Format("SELECT * FROM Auction WHERE steamid = '{0}'", _cInfo.playerId);
            DataTable _result = SQL.TQuery(_sql);

            if (_result.Rows.Count > 0)
            {
                DateTime _cancelTime;
                DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(6).ToString(), out _cancelTime);
                TimeSpan varTime           = DateTime.Now - _cancelTime;
                double   fractionalMinutes = varTime.TotalMinutes;
                int      _timepassed       = (int)fractionalMinutes;
                if (_timepassed >= 15)
                {
                    string    _itemName = _result.Rows[0].ItemArray.GetValue(2).ToString();
                    ItemValue itemValue = ItemClass.GetItem(_itemName, true);
                    if (itemValue.type == ItemValue.None.type)
                    {
                        Log.Out(string.Format("Could not find itemValue {0}", itemValue));
                        return;
                    }
                    else
                    {
                        int _quality;
                        int.TryParse(_result.Rows[0].ItemArray.GetValue(4).ToString(), out _quality);
                        itemValue = new ItemValue(ItemClass.GetItem(_itemName).type, _quality, _quality, true);
                    }
                    int _itemCount;
                    int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _itemCount);
                    World world      = GameManager.Instance.World;
                    var   entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                    {
                        entityClass     = EntityClass.FromString("item"),
                        id              = EntityFactory.nextEntityID++,
                        itemStack       = new ItemStack(itemValue, _itemCount),
                        pos             = world.Players.dict[_cInfo.entityId].position,
                        rot             = new Vector3(20f, 0f, 20f),
                        lifetime        = 60f,
                        belongsPlayerId = _cInfo.entityId
                    });
                    world.SpawnEntityInWorld(entityItem);
                    _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId));
                    world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
                    _sql = string.Format("DELETE FROM Auction WHERE steamid = '{0}'", _cInfo.playerId);
                    SQL.FastQuery(_sql);
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", your auction item has returned to you.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    using (StreamWriter sw = new StreamWriter(filepath, true))
                    {
                        sw.WriteLine(string.Format("{0}: {1} has cancelled their auction entry # {2}.", DateTime.Now, _cInfo.playerName, _cInfo.entityId));
                        sw.WriteLine();
                        sw.Flush();
                        sw.Close();
                    }
                }
                else
                {
                    int    _timeleft = 15 - _timepassed;
                    string _message  = "you must wait 15 minutes before you can cancel your auction item. Be careful what you sell. Time remaining: {Time} minutes.[-]";
                    _message = _message.Replace("{Time}", _timeleft.ToString());
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                }
            }
            else
            {
                Log.Out("No auction item found for this player");
            }
            _result.Dispose();
        }
Ejemplo n.º 14
0
        public static void BuyAuction(ClientInfo _cInfo, int _purchase)
        {
            string    _sql      = string.Format("SELECT * FROM Auction WHERE auctionid = {0}", _purchase);
            DataTable _result   = SQL.TQuery(_sql);
            string    _steamid  = _result.Rows[0].ItemArray.GetValue(1).ToString();
            string    _itemName = _result.Rows[0].ItemArray.GetValue(2).ToString();
            int       _itemCount;

            int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _itemCount);
            int _quality;

            int.TryParse(_result.Rows[0].ItemArray.GetValue(4).ToString(), out _quality);
            int _itemPrice;

            int.TryParse(_result.Rows[0].ItemArray.GetValue(5).ToString(), out _itemPrice);
            ItemValue itemValue = ItemClass.GetItem(_itemName, true);

            if (itemValue.type == ItemValue.None.type)
            {
                Log.Out(string.Format("Could not find itemValue for {0}", _itemName));
                return;
            }
            else
            {
                itemValue = new ItemValue(ItemClass.GetItem(_itemName).type, _quality, _quality, true);
            }
            World world      = GameManager.Instance.World;
            var   entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
            {
                entityClass     = EntityClass.FromString("item"),
                id              = EntityFactory.nextEntityID++,
                itemStack       = new ItemStack(itemValue, _itemCount),
                pos             = world.Players.dict[_cInfo.entityId].position,
                rot             = new Vector3(20f, 0f, 20f),
                lifetime        = 60f,
                belongsPlayerId = _cInfo.entityId
            });

            world.SpawnEntityInWorld(entityItem);
            _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId));
            world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
            Wallet.SubtractCoinsFromWallet(_cInfo.playerId, _itemPrice);
            string _message = "you have purchased {Count} {ItemName} from the auction for {Value} {CoinName}.";

            _message = _message.Replace("{Count}", _itemCount.ToString());
            _message = _message.Replace("{ItemName}", _itemName);
            _message = _message.Replace("{Value}", _itemPrice.ToString());
            _message = _message.Replace("{CoinName}", Wallet.Coin_Name);
            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            double _percent  = _itemPrice * 0.05;
            int    _newCoin2 = _itemPrice - (int)_percent;

            _sql = string.Format("DELETE FROM Auction WHERE auctionid = {0}", _purchase);
            SQL.FastQuery(_sql);
            Wallet.AddCoinsToWallet(_steamid, _newCoin2);
            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", seller has received the funds in their wallet.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            ClientInfo _cInfo1 = ConnectionManager.Instance.Clients.ForPlayerId(_steamid);

            if (_cInfo1 != null)
            {
                ChatHook.ChatMessage(_cInfo1, LoadConfig.Chat_Response_Color + _cInfo1.playerName + ", your auction item was purchased and the value placed in your wallet.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
            using (StreamWriter sw = new StreamWriter(filepath, true))
            {
                sw.WriteLine(string.Format("{0}: {1} has purchased auction entry {2}, profits went to steam id {3}", DateTime.Now, _cInfo.playerName, _purchase, _steamid));
                sw.WriteLine();
                sw.Flush();
                sw.Close();
            }
        }
Ejemplo n.º 15
0
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params[0] == "new")
         {
             if (_params.Count < 3)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected at least 3, found {0}", _params.Count));
                 return;
             }
             else
             {
                 int _hours;
                 if (!int.TryParse(_params[1], out _hours))
                 {
                     SdtdConsole.Instance.Output(string.Format("Invalid integer {0}", _params[1]));
                     return;
                 }
                 _params.RemoveRange(0, 2);
                 string    _message = string.Join(" ", _params.ToArray());
                 string    _sql     = "SELECT pollTime, pollHours, pollMessage FROM Polls WHERE pollOpen = 'true'";
                 DataTable _result  = SQL.TQuery(_sql);
                 if (_result.Rows.Count > 0)
                 {
                     DateTime _pollTime;
                     DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _pollTime);
                     int _pollHours;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _pollHours);
                     string   _pollMessage    = _result.Rows[0].ItemArray.GetValue(2).ToString();
                     TimeSpan varTime         = DateTime.Now - _pollTime;
                     double   fractionalHours = varTime.TotalHours;
                     int      _timepassed     = (int)fractionalHours;
                     if (_timepassed >= _pollHours)
                     {
                         SdtdConsole.Instance.Output("There is a poll open but the time has expired.");
                         SdtdConsole.Instance.Output(string.Format("Poll: {0}", _pollMessage));
                         SdtdConsole.Instance.Output("You need to close the above poll before making a new one.");
                     }
                     else
                     {
                         int _timeleft = _pollHours - _timepassed;
                         SdtdConsole.Instance.Output("There is a poll open. Let it finish or close it");
                         SdtdConsole.Instance.Output(string.Format("Poll: {0}", _pollMessage));
                         SdtdConsole.Instance.Output(string.Format("Time Remaining: {0} hours", _timeleft));
                     }
                 }
                 else
                 {
                     _sql = string.Format("INSERT INTO Polls (pollOpen, pollTime, pollHours, pollMessage) VALUES ('true', '{0}', {1}, '{2}')", DateTime.Now, _hours, _message);
                     SQL.FastQuery(_sql);
                     string _phrase926;
                     if (!Phrases.Dict.TryGetValue(926, out _phrase926))
                     {
                         _phrase926 = "Poll: {Message}";
                     }
                     _phrase926 = _phrase926.Replace("{Message}", _message);
                     string _phrase927;
                     if (!Phrases.Dict.TryGetValue(927, out _phrase927))
                     {
                         _phrase927 = "Type /pollyes or /pollno to vote.";
                     }
                     ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _phrase926, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                     ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _phrase927, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                     SdtdConsole.Instance.Output(string.Format("Opened a new poll for {0} hours.", _hours));
                     using (StreamWriter sw = new StreamWriter(_filepath, true))
                     {
                         sw.WriteLine(string.Format("{0}  New poll {1} ... The poll will be open for {2} hours", DateTime.Now, _message, _hours));
                         sw.WriteLine();
                         sw.Flush();
                         sw.Close();
                     }
                 }
                 _result.Dispose();
             }
         }
         else if (_params[0] == "close")
         {
             if (_params.Count != 2)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}", _params.Count));
                 return;
             }
             bool _announce = false;
             if (!bool.TryParse(_params[1], out _announce))
             {
                 SdtdConsole.Instance.Output(string.Format("Invalid true/false argument: {0}", _params[1]));
                 return;
             }
             else
             {
                 string    _sql    = "SELECT pollMessage, pollYes, pollNo FROM Polls WHERE pollOpen = 'true'";
                 DataTable _result = SQL.TQuery(_sql);
                 if (_result.Rows.Count > 0)
                 {
                     int _pollYes;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _pollYes);
                     int _pollNo;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _pollNo);
                     if (_announce)
                     {
                         string _phrase925;
                         if (!Phrases.Dict.TryGetValue(925, out _phrase925))
                         {
                             _phrase925 = "Poll results: Yes {YesVote} / No {NoVote}";
                         }
                         _phrase925 = _phrase925.Replace("{YesVote}", _pollYes.ToString());
                         _phrase925 = _phrase925.Replace("{NoVote}", _pollNo.ToString());
                         ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _phrase925, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                     }
                     using (StreamWriter sw = new StreamWriter(_filepath, true))
                     {
                         string _pollMessage = _result.Rows[0].ItemArray.GetValue(0).ToString();
                         sw.WriteLine(string.Format("{0}  Poll {1} ... has completed. The final results were yes {2} / no {3}", DateTime.Now, _pollMessage, _pollYes, _pollNo));
                         sw.WriteLine();
                         sw.Flush();
                         sw.Close();
                     }
                     _sql = "SELECT pollMessage, pollYes, pollNo FROM Polls WHERE pollOpen = 'false'";
                     DataTable _result1 = SQL.TQuery(_sql);
                     if (_result1.Rows.Count > 0)
                     {
                         _sql = "DELETE FROM Polls WHERE pollOpen = 'false'";
                         SQL.FastQuery(_sql);
                     }
                     _result1.Dispose();
                     _sql = "UPDATE Polls SET pollOpen = 'false' WHERE pollOpen = 'true'";
                     SQL.FastQuery(_sql);
                     PolledYes.Clear();
                     PolledNo.Clear();
                     SdtdConsole.Instance.Output("Closed the open poll.");
                 }
                 else
                 {
                     SdtdConsole.Instance.Output("No poll is open");
                 }
                 _result.Dispose();
             }
         }
         else if (_params[0] == "last")
         {
             if (_params.Count != 1)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, found {0}", _params.Count));
                 return;
             }
             else
             {
                 string    _sql    = "SELECT pollHours, pollMessage, pollYes, pollNo FROM Polls WHERE pollOpen = 'false'";
                 DataTable _result = SQL.TQuery(_sql);
                 if (_result.Rows.Count > 0)
                 {
                     int _pollHours;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _pollHours);
                     string _pollMessage = _result.Rows[0].ItemArray.GetValue(1).ToString();
                     int    _pollYes;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _pollYes);
                     int _pollNo;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _pollNo);
                     SdtdConsole.Instance.Output(string.Format("The last poll message: {0}", _pollMessage));
                     SdtdConsole.Instance.Output(string.Format("Last poll results: Yes {0} / No {1}", _pollYes, _pollNo));
                     SdtdConsole.Instance.Output(string.Format("Poll was open for {0} hours", _pollHours));
                 }
                 else
                 {
                     SdtdConsole.Instance.Output("There are no saved prior poll results");
                 }
                 _result.Dispose();
             }
         }
         else if (_params[0] == "reopen")
         {
             if (_params.Count != 2)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}", _params.Count));
                 return;
             }
             string    _sql    = "SELECT pollTime, pollHours, pollMessage FROM Polls WHERE pollOpen = 'true'";
             DataTable _result = SQL.TQuery(_sql);
             if (_result.Rows.Count > 0)
             {
                 SdtdConsole.Instance.Output("A poll is open. Can not open a new poll until it is closed");
             }
             else
             {
                 _sql = "SELECT pollTime, pollHours, pollMessage FROM Polls WHERE pollOpen = 'false'";
                 DataTable _result1 = SQL.TQuery(_sql);
                 if (_result1.Rows.Count > 0)
                 {
                     int _hours;
                     int.TryParse(_params[1], out _hours);
                     _sql = string.Format("UPDATE Polls SET pollOpen = 'true', pollTime = '{0}', pollHours = {1} WHERE pollOpen = 'false'", DateTime.Now, _hours);
                     SQL.FastQuery(_sql);
                 }
                 else
                 {
                     SdtdConsole.Instance.Output("You have no previous poll");
                 }
                 _result1.Dispose();
             }
             _result.Dispose();
         }
         else if (_params[0] == "check")
         {
             if (_params.Count != 1)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, found {0}", _params.Count));
                 return;
             }
             string    _sql    = "SELECT pollTime, pollHours, pollMessage, pollYes, pollNo FROM Polls WHERE pollOpen = 'true'";
             DataTable _result = SQL.TQuery(_sql);
             if (_result.Rows.Count > 0)
             {
                 DateTime _pollTime;
                 DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _pollTime);
                 int _pollHours;
                 int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _pollHours);
                 string _pollMessage = _result.Rows[0].ItemArray.GetValue(2).ToString();
                 int    _pollYes;
                 int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _pollYes);
                 int _pollNo;
                 int.TryParse(_result.Rows[0].ItemArray.GetValue(4).ToString(), out _pollNo);
                 TimeSpan varTime         = DateTime.Now - _pollTime;
                 double   fractionalHours = varTime.TotalHours;
                 int      _timepassed     = (int)fractionalHours;
                 if (_timepassed >= _pollHours)
                 {
                     SdtdConsole.Instance.Output("There is a poll open but the time has expired.");
                     SdtdConsole.Instance.Output(string.Format("Poll: {0}", _pollMessage));
                     SdtdConsole.Instance.Output(string.Format("Current poll results: Yes votes {0} / No votes {1}", _pollYes, _pollNo));
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Poll: {0}", _pollMessage));
                     SdtdConsole.Instance.Output(string.Format("Current poll results: Yes votes {0} / No votes {1}", _pollYes, _pollNo));
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output("No poll is open");
             }
             _result.Dispose();
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in PollConsole.Run: {0}.", e));
     }
 }
Ejemplo n.º 16
0
 public static void PlayerCheck()
 {
     if (!IsRunning2)
     {
         IsRunning2 = true;
         if (ConnectionManager.Instance.ClientCount() > 0)
         {
             List <EntityPlayer> EntityPlayerList = GameManager.Instance.World.Players.list;
             for (int i = 0; i < EntityPlayerList.Count; i++)
             {
                 EntityPlayer _player = EntityPlayerList[i];
                 if (_player != null)
                 {
                     ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForEntityId(_player.entityId);
                     if (_cInfo != null)
                     {
                         if (!_player.IsDead() && _player.Spawned)
                         {
                             if (Zones.IsEnabled)
                             {
                                 Zones.ZoneCheck(_cInfo, _player);
                             }
                             if (GodModeFlight.IsEnabled)
                             {
                                 GodModeFlight.GodFlightCheck(_cInfo);
                             }
                         }
                         else if (_player.IsDead())
                         {
                             if (!Died.Contains(_player.entityId))
                             {
                                 Died.Add(_player.entityId);
                                 if (KillNotice.IsEnabled || Bounties.IsEnabled || Zones.IsEnabled)
                                 {
                                     for (int j = 0; j < EntityPlayerList.Count; j++)
                                     {
                                         EntityPlayer _player2 = EntityPlayerList[j];
                                         if (_player != _player2)
                                         {
                                             ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForEntityId(_player2.entityId);
                                             if (_cInfo2 != null)
                                             {
                                                 Entity _target = _player2.GetDamagedTarget();
                                                 if (_player == _target)
                                                 {
                                                     if (KillNotice.IsEnabled)
                                                     {
                                                         string    _holdingItem = _player2.inventory.holdingItem.Name;
                                                         ItemValue _itemValue   = ItemClass.GetItem(_holdingItem, true);
                                                         if (_itemValue.type != ItemValue.None.type)
                                                         {
                                                             _holdingItem = _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.Name;
                                                         }
                                                         KillNotice.Notice(_cInfo, _cInfo2, _holdingItem);
                                                     }
                                                     if (Bounties.IsEnabled)
                                                     {
                                                         Bounties.PlayerKilled(_player, _player2, _cInfo, _cInfo2);
                                                     }
                                                     if (Zones.IsEnabled)
                                                     {
                                                         Zones.Check(_cInfo, _cInfo2);
                                                     }
                                                     break;
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 if (DeathSpot.IsEnabled)
                                 {
                                     DeathSpot.PlayerKilled(_player);
                                 }
                                 if (Wallet.IsEnabled && Wallet.Lose_On_Death)
                                 {
                                     string    _sql    = string.Format("SELECT playerSpentCoins FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                                     DataTable _result = SQL.TQuery(_sql);
                                     int       _playerSpentCoins;
                                     int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _playerSpentCoins);
                                     _result.Dispose();
                                     int _currentCoins = Wallet.GetcurrentCoins(_cInfo);
                                     if (_currentCoins >= 1)
                                     {
                                         _sql = string.Format("UPDATE Players SET playerSpentCoins = {0} WHERE steamid = '{1}'", _playerSpentCoins - _currentCoins, _cInfo.playerId);
                                         SQL.FastQuery(_sql, "Players");
                                     }
                                 }
                                 if (Event.Open && Event.PlayersTeam.ContainsKey(_cInfo.playerId))
                                 {
                                     string _sql = string.Format("UPDATE Players SET eventReturn = 'true' WHERE steamid = '{0}'", _cInfo.playerId);
                                     SQL.FastQuery(_sql, "Players");
                                 }
                             }
                         }
                     }
                 }
             }
         }
         IsRunning2 = false;
     }
 }
Ejemplo n.º 17
0
        private static void SetPoint(ClientInfo _cInfo, string _waypoint)
        {
            string    _sql    = string.Format("SELECT steamid FROM Waypoints WHERE steamid = '{0}'", _cInfo.playerId);
            DataTable _result = SQL.TQuery(_sql);

            if (_result.Rows.Count > 0)
            {
                if (ReservedSlots.IsEnabled && ReservedSlots.Dict.ContainsKey(_cInfo.playerId))
                {
                    DateTime _dt;
                    ReservedSlots.Dict.TryGetValue(_cInfo.playerId, out _dt);
                    if (DateTime.Now < _dt)
                    {
                        if (_result.Rows.Count < Donator_Max_Waypoints && Donator_Max_Waypoints > 0)
                        {
                            EntityPlayer _player    = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                            Vector3      _position  = _player.GetPosition();
                            int          x          = (int)_position.x;
                            int          y          = (int)_position.y;
                            int          z          = (int)_position.z;
                            string       _wposition = x + "," + y + "," + z;
                            _waypoint = SQL.EscapeString(_waypoint);
                            _sql      = string.Format("INSERT INTO Waypoints (steamid, wayPointName, position) VALUES ('{0}', '{1}', '{2}')", _cInfo.playerId, _waypoint, _wposition);
                            SQL.FastQuery(_sql, "Waypoints");
                            string _message = " saved waypoint name as {Name} to {X} {Y} {Z}.";
                            _message = _message.Replace("{Name}", _waypoint);
                            _message = _message.Replace("{X}", x.ToString());
                            _message = _message.Replace("{Y}", y.ToString());
                            _message = _message.Replace("{Z}", z.ToString());
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                        }
                        else
                        {
                            string _phrase581;
                            if (!Phrases.Dict.TryGetValue(581, out _phrase581))
                            {
                                _phrase581 = " you have a maximum {Count} waypoints.";
                            }
                            _phrase581 = _phrase581.Replace("{Count}", Donator_Max_Waypoints.ToString());
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase581 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                        }
                    }
                }
                else
                {
                    if (_result.Rows.Count < Max_Waypoints && Max_Waypoints > 0)
                    {
                        EntityPlayer _player    = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                        Vector3      _position  = _player.GetPosition();
                        int          x          = (int)_position.x;
                        int          y          = (int)_position.y;
                        int          z          = (int)_position.z;
                        string       _wposition = x + "," + y + "," + z;
                        _waypoint = SQL.EscapeString(_waypoint);
                        _sql      = string.Format("INSERT INTO Waypoints (steamid, wayPointName, position) VALUES ('{0}', '{1}', '{2}')", _cInfo.playerId, _waypoint, _wposition);
                        SQL.FastQuery(_sql, "Waypoints");
                        string _message = " saved waypoint name as {Name} to {X} {Y} {Z}.";
                        _message = _message.Replace("{Name}", _waypoint);
                        _message = _message.Replace("{X}", x.ToString());
                        _message = _message.Replace("{Y}", y.ToString());
                        _message = _message.Replace("{Z}", z.ToString());
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                    else
                    {
                        string _phrase582;
                        if (!Phrases.Dict.TryGetValue(582, out _phrase582))
                        {
                            _phrase582 = " you have a maximum {Count} waypoints.";
                        }
                        _phrase582 = _phrase582.Replace("{Count}", Max_Waypoints.ToString());
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase582 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
            }
            else
            {
                if (ReservedSlots.IsEnabled && ReservedSlots.Dict.ContainsKey(_cInfo.playerId))
                {
                    DateTime _dt;
                    ReservedSlots.Dict.TryGetValue(_cInfo.playerId, out _dt);
                    if (DateTime.Now < _dt)
                    {
                        if (Donator_Max_Waypoints > 0)
                        {
                            EntityPlayer _player    = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                            Vector3      _position  = _player.GetPosition();
                            int          x          = (int)_position.x;
                            int          y          = (int)_position.y;
                            int          z          = (int)_position.z;
                            string       _wposition = x + "," + y + "," + z;
                            _waypoint = SQL.EscapeString(_waypoint);
                            _sql      = string.Format("INSERT INTO Waypoints (steamid, wayPointName, position) VALUES ('{0}', '{1}', '{2}')", _cInfo.playerId, _waypoint, _wposition);
                            SQL.FastQuery(_sql, "Waypoints");
                            string _message = " saved waypoint name as {Name} to {X} {Y} {Z}.";
                            _message = _message.Replace("{Name}", _waypoint);
                            _message = _message.Replace("{X}", x.ToString());
                            _message = _message.Replace("{Y}", y.ToString());
                            _message = _message.Replace("{Z}", z.ToString());
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                        }
                        else
                        {
                            string _phrase581;
                            if (!Phrases.Dict.TryGetValue(581, out _phrase581))
                            {
                                _phrase581 = " you have a maximum {Count} waypoints.";
                            }
                            _phrase581 = _phrase581.Replace("{Count}", Donator_Max_Waypoints.ToString());
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase581 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                        }
                    }
                    else
                    {
                        string _phrase582;
                        if (!Phrases.Dict.TryGetValue(582, out _phrase582))
                        {
                            _phrase582 = " you have a maximum {Count} waypoints.";
                        }
                        _phrase582 = _phrase582.Replace("{Count}", Max_Waypoints.ToString());
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase582 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
                else
                {
                    if (Max_Waypoints > 0)
                    {
                        EntityPlayer _player    = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                        Vector3      _position  = _player.GetPosition();
                        int          x          = (int)_position.x;
                        int          y          = (int)_position.y;
                        int          z          = (int)_position.z;
                        string       _wposition = x + "," + y + "," + z;
                        _waypoint = SQL.EscapeString(_waypoint);
                        _sql      = string.Format("INSERT INTO Waypoints (steamid, wayPointName, position) VALUES ('{0}', '{1}', '{2}')", _cInfo.playerId, _waypoint, _wposition);
                        SQL.FastQuery(_sql, "Waypoints");
                        string _message = " saved waypoint name as {Name} to {X} {Y} {Z}.";
                        _message = _message.Replace("{Name}", _waypoint);
                        _message = _message.Replace("{X}", x.ToString());
                        _message = _message.Replace("{Y}", y.ToString());
                        _message = _message.Replace("{Z}", z.ToString());
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                    else
                    {
                        string _phrase582;
                        if (!Phrases.Dict.TryGetValue(582, out _phrase582))
                        {
                            _phrase582 = " you have a maximum {Count} waypoints.";
                        }
                        _phrase582 = _phrase582.Replace("{Count}", Max_Waypoints.ToString());
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase582 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
            }
            _result.Dispose();
        }
Ejemplo n.º 18
0
 public static void AddPlayer(ClientInfo _cInfo)
 {
     if (!PlayersTeam.ContainsKey(_cInfo.playerId))
     {
         EntityPlayer _player      = GameManager.Instance.World.Players.dict[_cInfo.entityId];
         Vector3      _position    = _player.GetPosition();
         int          x            = (int)_position.x;
         int          y            = (int)_position.y;
         int          z            = (int)_position.z;
         string       _sposition   = x + "," + y + "," + z;
         string       _eventReturn = SQL.EscapeString(_sposition);
         string       _sql         = string.Format("UPDATE Players SET eventReturn = '{0}' WHERE steamid = {1}", _eventReturn, _cInfo.playerId);
         SQL.FastQuery(_sql);
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you have signed up for the event and your current location has been saved for return.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null);
         _sql = string.Format("SELECT eventid, eventName, eventTeams, eventPlayerCount, eventTime FROM Events WHERE eventAdmin = '{0}' AND eventActive = 'true'", Admin);
         DataTable _result1 = SQL.TQuery(_sql);
         int       _eventid;
         int.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid);
         string _eventName = _result1.Rows[0].ItemArray.GetValue(1).ToString();
         int    _eventTeams;
         int.TryParse(_result1.Rows[0].ItemArray.GetValue(2).ToString(), out _eventTeams);
         int _eventPlayerCount;
         int.TryParse(_result1.Rows[0].ItemArray.GetValue(3).ToString(), out _eventPlayerCount);
         int _time;
         int.TryParse(_result1.Rows[0].ItemArray.GetValue(4).ToString(), out _time);
         _result1.Dispose();
         PlayersTeam.Add(_cInfo.playerId, TeamCount);
         string _message = "you are on team {Team}.";
         _message = _message.Replace("{Team}", TeamCount.ToString());
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null);
         if (TeamCount == _eventTeams)
         {
             TeamCount = 1;
         }
         if (PlayersTeam.Count == _eventPlayerCount)
         {
             Invited = false;
             foreach (var _eventPlayer in PlayersTeam)
             {
                 ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForPlayerId(_eventPlayer.Key);
                 if (_cInfo2 != null)
                 {
                     EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId];
                     if (_player2 != null && _player2.IsAlive())
                     {
                         int _teamNumber;
                         PlayersTeam.TryGetValue(_eventPlayer.Key, out _teamNumber);
                         _sql = string.Format("SELECT eventSpawn FROM EventSpawns WHERE eventid = {0} AND eventTeam = {1}", _eventid, _teamNumber);
                         DataTable _result2  = SQL.TQuery(_sql);
                         string    _spawnPos = _result2.Rows[0].ItemArray.GetValue(0).ToString();
                         _result2.Dispose();
                         int      _x, _y, _z;
                         string[] _cords = _spawnPos.Split(',');
                         int.TryParse(_cords[0], out _x);
                         int.TryParse(_cords[1], out _y);
                         int.TryParse(_cords[2], out _z);
                         _cInfo2.SendPackage(new NetPackageTeleportPlayer(new Vector3(_x, _y, _z), null, false));
                         ChatHook.ChatMessage(_cInfo2, LoadConfig.Chat_Response_Color + _cInfo2.playerName + ", you have been sent to your event spawn point.[-]", _cInfo2.entityId, _cInfo2.playerName, EChatType.Global, null);
                     }
                     else
                     {
                         _sql = string.Format("UPDATE Players SET eventSpawn = 'true' WHERE steamid = {0}", _eventPlayer.Key);
                         SQL.FastQuery(_sql);
                     }
                 }
                 else
                 {
                     _sql = string.Format("UPDATE Players SET eventSpawn = 'true' WHERE steamid = {0}", _eventPlayer.Key);
                     SQL.FastQuery(_sql);
                 }
             }
             int _eventTime = _time * 60;
             Timers._eventTime = _eventTime;
             Open     = true;
             _message = "{EventName} is full and has now started.";
             _message = _message.Replace("{EventName}", _eventName);
             ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
         }
         else
         {
             _message = "{EventName} still has space for more players. Type /event.";
             _message = _message.Replace("{EventName}", _eventName);
             ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
             _message = "{Count} of {Total} have signed up.";
             _message = _message.Replace("{Count}", PlayersTeam.Count.ToString());
             _message = _message.Replace("{Total}", _eventPlayerCount.ToString());
             ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
         }
     }
     else
     {
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you are already signed up for this event. It will start when enough players sign up.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null);
     }
 }
Ejemplo n.º 19
0
 private static bool GameMessage(ClientInfo _cInfo, EnumGameMessages _type, string _msg, string _mainName, bool _localizeMain, string _secondaryName, bool _localizeSecondary)
 {
     try
     {
         if (_type == EnumGameMessages.EntityWasKilled && _cInfo != null)
         {
             EntityPlayer _player1 = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             if (_player1 != null)
             {
                 bool _notice = false;
                 if (!string.IsNullOrEmpty(_secondaryName) && _mainName != _secondaryName)
                 {
                     ClientInfo _cInfo2 = ConsoleHelper.ParseParamIdOrName(_secondaryName);
                     if (_cInfo2 != null)
                     {
                         EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId];
                         if (_player2 != null)
                         {
                             if (KillNotice.IsEnabled && _player2.IsAlive())
                             {
                                 string _holdingItem = _player2.inventory.holdingItem.Name;
                                 if (!string.IsNullOrEmpty(_holdingItem))
                                 {
                                     ItemValue _itemValue = ItemClass.GetItem(_holdingItem, true);
                                     if (_itemValue.type != ItemValue.None.type)
                                     {
                                         _holdingItem = _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.GetItemName();
                                         KillNotice.Notice(_cInfo, _cInfo2, _holdingItem);
                                         _notice = true;
                                     }
                                 }
                             }
                             if (Zones.IsEnabled)
                             {
                                 Zones.Check(_cInfo, _cInfo2);
                             }
                             if (Bounties.IsEnabled)
                             {
                                 Bounties.PlayerKilled(_player1, _player2, _cInfo, _cInfo2);
                             }
                             if (Wallet.IsEnabled)
                             {
                                 if (Wallet.PVP && Wallet.Player_Kills > 0)
                                 {
                                     Wallet.AddCoinsToWallet(_cInfo2.playerId, Wallet.Player_Kills);
                                 }
                                 else if (Wallet.Player_Kills > 0)
                                 {
                                     Wallet.SubtractCoinsFromWallet(_cInfo2.playerId, Wallet.Player_Kills);
                                 }
                             }
                         }
                     }
                 }
                 if (DeathSpot.IsEnabled)
                 {
                     DeathSpot.PlayerKilled(_player1);
                 }
                 if (Event.Open && Event.PlayersTeam.ContainsKey(_cInfo.playerId))
                 {
                     string _sql = string.Format("UPDATE Players SET eventReturn = 'true' WHERE steamid = '{0}'", _cInfo.playerId);
                     SQL.FastQuery(_sql, "Players");
                 }
                 if (_notice)
                 {
                     return(false);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in API.GameMessage: {0}.", e.Message));
     }
     return(true);
 }
Ejemplo n.º 20
0
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     if (MutePlayer.IsEnabled)
     {
         try
         {
             if (_params.Count < 1 || _params.Count > 3)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1 to 3, found {0}.", _params.Count));
                 return;
             }
             if (_params[0].ToLower().Equals("add"))
             {
                 if (_params.Count < 2 || _params.Count > 3)
                 {
                     SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2 or 3, found {0}.", _params.Count));
                     return;
                 }
                 if (_params[1].Length < 1 || _params[1].Length > 17)
                 {
                     SdtdConsole.Instance.Output(string.Format("Can not add Id: Invalid Id {0}.", _params[1]));
                     return;
                 }
                 int _muteTime = 60;
                 if (_params[2] != null)
                 {
                     int _value;
                     if (int.TryParse(_params[2], out _value))
                     {
                         _muteTime = _value;
                     }
                 }
                 ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]);
                 if (_cInfo != null)
                 {
                     if (MutePlayer.Mutes.Contains(_cInfo.playerId))
                     {
                         SdtdConsole.Instance.Output(string.Format("Steam Id {0}, player name {1} is already muted.", _cInfo.playerId, _cInfo.playerName));
                         return;
                     }
                     else
                     {
                         string _sql;
                         if (_muteTime == -1)
                         {
                             MutePlayer.Mutes.Add(_cInfo.playerId);
                             _sql = string.Format("UPDATE Players SET muteTime = -1, playername = '{0}', WHERE steamid = '{1}'", _cInfo.playerName, _cInfo.playerId);
                             SQL.FastQuery(_sql);
                             SdtdConsole.Instance.Output(string.Format("Steam Id {0}, player name {1} has been muted indefinitely.", _cInfo.playerId, _cInfo.playerName));
                             return;
                         }
                         MutePlayer.Mutes.Add(_cInfo.playerId);
                         _sql = string.Format("UPDATE Players SET muteTime = {0}, playername = '{1}', muteDate = '{2}' WHERE steamid = '{3}'", _muteTime, _cInfo.playerName, DateTime.Now, _cInfo.playerId);
                         SQL.FastQuery(_sql);
                         SdtdConsole.Instance.Output(string.Format("Steam Id {0}, player name {1} has been muted for {2} minutes.", _cInfo.playerId, _cInfo.playerName, _muteTime));
                         return;
                     }
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Player with Id {0} can not be found.", _params[1]));
                     return;
                 }
             }
             else if (_params[0].ToLower().Equals("remove"))
             {
                 if (_params.Count != 2)
                 {
                     SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}.", _params.Count));
                     return;
                 }
                 if (_params[1].Length != 17)
                 {
                     SdtdConsole.Instance.Output(string.Format("Can not add Id: Invalid Id {0}.", _params[1]));
                     return;
                 }
                 string _id = _params[1];
                 if (MutePlayer.Mutes.Contains(_id))
                 {
                     ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_id);
                     if (_cInfo != null)
                     {
                         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you have been unmuted.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     }
                     MutePlayer.Mutes.Remove(_id);
                     string _sql = string.Format("UPDATE Players SET muteTime = 0 WHERE steamid = '{0}'", _id);
                     SQL.FastQuery(_sql);
                     SdtdConsole.Instance.Output(string.Format("Steam Id {0} has been unmuted.", _id));
                     return;
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Steam Id {0} is not muted.", _id));
                     return;
                 }
             }
             else if (_params[0].ToLower().Equals("list"))
             {
                 if (_params.Count != 1)
                 {
                     SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, found {0}.", _params.Count));
                     return;
                 }
                 if (MutePlayer.Mutes.Count > 0)
                 {
                     string    _sql    = "SELECT steamid, playername, muteTime, muteDate FROM Players WHERE muteTime > 0 OR muteTime = -1";
                     DataTable _result = SQL.TQuery(_sql);
                     int       _steamid;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _steamid);
                     string playername = _result.Rows[0].ItemArray.GetValue(1).ToString();
                     int    _muteTime;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _muteTime);
                     DateTime _muteDate;
                     DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _muteDate);
                     _result.Dispose();
                     if (_muteTime == -1)
                     {
                         SdtdConsole.Instance.Output(string.Format("Steam id {0}, player name {1} is muted indefinitely", _steamid, playername));
                         return;
                     }
                     if (_muteTime > 0)
                     {
                         TimeSpan varTime           = DateTime.Now - _muteDate;
                         double   fractionalMinutes = varTime.TotalMinutes;
                         int      _timepassed       = (int)fractionalMinutes;
                         int      _timeleft         = _muteTime - _timepassed;
                         SdtdConsole.Instance.Output(string.Format("Steam id {0}, player name {1} for {2} minutes", _steamid, playername, _timeleft));
                         return;
                     }
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("No players are muted."));
                     return;
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0]));
                 return;
             }
         }
         catch (Exception e)
         {
             Log.Out(string.Format("[SERVERTOOLS] Error in ConsoleCommandMuteConsole.Run: {0}.", e));
         }
     }
     else
     {
         SdtdConsole.Instance.Output("Mute is not enabled.");
         return;
     }
 }
Ejemplo n.º 21
0
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params[0].ToLower().Equals("add"))
         {
             if (_params.Count != 2)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}.", _params.Count));
                 return;
             }
             ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]);
             if (_cInfo != null)
             {
                 string    _sql              = string.Format("SELECT countryban FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                 DataTable _result           = SQL.TQuery(_sql);
                 bool      _countrybanImmune = false;
                 if (_result.Rows.Count > 0)
                 {
                     bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _countrybanImmune);
                 }
                 if (_countrybanImmune)
                 {
                     SdtdConsole.Instance.Output(string.Format("Can not add Id. {0} is already in the Country Ban Immunity list.", _params[1]));
                 }
                 else
                 {
                     if (_result.Rows.Count > 0)
                     {
                         _sql = string.Format("UPDATE Players SET countryban = 'true' WHERE steamid = '{0}'", _cInfo.playerId);
                     }
                     else
                     {
                         _sql = string.Format("INSERT INTO Players (steamid, countryban) VALUES ('{0}', 'true')", _cInfo.playerId);
                     }
                     SQL.FastQuery(_sql);
                     SdtdConsole.Instance.Output(string.Format("Added Id {0} to the Country Ban Immunity list.", _params[1]));
                 }
                 _result.Dispose();
             }
             else
             {
                 if (_params[1].Length != 17)
                 {
                     SdtdConsole.Instance.Output(string.Format("You can only use a player id or their name if online. Can not add Id: Invalid Id {0}", _params[1]));
                     return;
                 }
                 else
                 {
                     string    _id               = SQL.EscapeString(_params[1]);
                     string    _sql              = string.Format("SELECT countryban FROM Players WHERE steamid = '{0}'", _id);
                     DataTable _result           = SQL.TQuery(_sql);
                     bool      _countrybanImmune = false;
                     if (_result.Rows.Count > 0)
                     {
                         bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _countrybanImmune);
                     }
                     if (_countrybanImmune)
                     {
                         SdtdConsole.Instance.Output(string.Format("Can not add Id. {0} is already in the Country Ban Immunity list.", _params[1]));
                     }
                     else
                     {
                         if (_result.Rows.Count > 0)
                         {
                             _sql = string.Format("UPDATE Players SET countryban = 'true' WHERE steamid = '{0}'", _id);
                         }
                         else
                         {
                             _sql = string.Format("INSERT INTO Players (steamid, countryban) VALUES ('{0}', 'true')", _id);
                         }
                         SQL.FastQuery(_sql);
                         SdtdConsole.Instance.Output(string.Format("Added Id {0} to the Country Ban Immunity list.", _params[1]));
                     }
                     _result.Dispose();
                 }
             }
         }
         else if (_params[0].ToLower().Equals("remove"))
         {
             if (_params.Count != 2)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}", _params.Count));
                 return;
             }
             ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]);
             if (_cInfo != null)
             {
                 string    _sql    = string.Format("SELECT countryban FROM Players WHERE steamid = '{0}' AND countryban = 'true'", _cInfo.playerId);
                 DataTable _result = SQL.TQuery(_sql);
                 if (_result.Rows.Count > 0)
                 {
                     _sql = string.Format("UPDATE Players SET countryban = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                     SQL.FastQuery(_sql);
                     SdtdConsole.Instance.Output(string.Format("Removed Id {0} from Country Ban Immunity list.", _params[1]));
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Id {0} was not found.", _params[1]));
                 }
                 _result.Dispose();
             }
             else
             {
                 if (_params[1].Length != 17)
                 {
                     SdtdConsole.Instance.Output(string.Format("You can only use a player id or their name if online. Can not remove Id: Invalid Id {0}", _params[1]));
                 }
                 else
                 {
                     string    _id     = SQL.EscapeString(_params[1]);
                     string    _sql    = string.Format("SELECT countryban FROM Players WHERE steamid = '{0}' AND countryban = 'true'", _id);
                     DataTable _result = SQL.TQuery(_sql);
                     if (_result.Rows.Count > 0)
                     {
                         _sql = string.Format("UPDATE Players SET countryban = 'false' WHERE steamid = '{0}'", _id);
                         SQL.FastQuery(_sql);
                         SdtdConsole.Instance.Output(string.Format("Removed Id {0} from the Country Ban Immunity list.", _params[1]));
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("Id {0} was not found.", _params[1]));
                     }
                     _result.Dispose();
                 }
             }
         }
         else if (_params[0].ToLower().Equals("list"))
         {
             if (_params.Count != 1)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, found {0}.", _params.Count));
                 return;
             }
             string    _sql    = "SELECT countryban FROM Players WHERE countryban = 'true'";
             DataTable _result = SQL.TQuery(_sql);
             if (_result.Rows.Count < 1)
             {
                 SdtdConsole.Instance.Output("There are no Ids on the Country Ban Immunity list.");
             }
             else
             {
                 foreach (DataRow row in _result.Rows)
                 {
                     SdtdConsole.Instance.Output(string.Format("{0}", row[0]));
                 }
                 SdtdConsole.Instance.Output(string.Format("Total: {0}", _result.Rows.Count.ToString()));
             }
             _result.Dispose();
         }
         else
         {
             SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0]));
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in CountryBanImmunityCommandConsole.Run: {0}.", e));
     }
 }
Ejemplo n.º 22
0
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         string _steamId  = _senderInfo.RemoteClientInfo.playerId;
         int    _entityId = _senderInfo.RemoteClientInfo.entityId;
         if (_params[0].ToLower() == ("new"))
         {
             if (_params.Count < 2)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2 or more, found {0}.", _params.Count));
                 return;
             }
             string    _sql    = string.Format("SELECT eventName FROM Events WHERE eventAdmin = '{0}' AND eventName = '{1}'", _steamId, _params[1]);
             DataTable _result = SQL.TQuery(_sql);
             if (_result.Rows.Count == 0)
             {
                 _result.Dispose();
                 string _name = SQL.EscapeString(_params[1]);
                 _sql = string.Format("INSERT INTO Events (eventAdmin, eventName) VALUES ('{0}', '{1}')", _steamId, _name);
                 SQL.FastQuery(_sql, "EventCommandsConsole");
                 if (Event.SetupStage.ContainsKey(_steamId))
                 {
                     Event.SetupName[_steamId]  = _params[1];
                     Event.SetupStage[_steamId] = 1;
                 }
                 else
                 {
                     Event.SetupName.Add(_steamId, _params[1]);
                     Event.SetupStage.Add(_steamId, 1);
                 }
                 if (Event.Open)
                 {
                     SdtdConsole.Instance.Output(string.Format("There is an event being run by {0}.", Event.Admin));
                 }
                 SdtdConsole.Instance.Output("You have started to open a new event setup.");
                 SdtdConsole.Instance.Output(string.Format("The event name has been set to {0}.", _params[1]));
                 SdtdConsole.Instance.Output("What would you like the invitation for players to say? Type event \"invitation\".");
                 return;
             }
             else
             {
                 _result.Dispose();
                 SdtdConsole.Instance.Output(string.Format("The event name {0} already exists. Use a new name or delete the old event.", _params[1]));
                 return;
             }
         }
         else if (_params[0].ToLower() == ("save"))
         {
             if (Event.SetupStage.ContainsKey(_steamId))
             {
                 int _stage;
                 Event.SetupStage.TryGetValue(_steamId, out _stage);
                 string _eventName;
                 Event.SetupName.TryGetValue(_steamId, out _eventName);
                 if (_stage == 3)
                 {
                     EntityPlayer _player    = GameManager.Instance.World.Players.dict[_entityId];
                     Vector3      _position  = _player.GetPosition();
                     int          x          = (int)_position.x;
                     int          y          = (int)_position.y;
                     int          z          = (int)_position.z;
                     string       _sposition = x + "," + y + "," + z;
                     string       _sql       = string.Format("SELECT eventid, eventTeams FROM Events WHERE eventAdmin = '{0}' AND eventName = '{1}'", _steamId, _eventName);
                     DataTable    _result1   = SQL.TQuery(_sql);
                     int          _eventid;
                     int.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid);
                     int _eventTeams;
                     int.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _eventTeams);
                     _result1.Dispose();
                     _sql = string.Format("SELECT eventSpawn FROM EventSpawns WHERE eventid = {0}", _eventid);
                     DataTable _result2 = SQL.TQuery(_sql);
                     int       _count   = _result2.Rows.Count + 1;
                     _result2.Dispose();
                     string _pos = SQL.EscapeString(_sposition);
                     if (_count == _eventTeams)
                     {
                         _sql = string.Format("INSERT INTO EventSpawns (eventid, eventTeam, eventSpawn) VALUES ({0}, {1}, '{2}')", _eventid, _count, _pos);
                         SQL.FastQuery(_sql, "EventCommandsConsole");
                         Event.SetupStage[_steamId] = 4;
                         SdtdConsole.Instance.Output(string.Format("The spawn position for team {0} has been set to {1} {2} {3}.", _count, x, y, z));
                         SdtdConsole.Instance.Output("Stand where you would like the respawn for team 1 if they die during the event, then type event save.");
                         return;
                     }
                     else
                     {
                         _sql = string.Format("INSERT INTO EventSpawns (eventid, eventTeam, eventSpawn) VALUES ({0}, {1}, '{2}')", _eventid, _count, _pos);
                         SQL.FastQuery(_sql, "EventCommandsConsole");
                         SdtdConsole.Instance.Output(string.Format("The spawn position for team {0} has been set to {1} {2} {3}.", _count, x, y, z));
                         SdtdConsole.Instance.Output(string.Format("Stand where you would like the spawn for team {0} when the event starts and type event save.", _count + 1));
                         return;
                     }
                 }
                 else if (_stage == 4)
                 {
                     EntityPlayer _player    = GameManager.Instance.World.Players.dict[_entityId];
                     Vector3      _position  = _player.GetPosition();
                     int          x          = (int)_position.x;
                     int          y          = (int)_position.y;
                     int          z          = (int)_position.z;
                     string       _sposition = x + "," + y + "," + z;
                     string       _sql       = string.Format("SELECT eventid, eventTeams FROM Events WHERE eventAdmin = '{0}' AND eventName = '{1}'", _steamId, _eventName);
                     DataTable    _result1   = SQL.TQuery(_sql);
                     int          _eventid;
                     int.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid);
                     int _eventTeams;
                     int.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _eventTeams);
                     _result1.Dispose();
                     _sql = string.Format("SELECT eventRespawn FROM EventSpawns WHERE eventid = {0} AND eventRespawn != null", _eventid);
                     DataTable _result2 = SQL.TQuery(_sql);
                     int       _count   = _result2.Rows.Count + 1;
                     _result2.Dispose();
                     string _pos = SQL.EscapeString(_sposition);
                     if (_count == _eventTeams)
                     {
                         _sql = string.Format("INSERT INTO EventSpawns (eventid, eventTeam, eventRespawn) VALUES ({0}, {1}, '{2}')", _eventid, _count, _pos);
                         SQL.FastQuery(_sql, "EventCommandsConsole");
                         Event.SetupStage[_steamId] = 5;
                         SdtdConsole.Instance.Output(string.Format("The respawn position for team {0} has been set to {1} {2} {3}.", _count, x, y, z));
                         SdtdConsole.Instance.Output("Setup is complete. Type event start to send out the invitation to players.");
                         return;
                     }
                     else
                     {
                         _sql = string.Format("INSERT INTO EventSpawns (eventid, eventTeam, eventRespawn) VALUES ({0}, {1}, '{2}')", _eventid, _count, _pos);
                         SQL.FastQuery(_sql, "EventCommandsConsole");
                         SdtdConsole.Instance.Output(string.Format("The respawn position for team {0} has been set to {1} {2} {3}.", _count, x, y, z));
                         SdtdConsole.Instance.Output(string.Format("Stand where you would like the respawn for team {0} when the event starts and type event save.", _count + 1));
                         return;
                     }
                 }
                 else
                 {
                     SdtdConsole.Instance.Output("This command is invalid at this stage of setup.");
                     return;
                 }
             }
         }
         else if (_params[0].ToLower() == ("check"))
         {
             if (Event.Open)
             {
                 if (Event.Admin == _steamId)
                 {
                     string    _sql         = string.Format("SELECT eventName, eventInvite, eventTeams, eventPlayerCount, eventTime FROM Events WHERE eventAdmin = '{0}' AND eventActive = 'true'", Event.Admin);
                     DataTable _result      = SQL.TQuery(_sql);
                     string    _eventName   = _result.Rows[0].ItemArray.GetValue(0).ToString();
                     string    _eventInvite = _result.Rows[0].ItemArray.GetValue(1).ToString();
                     int       _eventTeams;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _eventTeams);
                     int _eventPlayerCount;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _eventPlayerCount);
                     int _eventTime;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(4).ToString(), out _eventTime);
                     _result.Dispose();
                     SdtdConsole.Instance.Output(string.Format("Event: {0}", _eventName));
                     SdtdConsole.Instance.Output(string.Format("Invitation: {0}", _eventInvite));
                     SdtdConsole.Instance.Output(string.Format("Info: Teams {0}, Players {1}, Time {2} minutes.", _eventTeams, _eventPlayerCount, _eventTime));
                     foreach (var _player in Event.PlayersTeam)
                     {
                         ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_player.Key);
                         if (_cInfo != null)
                         {
                             int _team;
                             Event.PlayersTeam.TryGetValue(_player.Key, out _team);
                             SdtdConsole.Instance.Output(string.Format("Player name {0}, Id {1}, is on team {2}.", _cInfo.playerName, _cInfo.playerId, _team));
                         }
                         else
                         {
                             int _team;
                             Event.PlayersTeam.TryGetValue(_player.Key, out _team);
                             SdtdConsole.Instance.Output(string.Format("Offline player: Player name unknown, Id {0}, is on team {1}.", _player.Key, _team));
                         }
                     }
                     return;
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("You are not the organizer for this event. Contact {0}.", Event.Admin));
                     return;
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output("There is no event open.");
                 return;
             }
         }
         else if (_params[0].ToLower() == ("cancel"))
         {
             if (Event.Admin == _steamId)
             {
                 if (Event.Open)
                 {
                     if (!Event.Cancel)
                     {
                         Event.Cancel = true;
                         SdtdConsole.Instance.Output("Are you sure you want to cancel the current event? Type event cancel again to stop the event.");
                         return;
                     }
                     else
                     {
                         Event.SetupStage.Remove(_steamId);
                         Event.SetupName.Remove(_steamId);
                         foreach (var _player in Event.PlayersTeam)
                         {
                             ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_player.Key);
                             if (_cInfo != null)
                             {
                                 EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                                 if (_player2.IsSpawned())
                                 {
                                     string    _sql      = string.Format("SELECT eventReturn FROM Players WHERE steamid = '{0}'", _steamId);
                                     DataTable _result   = SQL.TQuery(_sql);
                                     string    _position = _result.Rows[0].ItemArray.GetValue(0).ToString();
                                     _result.Dispose();
                                     int      x, y, z;
                                     string[] _cords = _position.Split(',');
                                     int.TryParse(_cords[0], out x);
                                     int.TryParse(_cords[1], out y);
                                     int.TryParse(_cords[2], out z);
                                     _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(x, y, z), null, false));
                                     Event.PlayersTeam.Remove(_player.Key);
                                     ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", the event has ended. Thank you for playing.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                 }
                                 else
                                 {
                                     string _sql = string.Format("UPDATE Players SET return = 'true' WHERE steamid = '{0}'", _steamId);
                                     SQL.FastQuery(_sql, "EventCommandsConsole");
                                     Event.PlayersTeam.Remove(_player.Key);
                                     SdtdConsole.Instance.Output(string.Format("Player with Id {0} was not spawned but they have been removed from the event and set to go back to their return point.", _player.Key));
                                 }
                             }
                             else
                             {
                                 string _sql = string.Format("UPDATE Players SET return = 'true' WHERE steamid = '{0}'", _steamId);
                                 SQL.FastQuery(_sql, "EventCommandsConsole");
                                 Event.PlayersTeam.Remove(_player.Key);
                                 SdtdConsole.Instance.Output(string.Format("Player with Id {0} was offline but they have been removed from the event and set to go back to their return point.", _player.Key));
                             }
                         }
                         string _sql2 = string.Format("UPDATE Events SET eventAdmin = null, eventActive = 'false' WHERE eventAdmin = '{0}'", Event.Admin);
                         SQL.FastQuery(_sql2, "EventCommandsConsole");
                         Event.Cancel = false;
                         Event.Open   = false;
                         Event.Admin  = null;
                         SdtdConsole.Instance.Output("The current event has been cancelled and event players have been sent back to their return points.");
                     }
                 }
                 else
                 {
                     if (Event.Invited)
                     {
                         Event.Invited = false;
                         Event.Admin   = null;
                         if (Event.PlayersTeam.Count > 0)
                         {
                             foreach (var _player in Event.PlayersTeam)
                             {
                                 ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_player.Key);
                                 if (_cInfo != null)
                                 {
                                     ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", the current event has been cancelled.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                 }
                                 Event.PlayersTeam.Remove(_player.Key);
                             }
                         }
                         SdtdConsole.Instance.Output("The current setup has been cancelled and all signed up players were removed.");
                         return;
                     }
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("You are not the organizer for this event. Contact {0}.", Event.Admin));
                 return;
             }
         }
         else if (_params[0].ToLower() == ("list"))
         {
             string    _sql    = string.Format("SELECT eventid, eventName, eventInvite, eventTeams, eventPlayerCount, eventTime FROM Events WHERE eventAdmin = '{0}'", _steamId);
             DataTable _result = SQL.TQuery(_sql);
             if (_result.Rows.Count > 0)
             {
                 foreach (DataRow row in _result.Rows)
                 {
                     SdtdConsole.Instance.Output(string.Format("Event Id = {0} Event Name = {1}", row[0].ToString(), row[1].ToString()));
                     SdtdConsole.Instance.Output(string.Format("Event Invite = {0}", row[2].ToString()));
                     SdtdConsole.Instance.Output(string.Format("Team Count = {0} Allowed Players = {1} Allowed Time = {2}", row[3].ToString(), row[4].ToString(), row[5].ToString()));
                     SdtdConsole.Instance.Output("-----------------------------------------------------------------------");
                     SdtdConsole.Instance.Output("-----------------------------------------------------------------------");
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output("You have no saved event data.");
             }
             _result.Dispose();
             if (Event.Open || Event.Invited)
             {
                 SdtdConsole.Instance.Output(string.Format("An event is running by admin {0}", Event.Admin));
             }
             else
             {
                 SdtdConsole.Instance.Output("Type event load <eventid> to load that event. After loading, type event start to send the invitation to players.");
             }
         }
         else if (_params[0].ToLower() == ("load"))
         {
             if (_params.Count != 2)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}.", _params.Count));
                 return;
             }
             int _id;
             if (int.TryParse(_params[1], out _id))
             {
                 string    _sql    = string.Format("SELECT eventName, eventInvite, eventTeams, eventPlayerCount, eventTime FROM Events WHERE eventAdmin = '{0}' AND eventid = {1}", _steamId, _id);
                 DataTable _result = SQL.TQuery(_sql);
                 if (_result.Rows.Count > 0)
                 {
                     string _eventName   = _result.Rows[0].ItemArray.GetValue(0).ToString();
                     string _eventInvite = _result.Rows[0].ItemArray.GetValue(1).ToString();
                     int    _eventTeams;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _eventTeams);
                     int _eventPlayerCount;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _eventPlayerCount);
                     int _eventTime;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(4).ToString(), out _eventTime);
                     _result.Dispose();
                     SdtdConsole.Instance.Output(string.Format("Event: {0}", _eventName));
                     SdtdConsole.Instance.Output(string.Format("Invitation: {0}", _eventInvite));
                     SdtdConsole.Instance.Output(string.Format("Info: Teams {0}, Players {1}, Time {2} minutes.", _eventTeams, _eventPlayerCount, _eventTime));
                     if (Event.SetupStage.ContainsKey(_steamId))
                     {
                         Event.SetupStage[_steamId] = 5;
                         Event.SetupName[_steamId]  = _eventName;
                     }
                     else
                     {
                         Event.SetupStage.Add(_steamId, 5);
                         Event.SetupName.Add(_steamId, _eventName);
                     }
                     SdtdConsole.Instance.Output(string.Format("Event id: {0} has been loaded. Type event start to send the invitation out to players.", _id));
                     return;
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Could not find this event id: {0}", _id));
                     return;
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("Invalid integer: {0}.", _params[1]));
                 return;
             }
         }
         else if (_params[0].ToLower() == ("extend"))
         {
             if (Event.Admin == _steamId)
             {
                 if (Event.Open)
                 {
                     if (Event.Extend)
                     {
                         Event.Extend = false;
                         int _time;
                         if (int.TryParse(_params[1], out _time))
                         {
                             int _addTime = Timers._eventTime + (_time * 60);
                             Timers._eventTime = _addTime;
                             SdtdConsole.Instance.Output(string.Format("The event time was extended {0} minutes.", _time));
                             return;
                         }
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("The event can only be extended while five minutes remain in the event. Wait for an alert before using the command."));
                         return;
                     }
                 }
                 else
                 {
                     SdtdConsole.Instance.Output("There is no event open to extend in time.");
                     return;
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("You are not the organizer for this event. Contact {0}.", Event.Admin));
                 return;
             }
         }
         else if (_params[0].ToLower() == ("remove"))
         {
             if (Event.Admin == _steamId)
             {
                 if (Event.Open)
                 {
                     if (Event.PlayersTeam.ContainsKey(_params[1]))
                     {
                         ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_params[1]);
                         if (_cInfo != null)
                         {
                             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                             if (_player.IsSpawned())
                             {
                                 string    _sql      = string.Format("SELECT eventReturn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                                 DataTable _result   = SQL.TQuery(_sql);
                                 string    _position = _result.Rows[0].ItemArray.GetValue(0).ToString();
                                 _result.Dispose();
                                 int      x, y, z;
                                 string[] _cords = _position.Split(',');
                                 int.TryParse(_cords[0], out x);
                                 int.TryParse(_cords[1], out y);
                                 int.TryParse(_cords[2], out z);
                                 _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(x, y, z), null, false));
                                 _sql = string.Format("UPDATE Players SET eventReturn = 'Unknown', eventSpawn = 'false', eventRespawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                 SQL.FastQuery(_sql, "EventCommandsConsole");
                                 Event.PlayersTeam.Remove(_params[1]);
                                 ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you have been removed from the event and sent to your return point.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                 SdtdConsole.Instance.Output(string.Format("Player with Id {0} was removed from the event and sent to their return point.", _params[1]));
                                 return;
                             }
                             else
                             {
                                 string _sql = string.Format("UPDATE Players SET return = 'true', eventSpawn = 'false', eventRespawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                 SQL.FastQuery(_sql, "EventCommandsConsole");
                                 Event.PlayersTeam.Remove(_params[1]);
                                 SdtdConsole.Instance.Output(string.Format("Player with Id {0} was not spawned but they were removed from the event and set to return to their return point.", _params[1]));
                             }
                         }
                         else
                         {
                             string _sql = string.Format("UPDATE Players SET return = 'true', eventSpawn = 'false', eventRespawn = 'false' WHERE steamid = '{0}'", _params[1]);
                             SQL.FastQuery(_sql, "EventCommandsConsole");
                             Event.PlayersTeam.Remove(_params[1]);
                             SdtdConsole.Instance.Output(string.Format("Player with Id {0} was offline but they have been removed from the event and set to return to their return point.", _params[1]));
                             return;
                         }
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("Invalid Id: {0}. They are not signed up for the event.", _params[1]));
                         return;
                     }
                 }
                 else
                 {
                     SdtdConsole.Instance.Output("There is no event open.");
                     return;
                 }
             }
         }
         else if (_params[0].ToLower() == ("start"))
         {
             if (!Event.Invited)
             {
                 if (Event.SetupStage.ContainsKey(_steamId))
                 {
                     int _stage;
                     if (Event.SetupStage.TryGetValue(_steamId, out _stage))
                     {
                         string _eventName;
                         if (Event.SetupName.TryGetValue(_steamId, out _eventName))
                         {
                             if (_stage == 5)
                             {
                                 if (!Event.Open)
                                 {
                                     Event.Invited = true;
                                     Event.Admin   = _steamId;
                                     Event.SetupStage.Remove(_steamId);
                                     Event.SetupName.Remove(_steamId);
                                     string    _sql    = string.Format("SELECT eventid, eventInvite FROM Events WHERE eventAdmin = '{0}' AND eventName = '{1}'", _steamId, _eventName);
                                     DataTable _result = SQL.TQuery(_sql);
                                     int       _eventid;
                                     int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid);
                                     string _eventInvite = _result.Rows[0].ItemArray.GetValue(1).ToString();
                                     _result.Dispose();
                                     _sql = string.Format("UPDATE Events SET eventActive = 'true' WHERE eventid = {0} AND eventAdmin = '{1}'", _eventid, _steamId);
                                     SQL.FastQuery(_sql, "EventCommandsConsole");
                                     string _msg1 = "Event: {EventName}[-]";
                                     string _msg2 = _eventInvite;
                                     string _msg3 = "Type /event if you want to join the event. You will return to where you are when it ends.[-]";
                                     _msg1 = _msg1.Replace("{EventName}", _eventName);
                                     ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _msg1, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                                     ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _msg2, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                                     ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _msg3, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                                 }
                                 else
                                 {
                                     SdtdConsole.Instance.Output("The event has already started.");
                                     return;
                                 }
                             }
                             else
                             {
                                 SdtdConsole.Instance.Output("This command is invalid at this stage of setup.");
                                 return;
                             }
                         }
                     }
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output("There is an event invitation open already.");
                 return;
             }
         }
         else if (_params[0].ToLower() == ("delete") || _params[0].ToLower() == ("del"))
         {
             int _id;
             if (int.TryParse(_params[1], out _id))
             {
                 string    _sql    = string.Format("SELECT eventid FROM Events WHERE eventAdmin = '{0}'", _steamId);
                 DataTable _result = SQL.TQuery(_sql);
                 if (_result.Rows.Count > 0)
                 {
                     _sql = string.Format("Delete FROM Events WHERE eventid = {0}", _id);
                     SQL.FastQuery(_sql, "EventCommandsConsole");
                     _sql = string.Format("Delete FROM EventSpawns WHERE eventid = {0}", _id);
                     SQL.FastQuery(_sql, "EventCommandsConsole");
                     SdtdConsole.Instance.Output(string.Format("Deleted the event with id: {0}.", _id));
                     return;
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Invalid integer: {0}. This id is not attached to you. Can not delete it.", _params[1]));
                 }
                 _result.Dispose();
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("Invalid integer: {0}.", _params[1]));
                 return;
             }
         }
         else
         {
             if (Event.SetupStage.ContainsKey(_steamId))
             {
                 int _stage;
                 if (Event.SetupStage.TryGetValue(_steamId, out _stage))
                 {
                     string _eventName;
                     if (Event.SetupName.TryGetValue(_steamId, out _eventName))
                     {
                         if (_stage == 1)
                         {
                             string _invite = SQL.EscapeString(_params[0]);
                             string _sql    = string.Format("UPDATE Events SET eventInvite = '{0}' WHERE eventAdmin = '{1}' AND eventName = '{2}'", _invite, _steamId, _eventName);
                             SQL.FastQuery(_sql, "EventCommandsConsole");
                             Event.SetupStage[_steamId] = 2;
                             SdtdConsole.Instance.Output(string.Format("The event invitation has been set to {0}.", _params[0]));
                             SdtdConsole.Instance.Output("How many teams, total players, and time in minutes will the event last? Type event <TeamCount> <TotalPlayers> <TimeInMin>.");
                             return;
                         }
                         else if (_stage == 2)
                         {
                             if (_params.Count == 3)
                             {
                                 int _teamCount;
                                 if (int.TryParse(_params[0], out _teamCount))
                                 {
                                     if (_teamCount < 1)
                                     {
                                         _teamCount = 1;
                                     }
                                     int _playerCount;
                                     if (int.TryParse(_params[1], out _playerCount))
                                     {
                                         if (_playerCount < 1)
                                         {
                                             _playerCount = 1;
                                         }
                                         int _eventTime;
                                         if (int.TryParse(_params[2], out _eventTime))
                                         {
                                             if (_eventTime < 1)
                                             {
                                                 _eventTime = 1;
                                             }
                                             string _sql = string.Format("UPDATE Events SET eventTeams = {0}, eventPlayerCount = {1}, eventTime = {2} WHERE eventAdmin = '{3}' AND eventName = '{4}'", _teamCount, _playerCount, _eventTime, _steamId, _eventName);
                                             SQL.FastQuery(_sql, "EventCommandsConsole");
                                             Event.SetupStage[_steamId] = 3;
                                             SdtdConsole.Instance.Output(string.Format("The event info has been set: team count {0}, total players {1}, event time {2}.", _teamCount, _playerCount, _eventTime));
                                             if (_teamCount == 1)
                                             {
                                                 SdtdConsole.Instance.Output("Stand where you would like players to spawn when the event starts and type event save.");
                                                 return;
                                             }
                                             else
                                             {
                                                 SdtdConsole.Instance.Output("Stand where you would like the team 1 to spawn when the event starts and type event save.");
                                                 return;
                                             }
                                         }
                                     }
                                 }
                             }
                             else
                             {
                                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 3, found {0}.", _params.Count));
                                 return;
                             }
                         }
                     }
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output("You have no event being setup. Setup a new one by typing event new <EventName>.");
                 return;
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in EventCommandsConsole.Run: {0}.", e));
     }
 }
Ejemplo n.º 23
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();
            }
        }
Ejemplo n.º 24
0
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params.Count < 1 || _params.Count > 2)
         {
             SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1 or 2, found {0}", _params.Count));
             return;
         }
         if (_params[0].ToLower().Equals("off"))
         {
             VoteReward.IsEnabled = false;
             LoadConfig.WriteXml();
             SdtdConsole.Instance.Output(string.Format("Vote reward has been set to off"));
             return;
         }
         else if (_params[0].ToLower().Equals("on"))
         {
             VoteReward.IsEnabled = true;
             LoadConfig.WriteXml();
             SdtdConsole.Instance.Output(string.Format("Vote reward has been set to on"));
             return;
         }
         else if (_params[0].ToLower().Equals("reset"))
         {
             if (_params.Count != 2)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}", _params.Count));
                 return;
             }
             if (_params[1].ToLower().Equals("online"))
             {
                 List <ClientInfo> ClientInfoList = ConnectionManager.Instance.Clients.List.ToList();
                 for (int i = 0; i < ClientInfoList.Count; i++)
                 {
                     ClientInfo _cInfo2 = ClientInfoList[i];
                     if (_cInfo2 != null)
                     {
                         string    _sql    = string.Format("SELECT lastVoteReward FROM Players WHERE steamid = '{0}'", _cInfo2.playerId);
                         DataTable _result = SQL.TQuery(_sql);
                         if (_result.Rows.Count != 0)
                         {
                             DateTime _lastVoteReward;
                             DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastVoteReward);
                             if (_lastVoteReward.ToString() != "10/29/2000 7:30:00 AM")
                             {
                                 _sql = string.Format("UPDATE Players SET lastVoteReward = '10/29/2000 7:30:00 AM' WHERE steamid = '{0}'", _cInfo2.playerId);
                                 SQL.FastQuery(_sql, "VoteConsole");
                                 SdtdConsole.Instance.Output(string.Format("Vote reward delay reset for {0}.", _cInfo2.playerName));
                             }
                             else
                             {
                                 SdtdConsole.Instance.Output(string.Format("Player named {0} does not have a vote reward delay that requires reset.", _cInfo2.playerName));
                             }
                         }
                     }
                 }
                 return;
             }
             if (_params[1].ToLower().Equals("all"))
             {
                 string _sql = string.Format("UPDATE Players SET lastVoteReward = '10/29/2000 7:30:00 AM' WHERE lastVoteReward != '10/29/2000 7:30:00 AM'");
                 SQL.FastQuery(_sql, "VoteConsole");
                 return;
             }
             ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]);
             if (_cInfo != null)
             {
                 string    _sql    = string.Format("SELECT lastVoteReward FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                 DataTable _result = SQL.TQuery(_sql);
                 if (_result.Rows.Count != 0)
                 {
                     DateTime _lastVoteReward;
                     DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastVoteReward);
                     if (_lastVoteReward.ToString() != "10/29/2000 7:30:00 AM")
                     {
                         _sql = string.Format("UPDATE Players SET lastVoteReward = '10/29/2000 7:30:00 AM' WHERE steamid = '{0}'", _cInfo.playerId);
                         SQL.FastQuery(_sql, "VoteConsole");
                         SdtdConsole.Instance.Output("Vote reward delay reset.");
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a vote reward delay that requires reset.", _params[1]));
                     }
                 }
                 _result.Dispose();
             }
             else
             {
                 if (_params[1].Length != 17)
                 {
                     SdtdConsole.Instance.Output(string.Format("Can not reset Id: Invalid Id {0}", _params[1]));
                     return;
                 }
                 string    _id     = SQL.EscapeString(_params[1]);
                 string    _sql    = string.Format("SELECT lastVoteReward FROM Players WHERE steamid = '{0}'", _id);
                 DataTable _result = SQL.TQuery(_sql);
                 if (_result.Rows.Count != 0)
                 {
                     DateTime _lastVoteReward;
                     DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastVoteReward);
                     if (_lastVoteReward.ToString() != "10/29/2000 7:30:00 AM")
                     {
                         _sql = string.Format("UPDATE Players SET lastVoteReward = '10/29/2000 7:30:00 AM' WHERE steamid = '{0}'", _id);
                         SQL.FastQuery(_sql, "VoteConsole");
                         SdtdConsole.Instance.Output("Vote reward delay reset.");
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a vote reward delay that requires reset.", _params[1]));
                     }
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a vote reward delay to reset.", _params[1]));
                 }
                 _result.Dispose();
             }
         }
         else
         {
             SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0]));
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in VotingConsole.Run: {0}.", e));
     }
 }
Ejemplo n.º 25
0
 public static void Exec(ClientInfo _cInfo, string _playerName)
 {
     if (SetMarket.Market_Position != "0,0,0")
     {
         int    x, y, z;
         string _sql;
         if (Return)
         {
             EntityPlayer _player   = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             Vector3      _position = _player.GetPosition();
             x = (int)_position.x;
             y = (int)_position.y;
             z = (int)_position.z;
             if (PvP_Check)
             {
                 if (Teleportation.PCheck(_cInfo, _player))
                 {
                     return;
                 }
             }
             if (Zombie_Check)
             {
                 if (Teleportation.ZCheck(_cInfo, _player))
                 {
                     return;
                 }
             }
             string _mposition = x + "," + y + "," + z;
             MarketPlayers.Add(_cInfo.entityId);
             _sql = string.Format("UPDATE Players SET marketReturn = '{0}' WHERE steamid = '{1}'", _mposition, _cInfo.playerId);
             SQL.FastQuery(_sql, "MarketChat");
             string _phrase561;
             if (!Phrases.Dict.TryGetValue(561, out _phrase561))
             {
                 _phrase561 = " you can go back by typing {CommandPrivate}{Command51} when you are ready to leave the market.";
             }
             _phrase561 = _phrase561.Replace("{CommandPrivate}", ChatHook.Command_Private);
             _phrase561 = _phrase561.Replace("{Command51}", MarketChat.Command51);
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase561 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
         string[] _cords = { };
         if (SetMarket.Market_Position.Contains(","))
         {
             if (SetMarket.Market_Position.Contains(" "))
             {
                 SetMarket.Market_Position.Replace(" ", "");
             }
             _cords = SetMarket.Market_Position.Split(',').ToArray();
         }
         else
         {
             _cords = SetMarket.Market_Position.Split(' ').ToArray();
         }
         int.TryParse(_cords[0], out x);
         int.TryParse(_cords[1], out y);
         int.TryParse(_cords[2], out z);
         _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(x, y, z), null, false));
         string _phrase562;
         if (!Phrases.Dict.TryGetValue(562, out _phrase562))
         {
             _phrase562 = " sent you to the market.";
         }
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase562 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         if (Wallet.IsEnabled && Command_Cost >= 1)
         {
             Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost);
         }
         _sql = string.Format("UPDATE Players SET lastMarket = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
         SQL.FastQuery(_sql, "MarketChat");
     }
     else
     {
         string _phrase563;
         if (!Phrases.Dict.TryGetValue(563, out _phrase563))
         {
             _phrase563 = " the market position is not set.";
         }
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase563 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
     }
 }
Ejemplo n.º 26
0
 private static void TeleportPlayer(ClientInfo _cInfo, bool _announce)
 {
     if (DeathTime.ContainsKey(_cInfo.entityId))
     {
         DateTime _time;
         if (DeathTime.TryGetValue(_cInfo.entityId, out _time))
         {
             TimeSpan varTime           = DateTime.Now - _time;
             double   fractionalMinutes = varTime.TotalMinutes;
             int      _timepassed       = (int)fractionalMinutes;
             if (ReservedSlots.IsEnabled && ReservedSlots.Reduced_Delay)
             {
                 if (ReservedSlots.Dict.ContainsKey(_cInfo.playerId))
                 {
                     DateTime _dt;
                     ReservedSlots.Dict.TryGetValue(_cInfo.playerId, out _dt);
                     if (DateTime.Now > _dt)
                     {
                         int _newTime = _timepassed / 2;
                         _timepassed = _newTime;
                     }
                 }
             }
             if (_timepassed < 2)
             {
                 string _value;
                 if (LastDeathPos.TryGetValue(_cInfo.entityId, out _value))
                 {
                     int      x, y, z;
                     string[] _cords = _value.Split(',');
                     int.TryParse(_cords[0], out x);
                     int.TryParse(_cords[1], out y);
                     int.TryParse(_cords[2], out z);
                     _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(x, y, z), null, false));
                     LastDeathPos.Remove(_cInfo.entityId);
                     string _sql;
                     if (Wallet.IsEnabled && Command_Cost >= 1)
                     {
                         Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost);
                     }
                     _sql = string.Format("UPDATE Players SET lastDied = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
                     SQL.FastQuery(_sql, "DeathSpot");
                     string _phrase736;
                     if (!Phrases.Dict.TryGetValue(736, out _phrase736))
                     {
                         _phrase736 = " teleporting you to your last death position. You can use this again in {DelayBetweenUses} minutes.";
                     }
                     _phrase736 = _phrase736.Replace("{DelayBetweenUses}", Delay_Between_Uses.ToString());
                     if (_announce)
                     {
                         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase736 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null);
                     }
                     else
                     {
                         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase736 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
             }
             else
             {
                 ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " your last death occurred too long ago. Command unavailable.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
             }
         }
     }
     else
     {
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " you have no death position. Die first.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
     }
 }
Ejemplo n.º 27
0
 public void PlayerDisconnected(ClientInfo _cInfo, bool _bShutdown)
 {
     if (_cInfo != null)
     {
         if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId))
         {
             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             if (_player != null)
             {
                 string _sql = string.Format("UPDATE Players SET zkills = {0}, kills = {1}, deaths = {2} WHERE steamid = '{3}'", XUiM_Player.GetZombieKills(_player), XUiM_Player.GetPlayerKills(_player), XUiM_Player.GetDeaths(_player), _cInfo.playerId);
                 SQL.FastQuery(_sql);
                 if (Wallet.IsEnabled)
                 {
                     int _currentCoins = Wallet.GetcurrentCoins(_cInfo);
                     _sql = string.Format("UPDATE Players SET wallet = {0} WHERE steamid = '{1}'", _currentCoins, _cInfo.playerId);
                     SQL.FastQuery(_sql);
                 }
             }
         }
         if (HatchElevator.LastPositionY.ContainsKey(_cInfo.entityId))
         {
             HatchElevator.LastPositionY.Remove(_cInfo.entityId);
         }
         if (FriendTeleport.Dict.ContainsKey(_cInfo.entityId))
         {
             FriendTeleport.Dict.Remove(_cInfo.entityId);
             FriendTeleport.Dict1.Remove(_cInfo.entityId);
         }
         if (Players.ZoneExit.ContainsKey(_cInfo.entityId))
         {
             Players.ZoneExit.Remove(_cInfo.entityId);
             Players.Forgive.Remove(_cInfo.entityId);
             Players.Victim.Remove(_cInfo.entityId);
         }
         if (FlightCheck.Flag.ContainsKey(_cInfo.entityId))
         {
             FlightCheck.Flag.Remove(_cInfo.entityId);
         }
         if (FlightCheck.fLastPositionXZ.ContainsKey(_cInfo.entityId))
         {
             FlightCheck.fLastPositionXZ.Remove(_cInfo.entityId);
         }
         if (FlightCheck.fLastPositionY.ContainsKey(_cInfo.entityId))
         {
             FlightCheck.fLastPositionY.Remove(_cInfo.entityId);
         }
         if (FriendTeleport.Dict.ContainsKey(_cInfo.entityId))
         {
             FriendTeleport.Dict.Remove(_cInfo.entityId);
         }
         if (FriendTeleport.Dict1.ContainsKey(_cInfo.entityId))
         {
             FriendTeleport.Dict1.Remove(_cInfo.entityId);
         }
         if (Travel.Flag.Contains(_cInfo.entityId))
         {
             Travel.Flag.Remove(_cInfo.entityId);
         }
         if (UndergroundCheck.Flag.ContainsKey(_cInfo.entityId))
         {
             UndergroundCheck.Flag.Remove(_cInfo.entityId);
         }
         if (UndergroundCheck.uLastPositionXZ.ContainsKey(_cInfo.entityId))
         {
             UndergroundCheck.uLastPositionXZ.Remove(_cInfo.entityId);
         }
         if (Wallet.IsEnabled)
         {
             string    _sql2    = string.Format("SELECT steamid FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
             DataTable _result2 = SQL.TQuery(_sql2);
             if (_result2.Rows.Count > 0)
             {
                 DateTime _time;
                 if (Players.Session.TryGetValue(_cInfo.playerId, out _time))
                 {
                     TimeSpan varTime           = DateTime.Now - _time;
                     double   fractionalMinutes = varTime.TotalMinutes;
                     int      _timepassed       = (int)fractionalMinutes;
                     if (_timepassed > 60)
                     {
                         int _hours = _timepassed / 60 * 10;
                         Wallet.AddCoinsToWallet(_cInfo.playerId, _hours);
                     }
                     string    _sql1    = string.Format("SELECT sessionTime FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                     DataTable _result1 = SQL.TQuery(_sql1);
                     int       _sessionTime;
                     int.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _sessionTime);
                     _result1.Dispose();
                     _sql1 = string.Format("UPDATE Players SET sessionTime = {0} WHERE steamid = '{1}'", _sessionTime + _timepassed, _cInfo.playerId);
                     SQL.FastQuery(_sql1);
                 }
             }
             _result2.Dispose();
         }
         if (Players.Session.ContainsKey(_cInfo.playerId))
         {
             Players.Session.Remove(_cInfo.playerId);
         }
         if (Bank.TransferId.ContainsKey(_cInfo.playerId))
         {
             Bank.TransferId.Remove(_cInfo.playerId);
         }
         if (Zones.reminder.ContainsKey(_cInfo.entityId))
         {
             Zones.reminder.Remove(_cInfo.entityId);
         }
     }
 }
Ejemplo n.º 28
0
 public static void Remove(ClientInfo _cInfo, string _playerName)
 {
     if (IsEnabled)
     {
         if (!GameManager.Instance.adminTools.CommandAllowedFor(_cmd, _cInfo.playerId))
         {
             string _phrase107;
             if (!Phrases.Dict.TryGetValue(107, out _phrase107))
             {
                 _phrase107 = " you do not have permissions to use this command.";
             }
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase107 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
         else
         {
             _playerName = _playerName.Replace("unmute ", "");
             ClientInfo _PlayertoUnMute = ConsoleHelper.ParseParamIdOrName(_playerName);
             if (_PlayertoUnMute == null)
             {
                 string _phrase201;
                 if (!Phrases.Dict.TryGetValue(201, out _phrase201))
                 {
                     _phrase201 = " player {PlayerName} was not found online.";
                 }
                 _phrase201 = _phrase201.Replace("{PlayerName}", _playerName);
                 ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase201 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
             }
             else
             {
                 string    _sql    = string.Format("SELECT muteTime FROM Players WHERE steamid = '{0}'", _PlayertoUnMute.playerId);
                 DataTable _result = SQL.TQuery(_sql);
                 int       _muteTime;
                 int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _muteTime);
                 _result.Dispose();
                 if (_muteTime == 0)
                 {
                     string _phrase204;
                     if (!Phrases.Dict.TryGetValue(204, out _phrase204))
                     {
                         _phrase204 = " player {PlayerName} is not muted.";
                     }
                     _phrase204 = _phrase204.Replace("{PlayerName}", _playerName);
                     ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase204 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
                 else
                 {
                     if (!Mutes.Contains(_PlayertoUnMute.playerId))
                     {
                         string _phrase204;
                         if (!Phrases.Dict.TryGetValue(204, out _phrase204))
                         {
                             _phrase204 = " player {PlayerName} is not muted.";
                         }
                         _phrase204 = _phrase204.Replace("{PlayerName}", _playerName);
                         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase204 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     }
                     else
                     {
                         Mutes.Remove(_PlayertoUnMute.playerId);
                         _sql = string.Format("UPDATE Players SET muteTime = 0 WHERE steamid = '{0}'", _PlayertoUnMute.playerId);
                         SQL.FastQuery(_sql);
                         string _phrase205;
                         if (!Phrases.Dict.TryGetValue(205, out _phrase205))
                         {
                             _phrase205 = " you have unmuted {PlayerName}.";
                         }
                         _phrase205 = _phrase205.Replace("{PlayerName}", _playerName);
                         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase205 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
             }
         }
     }
     else
     {
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + " this command is not enabled.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
     }
 }
Ejemplo n.º 29
0
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params.Count != 1)
         {
             SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, found {0}", _params.Count));
             return;
         }
         ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[0]);
         if (_cInfo != null)
         {
             string    _filepath  = string.Format("{0}/Player/{1}.map", GameUtils.GetSaveGameDir(), _cInfo.playerId);
             string    _filepath1 = string.Format("{0}/Player/{1}.ttp", GameUtils.GetSaveGameDir(), _cInfo.playerId);
             string    _sql       = string.Format("SELECT steamid FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
             DataTable _result    = SQL.TQuery(_sql);
             if (_result.Rows.Count != 0)
             {
                 string _phrase400;
                 if (!Phrases.Dict.TryGetValue(400, out _phrase400))
                 {
                     _phrase400 = "Reseting players profile.";
                 }
                 SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.entityId, _phrase400), _cInfo);
                 if (!File.Exists(_filepath))
                 {
                     SdtdConsole.Instance.Output(string.Format("Could not find file {0}.map", _params[0]));
                 }
                 else
                 {
                     File.Delete(_filepath);
                 }
                 if (!File.Exists(_filepath1))
                 {
                     SdtdConsole.Instance.Output(string.Format("Could not find file {0}.ttp", _params[0]));
                 }
                 else
                 {
                     File.Delete(_filepath1);
                 }
                 _sql = string.Format("UPDATE Players SET playername = 'Unknown', last_gimme = '10/29/2000 7:30:00 AM', lastkillme = '10/29/2000 7:30:00 AM', playerSpentCoins = 0, sessionTime = 0, bikeId = 0, lastBike = '10/29/2000 7:30:00 AM', jailName = 'Unknown', jailDate = '10/29/2000 7:30:00 AM', muteName = 'Unknown', muteDate = '10/29/2000 7:30:00 AM', lobbyReturn = 'Unknown', newTeleSpawn = 'Unknown', homeposition = 'Unknown', homeposition2 = 'Unknown', lastsethome = '10/29/2000 7:30:00 AM', lastwhisper = 'Unknown', lastStuck = '10/29/2000 7:30:00 AM', lastLobby = '10/29/2000 7:30:00 AM', lastLog = '10/29/2000 7:30:00 AM', lastBackpack = '10/29/2000 7:30:00 AM', lastFriendTele = '10/29/2000 7:30:00 AM', respawnTime = '10/29/2000 7:30:00 AM', lastTravel = '10/29/2000 7:30:00 AM', lastAnimals = '10/29/2000 7:30:00 AM', lastVoteReward = '10/29/2000 7:30:00 AM', firstClaim = 'false', ismuted = 'false', isjailed = 'false', startingItems = 'false', clanname = 'Unknown', invitedtoclan = 'Unknown', isclanowner = 'false', isclanofficer = 'false', customCommand1 = '10/29/2000 7:30:00 AM', customCommand2 = '10/29/2000 7:30:00 AM', customCommand3 = '10/29/2000 7:30:00 AM', customCommand4 = '10/29/2000 7:30:00 AM', customCommand5 = '10/29/2000 7:30:00 AM', customCommand6 = '10/29/2000 7:30:00 AM', customCommand7 = '10/29/2000 7:30:00 AM', customCommand8 = '10/29/2000 7:30:00 AM', customCommand9 = '10/29/2000 7:30:00 AM', customCommand10 = '10/29/2000 7:30:00 AM' WHERE steamid = '{0}'", _cInfo.playerId);
                 SQL.FastQuery(_sql, "ResetPlayerConsole");
                 _sql = string.Format("SELECT * FROM Auction WHERE steamid = '{0}'", _cInfo.playerId);
                 DataTable _result1 = SQL.TQuery(_sql);
                 if (_result1.Rows.Count != 0)
                 {
                     _sql = string.Format("DELETE FROM Auction WHERE steamid = '{0}'", _cInfo.playerId);
                     SQL.FastQuery(_sql, "ResetPlayerConsole");
                 }
                 _result1.Dispose();
             }
             _result.Dispose();
             string _phrase401;
             if (!Phrases.Dict.TryGetValue(401, out _phrase401))
             {
                 _phrase401 = "You have reset the profile for Player {SteamId}.";
             }
             _phrase401 = _phrase401.Replace("{SteamId}", _params[0]);
             SdtdConsole.Instance.Output(string.Format("{0}", _phrase401));
         }
         else if (_params[0].Length == 17)
         {
             string    _steamid   = SQL.EscapeString(_params[0]);
             string    _filepath  = string.Format("{0}/Player/{1}.map", GameUtils.GetSaveGameDir(), _steamid);
             string    _filepath1 = string.Format("{0}/Player/{1}.ttp", GameUtils.GetSaveGameDir(), _steamid);
             string    _sql       = string.Format("SELECT last_gimme FROM Players WHERE steamid = '{0}'", _steamid);
             DataTable _result    = SQL.TQuery(_sql);
             if (_result.Rows.Count != 0)
             {
                 if (!File.Exists(_filepath))
                 {
                     SdtdConsole.Instance.Output(string.Format("Could not find file {0}.map", _params[0]));
                 }
                 else
                 {
                     File.Delete(_filepath);
                 }
                 if (!File.Exists(_filepath1))
                 {
                     SdtdConsole.Instance.Output(string.Format("Could not find file {0}.ttp", _params[0]));
                 }
                 else
                 {
                     File.Delete(_filepath1);
                 }
                 _sql = string.Format("UPDATE Players SET playername = 'Unknown', last_gimme = '10/29/2000 7:30:00 AM', lastkillme = '10/29/2000 7:30:00 AM', playerSpentCoins = 0, sessionTime = 0, bikeId = 0, lastBike = '10/29/2000 7:30:00 AM', jailName = 'Unknown', jailDate = '10/29/2000 7:30:00 AM', muteName = 'Unknown', muteDate = '10/29/2000 7:30:00 AM', lobbyReturn = 'Unknown', newTeleSpawn = 'Unknown', homeposition = 'Unknown', homeposition2 = 'Unknown', lastsethome = '10/29/2000 7:30:00 AM', lastwhisper = 'Unknown', lastStuck = '10/29/2000 7:30:00 AM', lastLobby = '10/29/2000 7:30:00 AM', lastLog = '10/29/2000 7:30:00 AM', lastDied = '10/29/2000 7:30:00 AM', lastFriendTele = '10/29/2000 7:30:00 AM', respawnTime = '10/29/2000 7:30:00 AM', lastTravel = '10/29/2000 7:30:00 AM', lastAnimals = '10/29/2000 7:30:00 AM', lastVoteReward = '10/29/2000 7:30:00 AM', firstClaim = 'false', ismuted = 'false', isjailed = 'false', startingItems = 'false', clanname = 'Unknown', invitedtoclan = 'Unknown', isclanowner = 'false', isclanofficer = 'false', customCommand1 = '10/29/2000 7:30:00 AM', customCommand2 = '10/29/2000 7:30:00 AM', customCommand3 = '10/29/2000 7:30:00 AM', customCommand4 = '10/29/2000 7:30:00 AM', customCommand5 = '10/29/2000 7:30:00 AM', customCommand6 = '10/29/2000 7:30:00 AM', customCommand7 = '10/29/2000 7:30:00 AM', customCommand8 = '10/29/2000 7:30:00 AM', customCommand9 = '10/29/2000 7:30:00 AM', customCommand10 = '10/29/2000 7:30:00 AM' WHERE steamid = '{0}'", _steamid);
                 SQL.FastQuery(_sql, "ResetPlayerConsole");
                 _sql = string.Format("SELECT * FROM Auction WHERE steamid = '{0}'", _steamid);
                 DataTable _result1 = SQL.TQuery(_sql);
                 if (_result1.Rows.Count != 0)
                 {
                     _sql = string.Format("DELETE FROM Auction WHERE steamid = '{0}'", _steamid);
                     SQL.FastQuery(_sql, "ResetPlayerConsole");
                 }
                 _result1.Dispose();
             }
             _result.Dispose();
             string _phrase401;
             if (!Phrases.Dict.TryGetValue(401, out _phrase401))
             {
                 _phrase401 = "You have reset the profile for Player {SteamId}.";
             }
             _phrase401 = _phrase401.Replace("{SteamId}", _params[0]);
             SdtdConsole.Instance.Output(string.Format("{0}", _phrase401));
         }
         else
         {
             SdtdConsole.Instance.Output(string.Format("Player id {0} is not a valid integer", _params[0]));
             return;
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in ResetPlayerConsole.Run: {0}.", e));
     }
 }
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params.Count < 1 || _params.Count > 2)
         {
             SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1 or 2, found {0}", _params.Count));
             return;
         }
         if (_params[0].ToLower().Equals("off"))
         {
             FirstClaimBlock.IsEnabled = false;
             LoadConfig.WriteXml();
             SdtdConsole.Instance.Output(string.Format("First claim block has been set to off"));
             return;
         }
         else if (_params[0].ToLower().Equals("on"))
         {
             FirstClaimBlock.IsEnabled = true;
             LoadConfig.WriteXml();
             SdtdConsole.Instance.Output(string.Format("First claim block has been set to on"));
             return;
         }
         else if (_params[0].ToLower().Equals("reset"))
         {
             ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]);
             if (_cInfo != null)
             {
                 string    _sql    = string.Format("SELECT firstClaim FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                 DataTable _result = SQL.TQuery(_sql);
                 bool      _firstClaim;
                 bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _firstClaim);
                 _result.Dispose();
                 if (_firstClaim)
                 {
                     _sql = string.Format("UPDATE Players SET firstClaim = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                     SQL.FastQuery(_sql, "FirstClaimBlockConsole");
                     SdtdConsole.Instance.Output("Players first claim block reset.");
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a first claim block to reset.", _params[1]));
                 }
             }
             else if (_params[1].Length == 17)
             {
                 string    _id     = SQL.EscapeString(_params[1]);
                 string    _sql    = string.Format("SELECT firstClaim FROM Players WHERE steamid = '{0}'", _id);
                 DataTable _result = SQL.TQuery(_sql);
                 bool      _firstClaim;
                 bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _firstClaim);
                 _result.Dispose();
                 if (_firstClaim)
                 {
                     _sql = string.Format("UPDATE Players SET firstClaim = 'false' WHERE steamid = '{0}'", _id);
                     SQL.FastQuery(_sql, "FirstClaimBlockConsole");
                     SdtdConsole.Instance.Output("Players first claim block reset.");
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a first claim block to reset.", _params[1]));
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("Can not reset Id: Invalid Id {0}.", _params[1]));
             }
         }
         else
         {
             SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0]));
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in FirstClaimBlockConsole.Run: {0}.", e));
     }
 }