예제 #1
0
 internal SevenDaysLivePlayer(ClientInfo client)
 {
     this.client = client;
     steamId = Convert.ToUInt64(client.playerId);
     Character = this;
     Object = GameManager.Instance.World.Players.dict[client.entityId].transform.gameObject;
 }
예제 #2
0
 public static void CheckWatchlist(ClientInfo _cInfo)
 {
     if (Dict.ContainsKey(_cInfo.playerId))
     {
         List<ClientInfo> _cInfoList = ConnectionManager.Instance.GetClients();
         foreach (ClientInfo _cInfo1 in _cInfoList)
         {
             if (GameManager.Instance.adminTools.IsAdmin(_cInfo1.playerId))
             {
                 string _phrase350;
                 if (!Phrases.Dict.TryGetValue(350, out _phrase350))
                 {
                     _phrase350 = "Player {PlayerName} is on the watchlist for {Reason}.";
                 }
                 string _reason = null;
                 if (Dict.TryGetValue(_cInfo.playerId, out _reason))
                 {
                     _phrase350 = _phrase350.Replace("{PlayerName}", _cInfo.playerName);
                     _phrase350 = _phrase350.Replace("{Reason}", _reason);
                     _cInfo1.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("[FF8000]{0}[-]", _phrase350), "Server", false, "", false));
                 }
             }
         }
     }
 }
    public bool GetUserByTokenIDSecure(string tokenID, int connectionID, out ClientInfo client, out string detailMessage)
    {
        lock (lockTokenObject)
        {
            if (!TokenClients.TryGetValue(tokenID, out client))
            {
                detailMessage = "There is no User with TokenID: " + tokenID;
                Debug.LogWarning(detailMessage);
                return false;
            }
        }

        ClientInfo clientSecure;
        lock (lockConnectedObject)
        {
            if (!ConnectedClients.TryGetValue(connectionID, out clientSecure))
            {
                detailMessage = "No Client Connected from: " + client.ConnectionID;
                Debug.LogWarning(detailMessage);
                return false;
            }
        }
        if (!clientSecure.UserID.Equals(client.UserID))
        {
            detailMessage = "Client Connected from: " + client.ConnectionID+" is different from TokenID: " + tokenID;
            Debug.LogWarning(detailMessage);
            return false;
        }
        detailMessage = "Success";
        return true;
    }
예제 #4
0
 public static void SendAdmins(ClientInfo _sender, string _message)
 {
     if (!GameManager.Instance.adminTools.IsAdmin(_sender.playerId))
     {
         string _phrase200;
         if (!Phrases.Dict.TryGetValue(200, out _phrase200))
         {
             _phrase200 = "{PlayerName} you do not have permissions to use this command.";
         }
         _phrase200 = _phrase200.Replace("{PlayerName}", _sender.playerName);
         _sender.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", CustomCommands.ChatColor, _phrase200), "Server", false, "", false));
     }
     else
     {
         List<ClientInfo> _cInfoList = ConnectionManager.Instance.GetClients();
         foreach (ClientInfo _cInfo in _cInfoList)
         {
             if (GameManager.Instance.adminTools.IsAdmin(_cInfo.playerId))
             {
                 _message = _message.Replace("@ADMINS ", "");
                 _message = _message.Replace("@admins ", "");
                 _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("[FF0080]{0}[-]", _message), _sender.playerName, false, "", false));
             }
         }
     }
 }
예제 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        String isShowMetro = ConfigurationManager.AppSettings["ShowMetro"];
        if (String.IsNullOrEmpty(isShowMetro) || isShowMetro.ToLower() == "false")
        {
            JQMetro1.Visible = false;
            MainImg.Visible = true;
        }
        else if (isShowMetro.ToLower() == "true")
        {
            JQMetro1.Visible = true;
            MainImg.Visible = false;
        }
        var key = this.Request.QueryString["key"];
        var param = this.Request.QueryString["param"];
        if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(param))
        {
            try
            {
                var clientInfo = new ClientInfo() { SecurityKey = key, UseDataSet = true };
                EFServiceClient client = EFClientTools.ClientUtility.Client;
                clientInfo = client.LogOn(clientInfo);
                var locale = Request.UserLanguages.Length > 0 ? Request.UserLanguages[0] : "en-us";
                clientInfo.Locale = locale;
                clientInfo.LogonResult = LogonResult.Logoned;
                Session["ClientInfo"] = clientInfo;

                parameter.Value = DecryptParameters(param, key);
            }
            catch
            {
                Response.Redirect("Timeout.aspx", true);
            }
        }
    }
예제 #6
0
 void Start()
 {
     Socket sock = Sockets.CreateTCPSocket("www.myserver.com", 2345);
     client = new ClientInfo(sock, false); // Don't start receiving yet
     client.OnReadBytes += new ConnectionReadBytes(ReadData);
     client.BeginReceive();
 }
예제 #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string strFullUrl = Request.Url.ToString();
        string url = strFullUrl.Substring(strFullUrl.IndexOf("RedirectUrl") + 12);
        var publicKey = this.Request.QueryString["PublicKey"];

        if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(publicKey))
        {
            try
            {
                var clientInfo = new ClientInfo() { SecurityKey = publicKey, UseDataSet = true };
                EFServiceClient client = EFClientTools.ClientUtility.Client;
                clientInfo = client.LogOn(clientInfo);
                var locale = Request.UserLanguages.Length > 0 ? Request.UserLanguages[0] : "en-us";
                clientInfo.Locale = locale;
                clientInfo.LogonResult = LogonResult.Logoned;
                Session["ClientInfo"] = clientInfo;
                Response.Redirect(url);
            }
            catch(Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
        else
        {
            Response.Write("PublishKey is null or url is null.");
        }
    }
예제 #8
0
 public static void Execute( ClientInfo ci, byte param1, byte param2a, byte param2b )
 {
     ci.PrimaryCave[data1offset + 24] = param1;
     ci.PrimaryCave[data1offset + 28] = param2b;
     ci.PrimaryCave[data1offset + 29] = param2a;
     Memory.Write( ci.Handle, ci.CaveAddress, ci.PrimaryCave, true );
 }
예제 #9
0
 public override void PlayerLogin(ClientInfo _cInfo, string _compatibilityVersion)
 {
     if (ReservedSlots.IsEnabled)
     {
         ReservedSlots.CheckReservedSlot(_cInfo);
     }
 }
예제 #10
0
    public string LogOn(string userId, string password, string dataBase, string solution)
    {
        EFServiceClient client = EFClientTools.ClientUtility.Client;
        EFClientTools.ClientUtility.ServerIPAddress = client.GetServerIPAddress();
        var ipAddress = HttpContext.Current.Request.UserHostAddress;
        var clientInfo = new ClientInfo()
        {
            UserID = userId,
            Password = password,
            Database = dataBase,
            Solution = solution,
            IPAddress = ipAddress,
            Locale = "en-us",
            UseDataSet = true
        };
        if(clientInfo.UserID.Contains("'"))
        {
            return string.Empty;
        }
        var result = client.LogOn(clientInfo);

        client = EFClientTools.ClientUtility.Client;
        if (result.LogonResult == LogonResult.Logoned)
        {
            return result.SecurityKey;
        }
        else
        {
            return string.Empty;
        }
    }
 public static void SetLastPMSender(ClientInfo _sender, ClientInfo _receiver)
 {
     if (senderOfLastPM.ContainsKey (_receiver))
         senderOfLastPM [_receiver] = _sender;
     else
         senderOfLastPM.Add (_receiver, _sender);
 }
예제 #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var key = this.Request.QueryString["key"];
        var param = this.Request.QueryString["param"];
        if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(param))
        {
            try
            {
                var clientInfo = new ClientInfo() { SecurityKey = key, UseDataSet = true };
                EFServiceClient client = EFClientTools.ClientUtility.Client;
                clientInfo = client.LogOn(clientInfo);
                var locale = Request.UserLanguages.Length > 0 ? Request.UserLanguages[0] : "en-us";
                clientInfo.Locale = locale;
                clientInfo.LogonResult = LogonResult.Logoned;
                Session["ClientInfo"] = clientInfo;

                parameter.Value = DecryptParameters(param, key);
            }
            catch
            {
                Response.Redirect("Timeout.aspx", true);
            }
        }
        else
        {
            Response.Redirect("Timeout.aspx", true);
        }
    }
예제 #13
0
 public override void Verify(ClientInfo clientInfo)
 {
     Assert.NotNull(clientInfo);
       AssertMatch(Family,clientInfo.Device.Family,"Family");
       AssertMatch(IsMobile, clientInfo.Device.IsMobile, "IsMobile");
       AssertMatch(IsSpider, clientInfo.Device.IsSpider, "IsSpider");
 }
예제 #14
0
파일: Server.cs 프로젝트: chzh/xrefresh
 public void AddClient(int id, ClientInfo client)
 {
     lock (this)
     {
         clients[lastClientID] = client;
     }
     Context.Current.UpdateTrayIcon();
 }
예제 #15
0
 public static void GM_SavePlayerData(ClientInfo _cInfo, PlayerDataFile _playerDataFile)
 {
     try {
         PersistentContainer.Instance.Players[_cInfo.playerId, true].Update (_playerDataFile);
     } catch (Exception e) {
         Log.Out ("Error in GM_SavePlayerData: " + e);
     }
 }
예제 #16
0
 /// <summary>
 /// Send a message to the host.
 /// </summary>
 /// <param name="clientInfo">Client identifier.</param>
 /// <param name="buildMessage">Message to send.</param>
 public void SendTo(ClientInfo clientInfo, byte[] buildMessage)
 {
     lock (server)
     {
         server.SendMore(clientInfo.Id);
         server.Send(buildMessage);
     }
 }
예제 #17
0
 // Use this for initialization
 void Start()
 {
     _controller = new Controller();
     _princessHasShot = false;
     coolDownValue = 1.0f;
     currCD = 0.0f;
     this.clientInfo = this.transform.parent.GetComponent<ClientInfo>();
 }
