Exemple #1
0
        private void ButtonGorunumu(InSim insim, IS_MCI mci)
        {
            try
            {
                IS_NCN   conn     = new IS_NCN();
                string[] buttons1 =
                {
                    string.Format(textBox1.Text),
                    string.Format(textBox2.Text),
                    string.Format(textBox3.Text),
                    string.Format(textBox4.Text),
                };

                for (byte i = 0, id = 1, top = (byte)numericUpDown1.Value; i < buttons1.Length; i++, id++, top += (byte)numericUpDown5.Value)
                {
                    insim.Send(new IS_BTN
                    {
                        ReqI    = 255,
                        UCID    = conn.UCID,
                        ClickID = id,
                        BStyle  = ButtonStyles.ISB_DARK | ButtonStyles.ISB_LEFT,
                        T       = top,
                        L       = (byte)numericUpDown2.Value,
                        W       = (byte)numericUpDown3.Value,
                        H       = (byte)numericUpDown4.Value,
                        Text    = buttons1[i],
                    });
                }


                string[] buttons2 =
                {
                    string.Format(textBox5.Text),
                    string.Format(textBox6.Text),
                    string.Format(textBox7.Text),
                    string.Format(textBox8.Text),
                };

                for (byte i = 0, id = 5, top = (byte)numericUpDown6.Value; i < buttons2.Length; i++, id++, top += (byte)numericUpDown10.Value)
                {
                    insim.Send(new IS_BTN
                    {
                        ReqI    = 255,
                        UCID    = conn.UCID,
                        ClickID = id,
                        BStyle  = ButtonStyles.ISB_DARK | ButtonStyles.ISB_LEFT,
                        T       = top,
                        L       = (byte)numericUpDown7.Value,
                        W       = (byte)numericUpDown8.Value,
                        H       = (byte)numericUpDown9.Value,
                        Text    = buttons2[i],
                    });
                }
            }
            catch { }
        }
        public static void NCN(InSim insim, IS_NCN NCN)
        {
            try
            {
                Connections._connections.Add(NCN.UCID, new Connections
                {
                    UCID          = NCN.UCID,
                    UName         = NCN.UName,
                    PName         = NCN.PName,
                    Administrator = NCN.Admin
                });

                foreach (Connections Conn in Connections._connections.Values)
                {
                    if (Conn.UCID == NCN.UCID)
                    {
                        Interface.Message.Send($"^7Olá, ^6{Conn.UName}", Conn.UCID);
                    }
                }
            }
            catch (InSimException IEx) { Logger.Error(IEx.Message, Logger.Types.NCN); }
        }
Exemple #3
0
 private void NewConnection(InSim insim, IS_NCN ncn)
 {
     Console.WriteLine("IS_NCN pack received" + ncn.PName);
     players.SetName(ncn.UCID, ncn.PName);
     newestOnSeverName = ncn.PName;
 }
Exemple #4
0
        // Player joins server
        void NewConnection(InSim insim, IS_NCN NCN)
        {
            try
            {
                _connections.Add(NCN.UCID, new Connections
                {
                    UCID    = NCN.UCID,
                    UName   = NCN.UName,
                    PName   = NCN.PName,
                    IsAdmin = NCN.Admin,

                    IsSuperAdmin  = GetUserAdmin(NCN.UName),
                    OnTrack       = false,
                    TotalDistance = 0,
                    Pitstops      = 0,
                    points        = 0
                });

                if (ConnectedToSQL)
                {
                    try
                    {
                        if (SqlInfo.UserExist(NCN.UName))
                        {
                            // SqlInfo.UpdateUser(NCN.UName, true);//Updates the last joined time to the current one

                            string[] LoadedOptions = SqlInfo.LoadUserOptions(NCN.UName);
                            _connections[NCN.UCID].TotalDistance = Convert.ToInt32(LoadedOptions[0]);
                            _connections[NCN.UCID].points        = Convert.ToInt32(LoadedOptions[1]);

                            // Welcome messages
                            insim.Send(NCN.UCID, "^8Welcome back, " + NCN.PName);
                        }
                        else
                        {
                            SqlInfo.AddUser(NCN.UName, StringHelper.StripColors(_connections[NCN.UCID].PName), _connections[NCN.UCID].TotalDistance, _connections[NCN.UCID].points);
                        }
                    }
                    catch (Exception EX)
                    {
                        if (!SqlInfo.IsConnectionStillAlive())
                        {
                            ConnectedToSQL = false;
                            SQLReconnectTimer.Start();
                        }
                        else
                        {
                            Console.WriteLine("NCN(Add/Load)User - " + EX.Message);
                        }
                    }
                }

                if (NCN.UName != "")
                {
                    try
                    {
                    }
                    catch (Exception EX)
                    {
                        LogTextToFile("InSim-Errors", "[" + NCN.UCID + "] " + StringHelper.StripColors(NCN.PName) + "(" + NCN.UName + ") NCN - Exception: " + EX, false);
                    }
                }

                UpdateGui(NCN.UCID, true);
            }
            catch (Exception e) { LogTextToFile("InSim-Errors", "[" + NCN.UCID + "] " + StringHelper.StripColors(NCN.PName) + "(" + NCN.UName + ") NCN - Exception: " + e, false); }
        }