예제 #18
0
    public override void Verify(ClientInfo clientInfo)
    {
      Assert.NotNull(clientInfo);
      AssertMatch(Family, clientInfo.UserAgent.Family, "Family");
      AssertMatch(Major, clientInfo.UserAgent.Major, "Major");
      AssertMatch(Minor, clientInfo.UserAgent.Minor, "Minor");
      AssertMatch(Patch, clientInfo.UserAgent.Patch, "Patch");

    }
 public static void CheckPing(ClientInfo _cInfo)
 {
     string _steamid = _cInfo.playerId;
     if (_cInfo.ping > MAXPING && !_whiteListPlayers.ContainsKey(_steamid))
     {
         Log.Out("Kicking (" + _cInfo.playerName + ") for high ping. (" + _cInfo.ping + ") Max is " + MAXPING + ".");
         GameManager.Instance.GameMessageServer(_cInfo, "[FF8000]Kicking (" + _cInfo.playerName + ") for high ping. (" + _cInfo.ping + ") Max is " + MAXPING + ".[-]", "Server");
         SdtdConsole.Instance.ExecuteSync("kick " + _cInfo.entityId + " \"Ping To High. Max Ping is " + MAXPING + ".\"", _cInfo);
     }
 }
예제 #20
0
 public override void PlayerSpawning(ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile)
 {
     if (Motd.IsEnabled)
     {
         Motd.Send(_cInfo);
     }
     if (ClanManager.IsEnabled)
     {
         ClanManager.CheckforClantag(_cInfo);
     }
 }
예제 #21
0
 public RedisInfo()
 {
     Replication = new ReplicationInfo();
     Clients = new ClientInfo();
     Server = new ServerInfo();
     Memory = new MemoryInfo();
     Persistence = new PersistenceInfo();
     Stats = new StatsInfo();
     CPU = new CPUInfo();
     Keyspace = new KeyspaceInfo();
 }
예제 #22
0
파일: XPlane.cs 프로젝트: TexT12/LED-stuff
        public XPlane(int port, Form1 main)
        {
            this.form1 = main;
            IPEndPoint e = new IPEndPoint(IPAddress.Any, port + 3);
            udp = new UdpClient(e);

            xplane_recv = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port);

            Console.WriteLine("Initing with port base at " + port);

            clientInfo = new ClientInfo(udp, e);
        }
예제 #23
0
        public static void TeleHome(ClientInfo _cInfo)
        {
            Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false];
            if (p == null || p.HomePosition == null)
            {
                string _phrase11;
                if (!Phrases.Dict.TryGetValue(11, out _phrase11))
                {
                    _phrase11 = "{PlayerName} you do not have a home saved.";
                }
                _phrase11 = _phrase11.Replace("{PlayerName}", _cInfo.playerName);
                _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{1}{0}[-]", _phrase11, CustomCommands.ChatColor), "Server", false, "", false));
            }
            else
            {
                if (DelayBetweenUses < 1)
                {
                    Home(_cInfo, p.HomePosition);
                }
                else
                {
                    if (p.LastSetHome == null)
                    {
                        Home(_cInfo, p.HomePosition);
                    }
                    else
                    {
                        TimeSpan varTime = DateTime.Now - p.LastSetHome;
                        double fractionalMinutes = varTime.TotalMinutes;
                        int _timepassed = (int)fractionalMinutes;
                        if (_timepassed > DelayBetweenUses)
                        {
                            Home(_cInfo, p.HomePosition);
                        }
                        else
                        {
                            int _timeleft = DelayBetweenUses - _timepassed;
                            string _phrase13;
                            if (!Phrases.Dict.TryGetValue(13, out _phrase13))
                            {
                                _phrase13 = "{PlayerName} you can only use /home once every {DelayBetweenUses} minutes. Time remaining: {TimeRemaining} minutes.";
                            }
                            _phrase13 = _phrase13.Replace("{PlayerName}", _cInfo.playerName);
                            _phrase13 = _phrase13.Replace("{DelayBetweenUses}", DelayBetweenUses.ToString());
                            _phrase13 = _phrase13.Replace("{TimeRemaining}", _timeleft.ToString());
                            _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{1}{0}[-]", _phrase13, CustomCommands.ChatColor), "Server", false, "", false));

                        }
                    }
                }
            }
        }
예제 #24
0
 public static void SendMessage(ClientInfo _receiver, string senderName, string teamName, string _message)
 {
     if (senderName != null && teamName != null && _message != null) {
         _receiver.SendPackage (new NetPackageGameMessage (_message, "[00ffff]" + senderName + " (" + teamName + ")[-]"));
         string receiverName = _receiver.playerName;
         string[] strArrays = new string[] { "Message to player ", null, null, null, null };
         strArrays[1] = (receiverName == null ? "unknownName" : string.Concat("\"", receiverName, "\""));
         strArrays[2] = " sent with sender \"";
         strArrays[3] = senderName;
         strArrays[4] = "\"";
         SdtdConsole.Instance.Output(string.Concat(strArrays));
     }
 }
예제 #25
0
 private async void ReportNewSession(ClientInfo client)
 {
     try
     {
         await new UsageReporter(_applicationHost, _networkManager, _httpClient)
             .ReportAppUsage(client, CancellationToken.None)
             .ConfigureAwait(false);
     }
     catch (Exception ex)
     {
         _logger.ErrorException("Error sending anonymous usage statistics.", ex);
     }
 }
예제 #26
0
        public static void Execute( ClientInfo ci, byte param1, byte param2, string param3 )
        {
            ci.PrimaryCave[data1offset + 24] = param1;
            ci.PrimaryCave[data1offset + 28] = param2;
            byte[] data2Address = BitConverter.GetBytes( ci.CaveAddress.ToInt32() + data2offset );
            Buffer.BlockCopy( data2Address, 0, ci.PrimaryCave, data1offset + 32, 4 );
            byte[] unicodeBytes = UnicodeEncoding.Unicode.GetBytes( param3 );

            if (unicodeBytes.Length > 256) Buffer.BlockCopy( unicodeBytes, 0, ci.PrimaryCave, data2offset, 256 );
            else Buffer.BlockCopy( unicodeBytes, 0, ci.PrimaryCave, data2offset, unicodeBytes.Length );
            Memory.Write( ci.Handle, ci.CaveAddress, ci.PrimaryCave, true );
            Buffer.BlockCopy( emptyArray, 0, ci.PrimaryCave, data2offset, 256 );  // clear previous data
        }
 private bool Invoke(Action<IWcfClientSide> asyncResult, ClientInfo ci)
 {
     var suc = false;
     try
     {
         asyncResult(ci.Client);
         suc = true;
     }
     catch (System.ServiceModel.CommunicationObjectAbortedException e)
     {
     }
     return suc;
 }
 public static void PlayerDisconnected(ClientInfo _cInfo, bool _bShutdown)
 {
     try {
         Player p = PersistentContainer.Instance.Players [_cInfo.playerId, true];
         if (p != null) {
             p.SetOffline ();
         } else {
             Log.Out ("Disconnected player not found in client list...");
         }
         PersistentData.PersistentContainer.Instance.Save ();
     } catch (Exception e) {
         Log.Out ("Error in AllocsLogFunctions.PlayerDisconnected: " + e);
     }
 }
예제 #29
0
 public static void Reply(ClientInfo _cInfo, string _message)
 {
     if (_message.StartsWith("R "))
     {
         _message = _message.Replace("R ", "");
     }
     if (_message.StartsWith("r "))
     {
         _message = _message.Replace("r ", "");
     }
     if (_message.StartsWith("re "))
     {
         _message = _message.Replace("re ", "");
     }
     if (_message.StartsWith("RE "))
     {
         _message = _message.Replace("RE ", "");
     }
     if (PersistentContainer.Instance.Players[_cInfo.playerId, true].LastWhisper == null)
     {
         string _phrase15;
         if (!Phrases.Dict.TryGetValue(15, out _phrase15))
         {
             _phrase15 = "{SenderName} no one has pm'd you.";
         }
         _phrase15 = _phrase15.Replace("{SenderName}", _cInfo.playerName);
         _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{1}{0}[-]", _phrase15, CustomCommands.ChatColor), "Server", false, "", false));
     }
     else
     {
         ClientInfo _cInfo1 = ConnectionManager.Instance.GetClientInfoForPlayerId(PersistentContainer.Instance.Players[_cInfo.playerId, true].LastWhisper);
         if (_cInfo1 == null)
         {
             string _phrase16;
             if (!Phrases.Dict.TryGetValue(16, out _phrase16))
             {
                 _phrase16 = "{SenderName} the player is not online.";
             }
             _phrase16 = _phrase16.Replace("{SenderName}", _cInfo.playerName);
             _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{1}{0}[-]", _phrase16, CustomCommands.ChatColor), "Server", false, "", false));
         }
         else
         {
             _cInfo1.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("(PM) {0}", _message), _cInfo.playerName, false, "", false));
             PersistentContainer.Instance.Players[_cInfo1.playerId, true].LastWhisper = _cInfo.playerId;
             PersistentContainer.Instance.Save();
         }
     }
 }
예제 #30
0
 public override void SavePlayerData(ClientInfo _cInfo, PlayerDataFile _playerDataFile)
 {
     if (HighPingKicker.IsEnabled)
     {
         HighPingKicker.CheckPing(_cInfo);
     }
     if (InventoryCheck.IsEnabled || InventoryCheck.AnounceInvalidStack)
     {
         InventoryCheck.CheckInv(_cInfo, _playerDataFile);
     }
     if (Watchlist.IsEnabled)
     {
         Watchlist.CheckWatchlist(_cInfo);
     }
 }