Exemple #5
0
        // Player joins server
        void NewConnection(InSim insim, IS_NCN packet)
        {
            try
            {
                _connections.Add(packet.UCID, new Connections
                {
                    UCID    = packet.UCID,
                    UName   = packet.UName,
                    PName   = packet.PName,
                    IsAdmin = packet.Admin,

                    IsSuperAdmin  = GetUserAdmin(packet.UName),
                    OnTrack       = false,
                    TotalDistance = 0,
                    cash          = 1,
                    bankbalance   = 0,
                    cars          = "UF1, XFG, XRG",
                    regdate       = "0.0.0"
                });


                if (ConnectedToSQL)
                {
                    try
                    {
                        if (SqlInfo.UserExist(packet.UName))
                        {
                            SqlInfo.UpdateUser(packet.UName, true);//Updates the last joined time to the current one

                            string[] LoadedOptions = SqlInfo.LoadUserOptions(packet.UName);
                            _connections[packet.UCID].cash                = Convert.ToInt32(LoadedOptions[0]);
                            _connections[packet.UCID].bankbalance         = Convert.ToInt32(LoadedOptions[1]);
                            _connections[packet.UCID].TotalDistance       = Convert.ToInt32(LoadedOptions[2]);
                            _connections[packet.UCID].cars                = LoadedOptions[3];
                            _connections[packet.UCID].regdate             = LoadedOptions[4];
                            _connections[packet.UCID].lastseen            = LoadedOptions[5];
                            _connections[packet.UCID].totaljobsdone       = Convert.ToInt32(LoadedOptions[6]);
                            _connections[packet.UCID].totalearnedfromjobs = Convert.ToInt32(LoadedOptions[7]);
                        }
                        else
                        {
                            SqlInfo.AddUser(packet.UName, _connections[packet.UCID].cash, _connections[packet.UCID].bankbalance, _connections[packet.UCID].TotalDistance, _connections[packet.UCID].cars, _connections[packet.UCID].regdate, _connections[packet.UCID].lastseen, _connections[packet.UCID].totaljobsdone, _connections[packet.UCID].totalearnedfromjobs);
                        }
                    }
                    catch (Exception EX)
                    {
                        if (!SqlInfo.IsConnectionStillAlive())
                        {
                            ConnectedToSQL = false;
                            SQLReconnectTimer.Start();
                        }
                        else
                        {
                            Console.WriteLine("NCN(Add/Load)User - " + EX.Message);
                        }
                    }
                }

                #region ' Retrieve HostName '
                if (packet.UCID == 0 && packet.UName == "")
                {
                    HostName = packet.PName;
                }
                #endregion

                if (packet.ReqI == 0)
                {
                    insim.Send(packet.UCID, "^8Current track: ^3" + TrackHelper.GetFullTrackName(TrackName));
                }
            }
            catch (Exception e)
            {
                var conn = _players[packet.UCID];
                conn.NoColPlayername = StringHelper.StripColors(conn.PName);

                LogTextToFile("error", "[" + conn.UCID + "] " + conn.NoColPlayername + "(" + _connections[packet.UCID].UName + ") NCN - Exception: " + e, false);
            }
        }