예제 #31
0
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params.Count != 1 && _params.Count != 2 && _params.Count != 4 && _params.Count != 5 && _params.Count != 8)
         {
             SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, 2, 4, 5 or 8, found {0}", _params.Count));
             return;
         }
         if (_params[0].ToLower().Equals("off"))
         {
             if (ChatColorPrefix.IsEnabled)
             {
                 ChatColorPrefix.IsEnabled = false;
                 LoadConfig.WriteXml();
                 SdtdConsole.Instance.Output(string.Format("Chat color prefix has been set to off"));
                 return;
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("Chat color prefix is already off"));
                 return;
             }
         }
         else if (_params[0].ToLower().Equals("on"))
         {
             if (!ChatColorPrefix.IsEnabled)
             {
                 ChatColorPrefix.IsEnabled = true;
                 LoadConfig.WriteXml();
                 SdtdConsole.Instance.Output(string.Format("Chat color prefix has been set to on"));
                 return;
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("Chat color prefix is already on"));
                 return;
             }
         }
         else if (_params[0].ToLower().Equals("add"))
         {
             if (_params.Count != 4 && _params.Count != 5 && _params.Count != 8)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 4, 5 or 8, found {0}", _params.Count));
                 return;
             }
             ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]);
             if (_cInfo == null)
             {
                 if (_params[1].Length == 17)
                 {
                     _cInfo = PersistentOperations.GetClientInfoFromSteamId(_params[1]);
                     if (_cInfo == null)
                     {
                         SdtdConsole.Instance.Output(string.Format("Can not find player data attached to {0}", _params[1]));
                         return;
                     }
                 }
                 else
                 {
                     if (int.TryParse(_params[1], out int _entId))
                     {
                         _cInfo = PersistentOperations.GetClientInfoFromEntityId(_entId);
                         if (_cInfo == null)
                         {
                             SdtdConsole.Instance.Output(string.Format("Can not find player data attached to {0}", _params[1]));
                             return;
                         }
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("Can not find player data attached to {0}", _params[1]));
                         return;
                     }
                 }
             }
             if (_params.Count == 8)
             {
                 foreach (var group in ChatColorPrefix.Dict)
                 {
                     if (group.Value[1] == _params[3])
                     {
                         SdtdConsole.Instance.Output(string.Format("Can not add id {0} to the chat color prefix list. Group {1} already exists on the list. Create a new entry or add them to this group", _cInfo.playerId, _params[3]));
                         return;
                     }
                 }
                 double _daysToExpire;
                 if (!double.TryParse(_params[7], out _daysToExpire))
                 {
                     SdtdConsole.Instance.Output(string.Format("Invalid days to expire: {0}", _params[7]));
                     return;
                 }
                 DateTime _expireDate;
                 if (_daysToExpire > 0d)
                 {
                     _expireDate = DateTime.Now.AddDays(_daysToExpire);
                 }
                 else
                 {
                     _expireDate = DateTime.Now.AddDays(18250d);
                 }
                 if ((!_params[5].Contains("[") || !_params[5].Contains("]")) && _params[5] != "**")
                 {
                     SdtdConsole.Instance.Output(string.Format("Can not add id {0} to the chat color prefix list. Name color must be in HTML format, example [FFFFFF] with the brackets included. Found: {1}", _params[1], _params[5]));
                     return;
                 }
                 if ((!_params[6].Contains("[") || !_params[6].Contains("]")) && _params[6] != "**")
                 {
                     SdtdConsole.Instance.Output(string.Format("Can not add id {0} to the chat color prefix list. Prefix color must be in HTML format, example [FFFFFF] with the brackets included. Found: {1}", _params[1], _params[6]));
                     return;
                 }
                 string[] _c = new string[] { _params[2], _params[3], _params[4], _params[5], _params[6] };
                 if (ChatColorPrefix.Dict.ContainsKey(_params[1]))
                 {
                     ChatColorPrefix.Dict[_cInfo.playerId]  = _c;
                     ChatColorPrefix.Dict1[_cInfo.playerId] = _expireDate;
                     SdtdConsole.Instance.Output(string.Format("Updated id {0} with the name of {1} to the group {2} using prefix {3}, name color {4} and prefix color {5} that expires {6} to the chat color prefix list.", _cInfo.playerId, _params[2], _params[3], _params[4], _params[5], _params[6], _expireDate.ToString()));
                 }
                 else
                 {
                     ChatColorPrefix.Dict.Add(_cInfo.playerId, _c);
                     ChatColorPrefix.Dict1.Add(_cInfo.playerId, _expireDate);
                     SdtdConsole.Instance.Output(string.Format("Added id {0} with the name of {1} to the group {2} using prefix {3}, name color {4} and prefix color {5} that expires {6} to the chat color prefix list.", _cInfo.playerId, _params[2], _params[3], _params[4], _params[5], _params[6], _expireDate.ToString()));
                 }
                 ChatColorPrefix.UpdateXml();
                 return;
             }
             else if (_params.Count == 5)
             {
                 foreach (var group in ChatColorPrefix.Dict)
                 {
                     if (group.Value[1] == _params[3])
                     {
                         double _daysToExpire2;
                         if (!double.TryParse(_params[4], out _daysToExpire2))
                         {
                             SdtdConsole.Instance.Output(string.Format("Invalid days to expire: {0}", _params[4]));
                             return;
                         }
                         DateTime _expireDate2;
                         if (_daysToExpire2 > 0d)
                         {
                             _expireDate2 = DateTime.Now.AddDays(_daysToExpire2);
                         }
                         else
                         {
                             _expireDate2 = DateTime.Now.AddDays(18250d);
                         }
                         string[] _c = new string[] { _params[2], group.Value[1], group.Value[2], group.Value[3], group.Value[4] };
                         if (ChatColorPrefix.Dict.ContainsKey(_cInfo.playerName))
                         {
                             ChatColorPrefix.Dict[_cInfo.playerId]  = _c;
                             ChatColorPrefix.Dict1[_cInfo.playerId] = _expireDate2;
                             SdtdConsole.Instance.Output(string.Format("Updated id {0} with the name of {1} to the group {2} using prefix {3}, name color {4} and prefix color {5} that expires {6} to the chat color prefix list.", _cInfo.playerId, _params[2], group.Value[1], group.Value[2], group.Value[3], group.Value[4], _expireDate2.ToString()));
                         }
                         else
                         {
                             ChatColorPrefix.Dict.Add(_cInfo.playerId, _c);
                             ChatColorPrefix.Dict1.Add(_cInfo.playerId, _expireDate2);
                             SdtdConsole.Instance.Output(string.Format("Added id {0} with the name of {1} to the group {2} using prefix {3}, name color {4} and prefix color {5} that expires {6} to the chat color prefix list.", _cInfo.playerId, _params[2], group.Value[1], group.Value[2], group.Value[3], group.Value[4], _expireDate2.ToString()));
                         }
                         ChatColorPrefix.UpdateXml();
                         return;
                     }
                 }
                 SdtdConsole.Instance.Output(string.Format("No group with the name {0} was found.", _params[3]));
                 return;
             }
             else if (_params.Count == 4)
             {
                 foreach (var group in ChatColorPrefix.Dict)
                 {
                     if (group.Value[1] == _params[3])
                     {
                         string[] _c = new string[] { _params[2], _params[3], group.Value[2], group.Value[3], group.Value[4] };
                         ChatColorPrefix.Dict1.TryGetValue(group.Key, out DateTime _dt);
                         ChatColorPrefix.Dict.Add(_cInfo.playerId, _c);
                         ChatColorPrefix.Dict1.Add(_cInfo.playerId, _dt);
                         SdtdConsole.Instance.Output(string.Format("Added Id {0} with the name of {1} to the group {2} using prefix {3} name color {4} and prefix color {5} that expires {6} to the chat color prefix list.", _cInfo.playerId, _params[2], _params[3], group.Value[2], group.Value[3], group.Value[4], _dt.ToString()));
                         ChatColorPrefix.UpdateXml();
                         return;
                     }
                 }
                 SdtdConsole.Instance.Output(string.Format("No group with the name {0} was found.", _params[3]));
                 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;
             }
             foreach (var group in ChatColorPrefix.Dict)
             {
                 if (group.Value[1] == _params[1])
                 {
                     ChatColorPrefix.Dict.Remove(group.Key);
                     ChatColorPrefix.Dict1.Remove(group.Key);
                     SdtdConsole.Instance.Output(string.Format("Removed {0} named {1} with group {2} from the chat color prefix list.", group.Key, group.Value[0], _params[1]));
                 }
                 if (group.Key == _params[1])
                 {
                     ChatColorPrefix.Dict.Remove(group.Key);
                     ChatColorPrefix.Dict1.Remove(group.Key);
                     SdtdConsole.Instance.Output(string.Format("Removed {0} named {1} with group {2} from the chat color prefix list.", _params[1], group.Value[0], group.Value[1]));
                 }
                 if (group.Value[0] == _params[1])
                 {
                     ChatColorPrefix.Dict.Remove(group.Key);
                     ChatColorPrefix.Dict1.Remove(group.Key);
                     SdtdConsole.Instance.Output(string.Format("Removed {0} named {1} with group {2} from the chat color prefix list.", group.Key, _params[1], group.Value[1]));
                 }
                 ChatColorPrefix.UpdateXml();
             }
             SdtdConsole.Instance.Output(string.Format("Completed removing id and groups matching {0} from the chat color prefix list.", _params[1]));
         }
         else if (_params[0].ToLower().Equals("list"))
         {
             foreach (var group in ChatColorPrefix.Dict)
             {
                 if (group.Value[2] == "")
                 {
                     group.Value[2] = "**";
                 }
                 if (group.Value[3] == "")
                 {
                     group.Value[3] = "**";
                 }
                 DateTime _dt;
                 ChatColorPrefix.Dict1.TryGetValue(group.Key, out _dt);
                 SdtdConsole.Instance.Output(string.Format("Id {0} named {1} with group {2} prefix {3} color {4} expires {5}.", group.Key, group.Value[0], group.Value[1], group.Value[2], group.Value[3], _dt));
             }
         }
         else
         {
             SdtdConsole.Instance.Output(string.Format("Invalid argument {0}", _params[0]));
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in ChatColorPrefixConsole.Execute: {0}", e.Message));
     }
 }
예제 #32
0
        public string Start(string path)
        {
            Process clientProcess = null;

            try {
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.WorkingDirectory = path;
                startInfo.FileName         = Path.Combine(path, "client.exe");

                UOMachine.NativeMethods.SafeProcessHandle hProcess;
                UOMachine.NativeMethods.SafeThreadHandle  hThread;
                uint pid, tid;

                if (UOMachine.NativeMethods.CreateProcess(startInfo, true, out hProcess, out hThread, out pid, out tid))
                {
                    ClientPatcher.MultiPatch(hProcess.DangerousGetHandle());
                    bool result = false;
                    m_AddressLock = new object();
                    clientProcess = Process.GetProcessById((int)pid);

                    UOMachine.IPC.Network.Initialize();
                    UOMachine.Utility.Log.Initialize("UnitTests" + DateTime.Now.ToString("[MM - dd - yyyy HH.mm.ss] ") + ".txt");
                    InternalEventHandler.IPCHandler.Initialize();

                    UOMachine.NativeMethods.ResumeThread(hThread.DangerousGetHandle());

                    ClientInfo ci = new ClientInfo(clientProcess);

                    int instance = 0;
                    ClientInfoCollection.ClientList[instance] = ci;
                    ClientInfoCollection.Count = 1;

                    ulong len = (ulong)ci.EntryPoint - (ulong)ci.BaseAddress;
                    UOMachine.NativeMethods.GainMemoryAccessEx(ci.Handle, ci.BaseAddress, len);

                    string channelName = null;
                    RemoteHooking.IpcCreateServer <LoginServerTest>(ref channelName, System.Runtime.Remoting.WellKnownObjectMode.SingleCall);
                    RemoteHooking.Inject(clientProcess.Id, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UnitTests.dll"), null, channelName);

                    ci.InstallMacroHook();
                    Macro.ChangeServer(instance, "127.0.0.1", 2593);

                    Thread.Sleep(10000);

                    lock (m_AddressLock)
                    {
                        GumpInfo[] gi = Macro.GetGumpList(instance);
                        foreach (GumpInfo g in gi)
                        {
                            if (g.Type == "MainMenu gump")
                            {
                                foreach (GumpInfo g2 in g.SubGumps)
                                {
                                    if (g2.Type == "AcctLogin gump")
                                    {
                                        if (ci.DateStamp > 0x43A06A35)
                                        {
                                            g2.CallFunction(26);
                                        }
                                        else
                                        {
                                            g2.CallFunction(23);
                                        }
                                    }
                                }
                            }
                        }
                        result = Monitor.Wait(m_AddressLock, 60000);
                    }

                    UOMachine.IPC.Network.Dispose();
                    Log.Dispose();
                    UOMachine.NativeMethods.TerminateProcess(Process.GetProcessById(clientProcess.Id).Handle, 0);

                    return(m_Address);
                }
            } catch (Exception)
            {
                UOMachine.IPC.Network.Dispose();
                Log.Dispose();
                UOMachine.NativeMethods.TerminateProcess(Process.GetProcessById(clientProcess.Id).Handle, 0);
                throw;
            }
            return(null);
        }
예제 #33
0
        public bool PasteSelection(Vector3i pos)
        {
            int width  = selectionPrefab.size.x;
            int height = selectionPrefab.size.y;
            int length = selectionPrefab.size.z;

            this.start = pos;
            this.end   = new Vector3i(pos.x + width, pos.y + height, pos.z + length);
            FixSelections();

            Dictionary <long, Chunk> usedChunks = new Dictionary <long, Chunk>();


            for (int xOffset = -1; xOffset < width + 2; xOffset++)
            {
                for (int zOffset = -1; zOffset < length + 2; zOffset++)
                {
                    for (int yOffset = -1; yOffset < height + 2; yOffset++)
                    {
                        if (GameManager.Instance.World.IsChunkAreaLoaded(pos.x + xOffset, pos.y + yOffset, pos.z + zOffset))
                        {
                            Chunk usedChunk = GameManager.Instance.World.GetChunkFromWorldPos(pos.x + xOffset, pos.y + yOffset, pos.z + zOffset) as Chunk;
                            if (!usedChunks.ContainsKey(usedChunk.Key))
                            {
                                usedChunks [usedChunk.Key] = usedChunk;
                            }
                        }
                        else
                        {
                            //SdtdConsole.Instance.Output ("[WorldTool Selections] Prefab will use chunks that are not Loaded.  Aborting Paste.");
                            return(false);
                        }
                    }
                }
            }

            Prefab prefabClone = selectionPrefab.Clone();

            System.Random rnd = new System.Random();
            for (int blockX = 0; blockX < width; blockX++)
            {
                for (int blockY = 0; blockY < height; blockY++)
                {
                    for (int blockZ = 0; blockZ < length; blockZ++)
                    {
                        BlockValue currentBV = prefabClone.GetBlock(blockX, blockY, blockZ);
                        if (currentBV.type != 0)
                        {
                            BlockValue lootBV = LootContainer.lootPlaceholderMap.Replace(currentBV, rnd);
                            if (lootBV.type != currentBV.type)
                            {
                                prefabClone.SetBlock(blockX, blockY, blockZ, lootBV);
                            }
                        }
                    }
                }
            }


            bool currentPhysicsState = GameManager.bPhysicsActive;

            GameManager.bPhysicsActive = false;
            if (selectionPrefab.yOffset != 0)
            {
                pos.y += selectionPrefab.yOffset;
            }

            if (this.YOffset != 0)
            {
                pos.y += this.YOffset;
            }

            if (this.rotations > 0)
            {
                prefabClone.RotateY(false, this.rotations);
            }

            prefabClone.CopyIntoLocal(GameManager.Instance.World.ChunkClusters[0], new Vector3i(pos.x, pos.y, pos.z), true, true);
            GameManager.bPhysicsActive = currentPhysicsState;

            //Thread.Sleep(50);

            Log.Out("PASTING PREFAB");
            Log.Out(pos.ToString());

            StabilityInitializer stabInit = new StabilityInitializer(GameManager.Instance.World);

            for (int yOffset = -1; yOffset < height + 2; yOffset++)
            {
                for (int xOffset = -1; xOffset < width + 2; xOffset++)
                {
                    for (int zOffset = -1; zOffset < length + 2; zOffset++)
                    {
                        BlockValue block = GameManager.Instance.World.GetBlock(pos.x + xOffset, yOffset, pos.z + zOffset);
                        if (block.type != 0)
                        {
                            stabInit.BlockPlacedAt(pos.x + xOffset, pos.y + yOffset, pos.z + zOffset, block);
                        }
                    }
                }
            }

            Dictionary <String, List <Chunk> > playerChunksToReload = new Dictionary <String, List <Chunk> >();

            foreach (Chunk currentChunk in usedChunks.Values)
            {
                //currentChunk.RepairDensities ();
                foreach (string playerSteamId in GameManager.Instance.persistentPlayers.Players.Keys)
                {
                    ClientInfo connectedPlayer = ConsoleHelper.ParseParamIdOrName(playerSteamId);
                    //TODO: for efficieny, we should probably add a check to see if the player is in range
                    if (connectedPlayer != null)
                    {
                        List <Chunk> playerChunks;

                        if (!playerChunksToReload.ContainsKey(playerSteamId))
                        {
                            playerChunks = new List <Chunk> ();
                        }
                        else
                        {
                            playerChunks = playerChunksToReload [playerSteamId];
                        }

                        playerChunks.Add(currentChunk);
                        playerChunksToReload.Remove(playerSteamId);
                        playerChunksToReload.Add(playerSteamId, playerChunks);
                    }
                }
            }

            //send chunk remove messages
            foreach (string playerSteamId in playerChunksToReload.Keys)
            {
                ClientInfo connectedPlayer = ConsoleHelper.ParseParamIdOrName(playerSteamId);

                List <Chunk> playerChunks = playerChunksToReload [playerSteamId];
                if (playerChunks != null && playerChunks.Count > 0)
                {
                    foreach (Chunk currentChunk in playerChunks)
                    {
                        connectedPlayer.SendPackage(new NetPackageChunkRemove(currentChunk.Key));
                    }
                }
            }

            //send chunk add messages
            foreach (string playerSteamId in playerChunksToReload.Keys)
            {
                ClientInfo connectedPlayer = ConsoleHelper.ParseParamIdOrName(playerSteamId);

                List <Chunk> playerChunks = playerChunksToReload [playerSteamId];
                if (playerChunks != null && playerChunks.Count > 0)
                {
                    foreach (Chunk currentChunk in playerChunks)
                    {
                        connectedPlayer.SendPackage(new NetPackageChunk(currentChunk));
                    }
                }
            }

            return(true);
        }
예제 #34
0
 public List <PayItem> GetPayItems(ClientInfo client)
 {
     return(GetPayrollCollectionItem <PayItem>(client));
 }
예제 #35
0
 public List <TerminationReason> GetTerminationReasons(ClientInfo client)
 {
     return(GetPayrollCollectionItem <TerminationReason>(client));
 }
        public void CacheTimeout_DefaultValue_IsTwoDays()
        {
            var clientInfo = new ClientInfo();

            Assert.Equal(TimeSpan.FromDays(2), clientInfo.CacheTimeout);
        }
예제 #37
0
 public void DisconnectClient(ClientInfo info)
 {
     this.connectionManager.CloseConnection(info);
 }
예제 #38
0
        public void Load()
        {
            Log.Debug("Begin specsber parsing");
            using (var stream = File.Open(Path, FileMode.Open, FileAccess.Read))
            {
                using (var reader = ExcelReaderFactory.CreateCsvReader(stream, new ExcelReaderConfiguration
                {
                    FallbackEncoding = Encoding.GetEncoding(1251),
                    AutodetectSeparators = new[] { ';' }
                }))
                {
                    var result = reader.AsDataSet().Tables[0].Rows;
                    for (var i = 0; i < result.Count; i++)
                    {
                        var row    = result[i].ItemArray;
                        var rowStr = row[0].ToString();

                        if (string.IsNullOrEmpty(rowStr) || (rowStr[0] == '='))
                        {
                            continue;
                        }

                        var tmp = new ClientInfo
                        {
                            Source     = string.Join(";", row.Where(o => o is string).ToArray()),
                            SourcePath = Path,
                            Address    = row[7].ToString(),
                            Name       = !string.IsNullOrEmpty(row[6].ToString()) ? row[6].ToString() : row[5].ToString()
                        };

                        var j      = 10;
                        var rawSum = 0m;
                        if (string.Equals(row[j].ToString(), "[!]") && string.Equals(row[j - 1].ToString(), "[!]"))
                        {
                            tmp.Positions.Add(new Position {
                                Name = "Вывоз ТКО", Sum = row[j + 3].ToString()
                            });
                            rawSum = decimal.Parse(row[j + 3].ToString());
                        }
                        else
                        {
                            while (true)
                            {
                                Log.Debug($"Read position: '{row[j + 1]}; {row[j + 2]}'");
                                var posSum  = row[j + 2].ToString();
                                var posName = row[j + 1].ToString();
                                if (string.IsNullOrEmpty(posSum) ||
                                    string.Equals(posSum.Replace(",", "."), "0.00") ||
                                    string.IsNullOrEmpty(posName) ||
                                    string.Equals(posName, "ГОСПОШЛИНА") ||
                                    string.Equals(posName, "ПЕНИ ПО СУДУ") ||
                                    string.Equals(posName, "ПЕНЯ")
                                    )
                                {
                                    if (row[j + 3].ToString() == "[!]")
                                    {
                                        break;
                                    }

                                    j += 3;
                                    continue;
                                }


                                tmp.Positions.Add(new Position {
                                    Name = posName, Sum = posSum
                                });

                                if (row[j + 3].ToString() == "[!]")
                                {
                                    break;
                                }

                                j += 3;
                            }

                            rawSum = decimal.Parse(row[j + 5].ToString());
                        }


                        var tmpSum = 0m;


                        foreach (var position in tmp.Positions)
                        {
                            tmpSum      += decimal.Parse(position.Sum.Replace(".", ","));
                            position.Sum = position.Sum.Replace(",", ".");
                        }


                        tmp.Sum = tmpSum.ToString(CultureInfo.InvariantCulture);

                        Data.Add(tmp);

                        if ((tmpSum != rawSum) || (tmp.Positions.Count != 1))
                        {
                            var msg = tmpSum != rawSum ? $"Сумма не совпадает: {tmpSum}!={rawSum}" : "Позиций != 1";

                            var eventInfo = new LogEventInfo
                            {
                                Message = msg,
                                Level   = LogLevel.Warn,
                            };

                            foreach (var item in tmp.AsDictionary())
                            {
                                eventInfo.Properties.Add(new KeyValuePair <object, object>(item.Key, item.Value));
                            }

                            Log.Warn(eventInfo);
                        }
                    }
                }
            }

            Log.Debug("End specsber parsing");
            Log.Info($"Файл {Path} успешно загружен");
        }
예제 #39
0
 private static bool UnknownCommand(ClientInfo clientInfo)
 {
     ChatManager.Message(clientInfo, "[FF4136]Unknown command");
     return(false);
 }
예제 #40
0
파일: Cust.cs 프로젝트: radtek/InfoPos
        public Result Txn602001(ClientInfo ci, RequestInfo ri, DbConnections db, ref Log lg)
        {
            Result res = new Result();

            try
            {
                #region Prepare parameters
                object[] param = ri.ReceivedParam;

                string custno   = Static.ToStr(param[0]);
                string contract = Static.ToStr(param[1]);
                string reg      = Static.ToStr(param[2]);
                string fname    = Static.ToStr(param[3]);
                string lname    = Static.ToStr(param[4]);
                string cname    = Static.ToStr(param[5]);

                #endregion
                #region Prepare query
                string sql = @"
select /*+ first_rows(1) */
c.customerno
, decode(c.classcode,0,c.lastname||' '||c.firstname,c.corporatename) custname
, c.mobile, c.registerno, c.membercontractno
, decode(c.classcode,0, decode(c.membercontractno,null,'ИРГЭН','ГИШҮҮН'),'ААН') classcode
, decode(c.classcode,0, decode(c.sex,0,'ЭР','ЭМ'), null) sex
from customer c
{0} order by c.customerno desc
";

                #endregion
                #region Prepare filter text

                StringBuilder sb     = new StringBuilder();
                ArrayList     values = new ArrayList();

                if (!string.IsNullOrEmpty(custno))
                {
                    values.Add(custno);
                    if (sb.Length > 0)
                    {
                        sb.Append(" and ");
                    }
                    sb.AppendFormat("c.customerno=:{0}", values.Count);
                }
                if (!string.IsNullOrEmpty(reg))
                {
                    values.Add(reg);
                    if (sb.Length > 0)
                    {
                        sb.Append(" and ");
                    }
                    sb.AppendFormat("c.registerno like :{0}||'%'", values.Count);
                }
                if (!string.IsNullOrEmpty(fname))
                {
                    values.Add(fname);
                    if (sb.Length > 0)
                    {
                        sb.Append(" and ");
                    }
                    sb.AppendFormat("c.firstname like :{0}||'%'", values.Count);
                }
                if (!string.IsNullOrEmpty(lname))
                {
                    values.Add(lname);
                    if (sb.Length > 0)
                    {
                        sb.Append(" and ");
                    }
                    sb.AppendFormat("c.lastname=:{0}", values.Count);
                }
                if (!string.IsNullOrEmpty(cname))
                {
                    values.Add(cname);
                    if (sb.Length > 0)
                    {
                        sb.Append(" and ");
                    }
                    sb.AppendFormat("c.corporatename like :{0}||'%'", values.Count);
                }
                if (!string.IsNullOrEmpty(contract))
                {
                    values.Add(contract);
                    if (sb.Length > 0)
                    {
                        sb.Append(" and ");
                    }
                    sb.AppendFormat("c.membercontractno=:{0}", values.Count);
                }

                if (sb.Length > 0)
                {
                    sb.Insert(0, "where ");
                }
                sql = string.Format(sql, sb.ToString());

                #endregion
                #region Execute query
                res = db.ExecuteQuery("core", sql, "Txn602001", ri.PageIndex, ri.PageRows, values.ToArray());
                #endregion
            }
            catch (Exception ex)
            {
                res.ResultNo   = 9110002;
                res.ResultDesc = "Програм руу нэвтрэхэд алдаа гарлаа" + ex.Message;
            }
            finally
            {
                lg.item.Desc = "Хэрэглэгчийн жагсаалт авах";
            }
            return(res);
        }       // Харилцагч хайх
예제 #41
0
파일: Cust.cs 프로젝트: radtek/InfoPos
        }       // ПОС үйлчлүүлэгч үүсгэх

        public Result Txn602003(ClientInfo ci, RequestInfo ri, DbConnections db, ref Log lg)
        {
            Result res = new Result();

            try
            {
                #region Prepare parameters
                object[] param = ri.ReceivedParam;

                string custno = Static.ToStr(param[0]);
                string cname  = Static.ToStr(param[1]);
                string reg    = Static.ToStr(param[2]);

                #endregion
                #region Prepare query
                string sql = @"
select /*+ first_rows(1) */
c.customerno,c.corporatename custname,c.registerno,nvl(telephone, c.mobile) phoneno
from customer c where c.classcode=1 {0}
order by 2
";

                #endregion
                #region Prepare filter text

                StringBuilder sb     = new StringBuilder();
                ArrayList     values = new ArrayList();

                if (!string.IsNullOrEmpty(custno))
                {
                    values.Add(custno);
                    sb.AppendFormat("and c.customerno=:{0}", values.Count);
                }
                if (!string.IsNullOrEmpty(cname))
                {
                    values.Add(cname);
                    sb.AppendFormat("and c.corporatename like :{0}||'%'", values.Count);
                }
                if (!string.IsNullOrEmpty(reg))
                {
                    values.Add(reg);
                    sb.AppendFormat("and c.registerno like :{0}||'%'", values.Count);
                }

                //if (sb.Length > 0) sb.Insert(0, "where ");
                sql = string.Format(sql, sb.ToString());

                #endregion
                #region Execute query
                res = db.ExecuteQuery("core", sql, "Txn602001", ri.PageIndex, ri.PageRows, values.ToArray());
                #endregion
            }
            catch (Exception ex)
            {
                res.ResultNo   = 9110002;
                res.ResultDesc = "Програм руу нэвтрэхэд алдаа гарлаа" + ex.Message;
            }
            finally
            {
                lg.item.Desc = "Хэрэглэгчийн жагсаалт авах";
            }
            return(res);
        }       // Байгууллага хайх
        public string saveClient(Clienti clientToSave)
        {
            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["localDB"].ConnectionString))
            {
                int    indexC        = 0;
                string json          = "";
                bool   accountExists = false;


                try{
                    connection.Open();
                    SqlCommand command = new SqlCommand(null, connection);

                    //Create SQL statement

                    command.CommandText = "SELECT COUNT(*) FROM [dbo].[Clienti] WHERE Email = @email";
                    command.Parameters.AddWithValue("@email", clientToSave.Email);

                    int emailNum = 0;
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        StringBuilder respons = new StringBuilder();
                        while (reader.Read())
                        {
                            respons.Append(reader[0]);
                        }
                        emailNum = int.Parse(respons.ToString());
                        System.Diagnostics.Debug.WriteLine("Emai value: " + emailNum);

                        if (emailNum > 0)
                        {
                            accountExists = true;
                            ClientInfo infoToReturn = new ClientInfo();
                            infoToReturn.mesaj = "Account exists!";
                            json = Newtonsoft.Json.JsonConvert.SerializeObject(infoToReturn);
                        }
                    }
                }
                catch (SqlException ex)
                {
                    // throw ex;
                    ClientInfo infoToReturn = new ClientInfo();
                    infoToReturn.mesaj = "Error!";
                }
                finally
                {
                    connection.Close();
                }

                if (accountExists == false)
                {
                    try
                    {
                        connection.Open();
                        SqlCommand command = new SqlCommand(null, connection);

                        // Create SQL statement
                        command.CommandText = "INSERT INTO Clienti (NumePrenume, IndexOras, Email, Parola) output INSERTED.[Index] VALUES (@nume, @oras, @email, @parola);";

                        command.Parameters.AddWithValue("@nume", clientToSave.NumePrenume);
                        command.Parameters.AddWithValue("@oras", clientToSave.IndexOras);
                        command.Parameters.AddWithValue("@email", clientToSave.Email);
                        command.Parameters.AddWithValue("@parola", sha256_hash(clientToSave.Parola));

                        indexC = (int)command.ExecuteScalar();

                        System.Diagnostics.Debug.WriteLine("Client: " + indexC);

                        // Create client session token
                        string Token = Convert.ToBase64String(BitConverter.GetBytes(DateTime.UtcNow.ToBinary()).Concat(Guid.NewGuid().ToByteArray()).ToArray());
                        command.CommandText = "INSERT INTO ClientiSesiuni (IndexClient, Token, DeviceId) VALUES (@indexClient, @token, @device)";
                        command.Parameters.AddWithValue("@indexClient", indexC);
                        command.Parameters.AddWithValue("@token", Token);
                        command.Parameters.AddWithValue("@device", sha256_hash(clientToSave.DeviceID));

                        command.ExecuteNonQuery();
                        clientToSave.Token = Token;

                        ClientInfo infoToReturn = new ClientInfo();
                        infoToReturn.token = Token;
                        infoToReturn.mesaj = "Success!";
                        json = Newtonsoft.Json.JsonConvert.SerializeObject(infoToReturn);
                    }
                    catch (SqlException ex)
                    {
                        //throw ex;
                        ClientInfo infoToReturn = new ClientInfo();
                        infoToReturn.mesaj = "Error!";
                        json = Newtonsoft.Json.JsonConvert.SerializeObject(infoToReturn);
                    }
                    finally
                    {
                        connection.Close();
                    }
                }
                return(json);
            }
        }
예제 #43
0
        public static void Checks(ClientInfo _cInfo, string _message, bool _announce)
        {
            EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];

            if (PvP_Check)
            {
                if (Teleportation.PCheck(_cInfo, _player))
                {
                    return;
                }
            }
            if (Zombie_Check)
            {
                if (Teleportation.ZCheck(_cInfo, _player))
                {
                    return;
                }
            }
            ClientInfo _friend = ConsoleHelper.ParseParamIdOrName(_message);

            if (_friend != null)
            {
                EntityPlayer _friendPlayer = GameManager.Instance.World.Players.dict[_friend.entityId];
                if (_player.IsFriendsWith(_friendPlayer))
                {
                    bool      _donator = false;
                    string    _sql     = string.Format("SELECT lastFriendTele FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                    DataTable _result  = SQL.TQuery(_sql);
                    DateTime  _lastFriendTele;
                    DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastFriendTele);
                    _result.Dispose();
                    if (Delay_Between_Uses < 1 || _lastFriendTele.ToString() == "10/29/2000 7:30:00 AM")
                    {
                        if (Wallet.IsEnabled && Command_Cost >= 1)
                        {
                            CommandCost(_cInfo, _message);
                        }
                        else
                        {
                            MessageFriend(_cInfo, _message);
                        }
                    }
                    else
                    {
                        TimeSpan varTime           = DateTime.Now - _lastFriendTele;
                        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)
                                {
                                    _donator = true;
                                    int _newDelay = Delay_Between_Uses / 2;
                                    if (_timepassed >= _newDelay)
                                    {
                                        if (Wallet.IsEnabled && Command_Cost >= 1)
                                        {
                                            CommandCost(_cInfo, _message);
                                        }
                                        else
                                        {
                                            MessageFriend(_cInfo, _message);
                                        }
                                    }
                                    else
                                    {
                                        int    _timeleft = _newDelay - _timepassed;
                                        string _phrase630;
                                        if (!Phrases.Dict.TryGetValue(630, out _phrase630))
                                        {
                                            _phrase630 = " you can only teleport to a friend once every {DelayBetweenUses} minutes. Time remaining: {TimeRemaining} minutes.";
                                        }
                                        _phrase630 = _phrase630.Replace("{DelayBetweenUses}", _newDelay.ToString());
                                        _phrase630 = _phrase630.Replace("{TimeRemaining}", _timeleft.ToString());
                                        if (_announce)
                                        {
                                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase630 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null);
                                        }
                                        else
                                        {
                                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase630 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                        }
                                    }
                                }
                            }
                        }
                        if (!_donator)
                        {
                            if (_timepassed >= Delay_Between_Uses)
                            {
                                if (Wallet.IsEnabled && Command_Cost >= 1)
                                {
                                    CommandCost(_cInfo, _message);
                                }
                                else
                                {
                                    MessageFriend(_cInfo, _message);
                                }
                            }
                            else
                            {
                                int    _timeleft = Delay_Between_Uses - _timepassed;
                                string _phrase630;
                                if (!Phrases.Dict.TryGetValue(630, out _phrase630))
                                {
                                    _phrase630 = " you can only teleport to a friend once every {DelayBetweenUses} minutes. Time remaining: {TimeRemaining} minutes.";
                                }
                                _phrase630 = _phrase630.Replace("{DelayBetweenUses}", Delay_Between_Uses.ToString());
                                _phrase630 = _phrase630.Replace("{TimeRemaining}", _timeleft.ToString());
                                if (_announce)
                                {
                                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase630 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null);
                                }
                                else
                                {
                                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase630 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                }
                            }
                        }
                    }
                }
                else
                {
                    string _phrase633;
                    if (!Phrases.Dict.TryGetValue(633, out _phrase633))
                    {
                        _phrase633 = "This player is not your friend. You can not request teleport to them.";
                    }
                    ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase633 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                }
            }
        }
예제 #44
0
 private static string GetBrowser(ClientInfo clientInfo)
 {
     return(clientInfo == null
                ? null
                : string.Format("{0} {1}", clientInfo.UA.Family, clientInfo.UA.Major));
 }
예제 #45
0
 private static string GetPlatform(ClientInfo clientInfo)
 {
     return(clientInfo == null
                ? null
                : string.Format("{0} {1}", clientInfo.OS.Family, clientInfo.OS.Major));
 }
        internal void PopulateCache(
            ITokenCacheAccessor accessor,
            string uid               = TestConstants.Uid,
            string utid              = TestConstants.Utid,
            string clientId          = TestConstants.ClientId,
            string environment       = TestConstants.ProductionPrefCacheEnvironment,
            string displayableId     = TestConstants.DisplayableId,
            string rtSecret          = TestConstants.RTSecret,
            string overridenScopes   = null,
            bool expiredAccessTokens = false,
            bool addSecondAt         = true)
        {
            string clientInfo = MockHelpers.CreateClientInfo(uid, utid);
            string homeAccId  = ClientInfo.CreateFromJson(clientInfo).ToAccountIdentifier();

            var accessTokenExpiresOn = expiredAccessTokens ?
                                       new DateTimeOffset(DateTime.UtcNow) :
                                       new DateTimeOffset(DateTime.UtcNow + TimeSpan.FromSeconds(ValidExpiresIn));

            var extendedAccessTokenExpiresOn = expiredAccessTokens ?
                                               new DateTimeOffset(DateTime.UtcNow) :
                                               new DateTimeOffset(DateTime.UtcNow + TimeSpan.FromSeconds(ValidExtendedExpiresIn));

            MsalAccessTokenCacheItem atItem = new MsalAccessTokenCacheItem(
                environment,
                clientId,
                overridenScopes ?? TestConstants.s_scope.AsSingleString(),
                utid,
                "",
                accessTokenExpiresOn,
                extendedAccessTokenExpiresOn,
                clientInfo,
                homeAccId);

            // add access token
            accessor.SaveAccessToken(atItem);

            var idTokenCacheItem = new MsalIdTokenCacheItem(
                environment,
                clientId,
                MockHelpers.CreateIdToken(TestConstants.UniqueId + "more", displayableId),
                clientInfo,
                homeAccId,
                tenantId: utid);

            accessor.SaveIdToken(idTokenCacheItem);

            // add another access token
            if (addSecondAt)
            {
                atItem = new MsalAccessTokenCacheItem(
                    environment,
                    clientId,
                    TestConstants.s_scopeForAnotherResource.AsSingleString(),
                    utid,
                    "",
                    accessTokenExpiresOn,
                    extendedAccessTokenExpiresOn,
                    clientInfo,
                    homeAccId);

                accessor.SaveAccessToken(atItem);
            }

            var accountCacheItem = new MsalAccountCacheItem(
                environment,
                null,
                clientInfo,
                homeAccId,
                null,
                displayableId,
                utid,
                null,
                null,
                null);

            accessor.SaveAccount(accountCacheItem);

            AddRefreshTokenToCache(accessor, uid, utid, clientId, environment, rtSecret);

            var appMetadataItem = new MsalAppMetadataCacheItem(
                clientId,
                environment,
                null);

            accessor.SaveAppMetadata(appMetadataItem);
        }
예제 #47
0
 public ClientInfoMessage(ClientInfo clientInfo) : this()
 {
     SetRequestCode();
     ClientInfo = clientInfo;
 }
예제 #48
0
 public static void MarketTele(ClientInfo _cInfo)
 {
     if (Market.Market_Position != "0,0,0" || Market.Market_Position != "0 0 0" || Market.Market_Position != "")
     {
         EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
         if (Player_Check)
         {
             if (Teleportation.PCheck(_cInfo, _player))
             {
                 return;
             }
         }
         if (Zombie_Check)
         {
             if (Teleportation.ZCheck(_cInfo, _player))
             {
                 return;
             }
         }
         int x, y, z;
         if (Return)
         {
             Vector3 _position = _player.GetPosition();
             x = (int)_position.x;
             y = (int)_position.y;
             z = (int)_position.z;
             string _mposition = x + "," + y + "," + z;
             MarketPlayers.Add(_cInfo.entityId);
             PersistentContainer.Instance.Players[_cInfo.playerId].MarketReturnPos = _mposition;
             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}", Market.Command51);
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase561 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
         string[] _cords = { };
         if (Market.Market_Position.Contains(","))
         {
             if (Market.Market_Position.Contains(" "))
             {
                 Market.Market_Position.Replace(" ", "");
             }
             _cords = Market.Market_Position.Split(',').ToArray();
         }
         else if (Market.Market_Position.Contains(" "))
         {
             _cords = Market.Market_Position.Split(' ').ToArray();
         }
         int.TryParse(_cords[0], out x);
         int.TryParse(_cords[1], out y);
         int.TryParse(_cords[2], out z);
         _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(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 + LoadConfig.Chat_Response_Color + _phrase562 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         if (Wallet.IsEnabled && Command_Cost >= 1)
         {
             Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost);
         }
         PersistentContainer.Instance.Players[_cInfo.playerId].LastMarket = DateTime.Now;
         PersistentContainer.Instance.Save();
     }
     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 + LoadConfig.Chat_Response_Color + _phrase563 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
     }
 }
예제 #49
0
 public List <PayGroup> GetPayGroups(ClientInfo client)
 {
     return(GetPayrollCollectionItem <PayGroup>(client));
 }
        public static void VehicleDelay(ClientInfo _cInfo, string _playerName, int _vehicle)
        {
            string    _sql    = string.Format("SELECT steamid FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId);
            DataTable _result = SQL.TQuery(_sql);

            if (_result.Rows.Count == 0)
            {
                string _steamid = SQL.EscapeString(_cInfo.playerId);
                _sql = string.Format("INSERT INTO Vehicles (steamid) VALUES ('{0}')", _steamid);
                SQL.FastQuery(_sql);
            }
            _result.Dispose();
            Entity _player         = GameManager.Instance.World.Players.dict[_cInfo.entityId];
            Entity _attachedEntity = _player.AttachedToEntity;

            if (_attachedEntity == null)
            {
                bool _donator = false;
                if (Delay_Between_Uses < 1)
                {
                    if (Wallet.IsEnabled && Command_Cost >= 1)
                    {
                        CommandCost(_cInfo, _player, _vehicle);
                    }
                    else
                    {
                        Exec2(_cInfo, _player, _vehicle);
                    }
                }
                else
                {
                    if (_vehicle == 1)
                    {
                        _sql = string.Format("SELECT lastBike FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId);
                    }
                    if (_vehicle == 2)
                    {
                        _sql = string.Format("SELECT lastMiniBike FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId);
                    }
                    if (_vehicle == 3)
                    {
                        _sql = string.Format("SELECT lastMotorBike FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId);
                    }
                    if (_vehicle == 4)
                    {
                        _sql = string.Format("SELECT lastJeep FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId);
                    }
                    if (_vehicle == 5)
                    {
                        _sql = string.Format("SELECT lastGyro FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId);
                    }
                    _result = SQL.TQuery(_sql);
                    DateTime _lastVehicle;
                    DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastVehicle);
                    _result.Dispose();
                    TimeSpan varTime           = DateTime.Now - _lastVehicle;
                    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)
                            {
                                _donator = true;
                                int _newDelay = Delay_Between_Uses / 2;
                                if (_timepassed >= _newDelay)
                                {
                                    if (Wallet.IsEnabled && Command_Cost >= 1)
                                    {
                                        CommandCost(_cInfo, _player, _vehicle);
                                    }
                                    else
                                    {
                                        Exec2(_cInfo, _player, _vehicle);
                                    }
                                }
                                else
                                {
                                    int    _timeleft = _newDelay - _timepassed;
                                    string _phrase786;
                                    if (!Phrases.Dict.TryGetValue(786, out _phrase786))
                                    {
                                        _phrase786 = " you can only use vehicle teleport once every {DelayBetweenUses} minutes. Time remaining: {TimeRemaining} minutes.";
                                    }
                                    _phrase786 = _phrase786.Replace("{DelayBetweenUses}", _newDelay.ToString());
                                    _phrase786 = _phrase786.Replace("{TimeRemaining}", _timeleft.ToString());
                                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase786 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                }
                            }
                        }
                    }
                    if (!_donator)
                    {
                        if (_timepassed >= Delay_Between_Uses)
                        {
                            if (Wallet.IsEnabled && Command_Cost >= 1)
                            {
                                CommandCost(_cInfo, _player, _vehicle);
                            }
                            else
                            {
                                Exec2(_cInfo, _player, _vehicle);
                            }
                        }
                        else
                        {
                            int    _timeleft = Delay_Between_Uses - _timepassed;
                            string _phrase786;
                            if (!Phrases.Dict.TryGetValue(786, out _phrase786))
                            {
                                _phrase786 = " you can only use vehicle teleport once every {DelayBetweenUses} minutes. Time remaining: {TimeRemaining} minutes.";
                            }
                            _phrase786 = _phrase786.Replace("{DelayBetweenUses}", Delay_Between_Uses.ToString());
                            _phrase786 = _phrase786.Replace("{TimeRemaining}", _timeleft.ToString());
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase786 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                        }
                    }
                }
            }
            else
            {
                Log.Out("Attached vehicle");
                Exec1(_cInfo, _player, _vehicle);
            }
        }
예제 #51
0
 protected override void Unpack(Unpacker unpacker)
 {
     base.Unpack(unpacker);
     ClientInfo = new ClientInfo(unpacker);
 }
 public static void Exec1(ClientInfo _cInfo, Entity _player, int _vehicle)
 {
     if (Inside_Claim)
     {
         World                world                 = GameManager.Instance.World;
         Vector3              _position             = _player.GetPosition();
         int                  x                     = (int)_position.x;
         int                  y                     = (int)_position.y;
         int                  z                     = (int)_position.z;
         Vector3i             _vec3i                = new Vector3i(x, y, z);
         PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList();
         PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_player.entityId);
         EnumLandClaimOwner   _owner                = world.GetLandClaimOwner(_vec3i, _persistentPlayerData);
         if (_owner == EnumLandClaimOwner.Self || _owner == EnumLandClaimOwner.Ally)
         {
             string _vehicleName = "";
             string _messageName = "";
             if (_vehicle == 1)
             {
                 _vehicleName = "vehicleBicycle";
                 _messageName = "bike";
             }
             if (_vehicle == 2)
             {
                 _vehicleName = "vehicleMinibike";
                 _messageName = "minibike";
             }
             if (_vehicle == 3)
             {
                 _vehicleName = "vehicleMotorcycle";
                 _messageName = "motorbike";
             }
             if (_vehicle == 4)
             {
                 _vehicleName = "vehicle4x4Truck";
                 _messageName = "jeep";
             }
             if (_vehicle == 5)
             {
                 _vehicleName = "vehicleGyrocopter";
                 _messageName = "gyro";
             }
             if (_player.AttachedToEntity.EntityClass.entityClassName.ToString() == _vehicleName)
             {
                 string _phrase781;
                 if (!Phrases.Dict.TryGetValue(781, out _phrase781))
                 {
                     _phrase781 = " saved your current vehicle for retrieval.";
                 }
                 ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase781 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 string _sql = "";
                 if (_vehicle == 1)
                 {
                     _sql = string.Format("UPDATE Vehicles SET bikeId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId);
                 }
                 if (_vehicle == 2)
                 {
                     _sql = string.Format("UPDATE Vehicles SET miniBikeId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId);
                 }
                 if (_vehicle == 3)
                 {
                     _sql = string.Format("UPDATE Vehicles SET motorBikeId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId);
                 }
                 if (_vehicle == 4)
                 {
                     _sql = string.Format("UPDATE Vehicles SET jeepId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId);
                 }
                 if (_vehicle == 5)
                 {
                     _sql = string.Format("UPDATE Vehicles SET gyroId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId);
                 }
                 SQL.FastQuery(_sql);
             }
             else
             {
                 string _phrase787;
                 if (!Phrases.Dict.TryGetValue(787, out _phrase787))
                 {
                     _phrase787 = " you are on the wrong vehicle to save it with this command. You are using a {Vehicle}.";
                 }
                 _phrase787 = _phrase787.Replace("{Vehicle}", _messageName);
                 ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase787 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
             }
         }
         else
         {
             string _phrase780;
             if (!Phrases.Dict.TryGetValue(780, out _phrase780))
             {
                 _phrase780 = " you have not claimed this space or a friend. You can only save your vehicle inside a claimed space.";
             }
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase780 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
     else
     {
         string _vehicleName = "";
         string _messageName = "";
         if (_vehicle == 1)
         {
             _vehicleName = "vehicleBicycle";
             _messageName = "bike";
         }
         if (_vehicle == 2)
         {
             _vehicleName = "vehicleMinibike";
             _messageName = "minibike";
         }
         if (_vehicle == 3)
         {
             _vehicleName = "vehicleMotorcycle";
             _messageName = "motorbike";
         }
         if (_vehicle == 4)
         {
             _vehicleName = "vehicle4x4Truck";
             _messageName = "jeep";
         }
         if (_vehicle == 5)
         {
             _vehicleName = "vehicleGyrocopter";
             _messageName = "gyro";
         }
         if (_player.AttachedToEntity.name == _vehicleName)
         {
             string _phrase781;
             if (!Phrases.Dict.TryGetValue(781, out _phrase781))
             {
                 _phrase781 = " saved your current vehicle for retrieval.";
             }
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase781 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
             string _sql = "";
             if (_vehicle == 1)
             {
                 _sql = string.Format("UPDATE Vehicles SET bikeId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId);
             }
             if (_vehicle == 2)
             {
                 _sql = string.Format("UPDATE Vehicles SET miniBikeId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId);
             }
             if (_vehicle == 3)
             {
                 _sql = string.Format("UPDATE Vehicles SET motorBikeId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId);
             }
             if (_vehicle == 4)
             {
                 _sql = string.Format("UPDATE Vehicles SET jeepId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId);
             }
             if (_vehicle == 5)
             {
                 _sql = string.Format("UPDATE Vehicles SET gyroId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId);
             }
             SQL.FastQuery(_sql);
         }
         else
         {
             string _phrase787;
             if (!Phrases.Dict.TryGetValue(787, out _phrase787))
             {
                 _phrase787 = " you are on the wrong vehicle to save it with this command. You are using a {Vehicle}.";
             }
             _phrase787 = _phrase787.Replace("{Vehicle}", _messageName);
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase787 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
 }
예제 #53
0
 public List <WorkLocation> GetWorkLocations(ClientInfo client)
 {
     return(GetPayrollCollectionItem <WorkLocation>(client));
 }
        public static void Exec2(ClientInfo _cInfo, Entity _player, int _vehicle)
        {
            string _sql = "";

            if (_vehicle == 1)
            {
                _sql = string.Format("SELECT bikeId FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId);
            }
            if (_vehicle == 2)
            {
                _sql = string.Format("SELECT miniBikeId FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId);
            }
            if (_vehicle == 3)
            {
                _sql = string.Format("SELECT motorBikeId FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId);
            }
            if (_vehicle == 4)
            {
                _sql = string.Format("SELECT jeepId FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId);
            }
            if (_vehicle == 5)
            {
                _sql = string.Format("SELECT gyroId FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId);
            }
            DataTable _result = SQL.TQuery(_sql);
            int       _Id;

            int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _Id);
            _result.Dispose();
            if (_Id != 0)
            {
                List <Entity> Entities = GameManager.Instance.World.Entities.list;
                for (int i = 0; i < Entities.Count; i++)
                {
                    Entity _entity = Entities[i];
                    if (!_entity.IsClientControlled())
                    {
                        if (_entity.entityId == _Id)
                        {
                            if ((_player.position.x - _entity.position.x) * (_player.position.x - _entity.position.x) + (_player.position.z - _entity.position.z) * (_player.position.z - _entity.position.z) <= 50 * 50)
                            {
                                if (_entity.AttachedToEntity == false)
                                {
                                    _entity.SetPosition(_player.position);
                                    string _phrase782;
                                    if (!Phrases.Dict.TryGetValue(782, out _phrase782))
                                    {
                                        _phrase782 = " found your vehicle and sent it to you.";
                                    }
                                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase782 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);

                                    if (Wallet.IsEnabled && Command_Cost >= 1)
                                    {
                                        Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost);
                                    }
                                    if (_vehicle == 1)
                                    {
                                        _sql = string.Format("UPDATE Vehicles SET lastBike = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
                                    }
                                    if (_vehicle == 2)
                                    {
                                        _sql = string.Format("UPDATE Vehicles SET lastMiniBike = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
                                    }
                                    if (_vehicle == 3)
                                    {
                                        _sql = string.Format("UPDATE Vehicles SET lastMotorBike = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
                                    }
                                    if (_vehicle == 4)
                                    {
                                        _sql = string.Format("UPDATE Vehicles SET lastJeep = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
                                    }
                                    if (_vehicle == 5)
                                    {
                                        _sql = string.Format("UPDATE Vehicles SET lastGyro = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
                                    }

                                    SQL.FastQuery(_sql);
                                    return;
                                }
                                else
                                {
                                    string _phrase785;
                                    if (!Phrases.Dict.TryGetValue(785, out _phrase785))
                                    {
                                        _phrase785 = " found your vehicle but someone else is on it.";
                                    }
                                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase785 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                    return;
                                }
                            }
                        }
                    }
                }
                string _phrase784;
                if (!Phrases.Dict.TryGetValue(784, out _phrase784))
                {
                    _phrase784 = " could not find your vehicle near by.";
                }
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase784 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
            else
            {
                string _phrase783;
                if (!Phrases.Dict.TryGetValue(783, out _phrase783))
                {
                    _phrase783 = " you do not have this vehicle type saved.";
                }
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase783 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
        }
예제 #55
0
        private List <T> GetPayrollCollectionItem <T>(ClientInfo client) where T : PayrollCollectionItem
        {
            var response = _connector.SendEncryptedRequest <T>(client.GetCollectionRequestByType, typeof(T));

            return(response?.Results as List <T>);
        }
예제 #56
0
 public void SetClientInfo(ClientInfo info)
 {
 }
예제 #57
0
        public static void Do(ClientInfo clientInfo, string data)
        {
            C2S_LeaveRoom c2s = JsonConvert.DeserializeObject <C2S_LeaveRoom>(data);

            RoomManager.deleteUser(clientInfo);
        }
예제 #58
0
        public static bool Execute(ClientInfo sender, List <string> arguments)
        {
            World        world        = GameManager.Instance.World;
            EntityPlayer entityPlayer = world.Players.dict[sender.entityId];

            Vector3 playerLocation = entityPlayer.getBellyPosition();
            string  xyz            = string.Format("X: [FFDC00]{0}[DDDDDD], Y: [FFDC00]{1}[DDDDDD], Z: [FFDC00]{2}",
                                                   playerLocation.x,
                                                   playerLocation.y,
                                                   playerLocation.z
                                                   );

            // Prints current position
            if (arguments.Count == 0)
            {
                string msg = string.Format("[DDDDDD]Player: [FFDC00]{0}[DDDDDD], {1}",
                                           sender.playerName.Trim(),
                                           xyz
                                           );

                ChatManager.Message(sender, msg);
                return(false);
            }
            // Lobby or map
            else if (arguments.Count >= 1)
            {
                if (arguments[0] == "lobby")
                {
                    VariableContainer.SetLobbyPosition(playerLocation);

                    string msg = string.Format("[DDDDDD]New pos for: [FFDC00]Lobby[DDDDDD], {0}", xyz);

                    ChatManager.Message(sender, msg);
                    return(false);
                }

                // Must be map id
                string mapId = arguments[0].Trim();

                if (!VariableContainer.MapExists(mapId))
                {
                    VariableContainer.AddMap(new Map(mapId));
                    ChatManager.Message(sender, "[DDDDDD]Created new Map: [FFDC00]" + mapId);
                }

                Map map = VariableContainer.GetMap(mapId);

                string spawnFor = "team";

                if (arguments.Count >= 2)
                {
                    spawnFor = arguments[1].Trim();
                }

                if (arguments.Count >= 3)
                {
                    if (arguments[2].Trim() == "-d")
                    {
                        if (!map.spawns.ContainsKey(spawnFor))
                        {
                            ChatManager.Message(sender, string.Format("[DDDDDD]Group [FFDC00]{0} [DDDDDD]does not exist", spawnFor));
                            return(false);
                        }

                        // Delete latest
                        int index = map.spawns[spawnFor].Count - 1;

                        if (arguments.Count == 4)
                        {
                            try
                            {
                                index = int.Parse(arguments[3].Trim());
                            } catch { }
                        }

                        map.spawns[spawnFor].RemoveAt(index);
                        if (map.spawns[spawnFor].Count == 0)
                        {
                            map.spawns.Remove(spawnFor);
                            ChatManager.Message(sender, string.Format("[DDDDDD]Group [FFDC00]{0}[DDDDDD] at map [FFDC00]{1}[DDDDDD] has been deleted", spawnFor, mapId));
                        }
                        else
                        {
                            ChatManager.Message(sender, string.Format("[DDDDDD]Removed spawn for group [FFDC00]{0}[DDDDDD] at map [FFDC00]{1}", spawnFor, mapId));
                        }
                    }
                    else
                    {
                        ChatManager.Message(sender, "[DDDDDD]Usage: /pos mapId spawnGroup [FFDC00]-d [index]");
                        return(false);
                    }
                }
                else
                {
                    // Add spawn for group
                    map.AddSpawn(spawnFor, playerLocation);
                    ChatManager.Message(sender, string.Format("[DDDDDD]New pos for: [FFDC00]{0} ({1})[DDDDDD], {2}", mapId, spawnFor, xyz));
                }

                // Save
                VariableContainer.SetMap(map);
                Configs.Save();
                return(false);
            }
            else
            {
                ChatManager.Message(sender, "[DDDDDD]Usage: [FFDC00]/pos [lobby/mapId] [spawnGroup] [-d [index]]");
                return(false);
            }
        }
예제 #59
0
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params.Count < 1 || _params.Count > 2)
         {
             SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 1 or 2, found {0}", _params.Count));
             return;
         }
         if (_params[0].ToLower().Equals("off"))
         {
             if (VoteReward.IsEnabled)
             {
                 VoteReward.IsEnabled = false;
                 Config.WriteXml();
                 SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Vote reward has been set to off"));
                 return;
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Vote reward is already off"));
                 return;
             }
         }
         else if (_params[0].ToLower().Equals("on"))
         {
             if (!VoteReward.IsEnabled)
             {
                 VoteReward.IsEnabled = true;
                 Config.WriteXml();
                 SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Vote reward has been set to on"));
                 return;
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Vote reward is already on"));
                 return;
             }
         }
         else if (_params[0].ToLower().Equals("reset"))
         {
             if (_params.Count != 2)
             {
                 SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] 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)
                     {
                         PersistentContainer.Instance.Players[_cInfo2.playerId].LastVote = DateTime.Now.AddYears(-1);
                         SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Vote reward delay reset for {0}", _cInfo2.playerName));
                     }
                 }
                 return;
             }
             if (_params[1].ToLower().Equals("all"))
             {
                 for (int i = 0; i < PersistentContainer.Instance.Players.SteamIDs.Count; i++)
                 {
                     string           _id = PersistentContainer.Instance.Players.SteamIDs[i];
                     PersistentPlayer p   = PersistentContainer.Instance.Players[_id];
                     {
                         PersistentContainer.Instance.Players[_id].LastVote = DateTime.Now.AddYears(-1);
                     }
                 }
                 SdtdConsole.Instance.Output("[SERVERTOOLS] Vote reward delay reset for all players");
                 return;
             }
             else
             {
                 ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]);
                 if (_cInfo != null)
                 {
                     PersistentContainer.Instance.Players[_cInfo.playerId].LastVote = DateTime.Now.AddYears(-1);
                     SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Vote reward delay reset for {0}", _cInfo.playerName));
                 }
                 else
                 {
                     if (_params[1].Length != 17)
                     {
                         SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Can not reset Id: Invalid Id {0}", _params[1]));
                         return;
                     }
                     PersistentPlayer p = PersistentContainer.Instance.Players[_params[1]];
                     if (p != null)
                     {
                         PersistentContainer.Instance.Players[_params[1]].LastVote = DateTime.Now.AddYears(-1);
                         SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Vote reward delay reset for {0}", _params[1]));
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a Vote reward delay to reset", _params[1]));
                     }
                 }
             }
         }
         else
         {
             SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Invalid argument {0}", _params[0]));
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in VotingConsole.Execute: {0}", e.Message));
     }
 }
예제 #60
0
 public BaseController(ClientInfo clientInfo)
 {
     ClientInfo = clientInfo;
 }