Beispiel #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            SampRegistry sr = new SampRegistry();

            sr.Default();
            if (!sr.Check())
            {
                sr.Create();
            }
            else if (!sr.Valid())
            {
                sr.Write();
            }
            else
            {
                sr.Read();
            }

            this.textName.Text = sr.PlayerName;

            if (Launcher.Locked)
            {
                this.textPassword.Enabled = true;
                this.textPassword.Text    = String.Empty;
            }
            else
            {
                this.textPassword.Enabled = false;
                this.textPassword.Text    = "0123456789";
            }
#if DEBUG
            UserStats stats = new UserStats();

            stats.UserName = textName.Text;
            stats.IpAddress();
            stats.Read();
            stats.Send();
#endif
        }
Beispiel #2
0
        private void ButtonLogin_Click(object sender, EventArgs e)
        {
            if (this.textName.Text.ToLower() == "ime_prezime")
            {
                MessageTitle title = new MessageTitle();

                string message = "Korisnièko ime ne može biti poèetno postaljeno (Ime_Prezime).\n" +
                                 "Unesite vaše korisnièko za prijavu na server formata 'Ime_Prezime'.";

                MessageBoxAdv.Show(message, title.ErrorMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (this.textName.Text.Length < 4)
            {
                MessageTitle title = new MessageTitle();
                string       text  = "Korisnièko ime mora sadržavati najmanje 4 karaktera.\nFormat korisnièkog imena mora biti 'Ime_Prezime'.";
                MessageBoxAdv.Show(text, title.ErrorMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.textName.Text = "Ime_Prezime";
                //this.Show();
                return;
            }

            if (this.textName.Text.Length > 21)
            {
                MessageTitle title = new MessageTitle();
                string       text  = "Korisnièko ime može imati najviše 21 karakter.\nFormat korisnièkog imena mora biti 'Ime_Prezime'.";
                MessageBoxAdv.Show(text, title.ErrorMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.textName.Text = "Ime_Prezime";
                //this.Show();
                return;
            }

            //if (!this.textName.Text.Contains("_"))
            //{
            //    MessageTitle title = new MessageTitle();
            //    string text = "Korisnièko ime mora sadržavati znak '_' u sebi.\nFormat korisnièkog imena mora biti 'Ime_Prezime'.";
            //    MessageBoxAdv.Show(text, title.ErrorMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    this.textName.Text = "Ime_Prezime";
            //    //this.Show();
            //    return;
            //}

            //if (this.textName.Text.Contains("_"))
            //{
            //    string temp = this.textName.Text.Remove(this.textName.Text.IndexOf("_"), 1);
            //    if (temp.Contains("_"))
            //    {
            //        MessageTitle title = new MessageTitle();
            //        string text = "Korisnièko ime može samo sadržavati jednu donju-crtu '_'.\nFormat korisnièkog imena mora biti 'Ime_Prezime'.";
            //        MessageBoxAdv.Show(text, title.ErrorMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
            //        this.textName.Text = "Ime_Prezime";
            //        //this.Show();
            //        return;
            //    }
            //}

            if (!Regex.IsMatch(this.textName.Text, @"^[a-zA-Z_]+$"))
            {
                MessageTitle title = new MessageTitle();
                string       text  = String.Format("Korisnièko ime može sadržavati samo slova i znak donje-crte '_'.\nFormat korisnièkog imena mora biti 'Ime_Prezime', maksimalne dužine 21 karakter.");
                MessageBoxAdv.Show(text, title.ErrorMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.textName.Text = "Ime_Prezime";
                return;
            }

            //string name = this.textName.Text.Substring(0, this.textName.Text.IndexOf("_"));
            //string surname = this.textName.Text.Substring(this.textName.Text.IndexOf("_") + 1);

            //if (name.Length < 3 || surname.Length < 4)
            //{
            //    MessageTitle title = new MessageTitle();
            //    string text = "Dio 'Ime' može imati najamnje 3 slova, dok 'Prezime' najmanje 4 slova.\nFormat korisnièkog imena mora biti 'Ime_Prezime', maksimalne dužine 21 karakter.";
            //    MessageBoxAdv.Show(text, title.ErrorMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    this.textName.Text = "Ime_Prezime";
            //    //this.Show();
            //    return;
            //}

            //if (name.Substring(0, 1) != name.Substring(0, 1).ToUpper())
            //{
            //    MessageTitle title = new MessageTitle();
            //    string text =String.Format("Dio '{0}' mora poèinjati velikim slovom.\nFormat korisnièkog imena mora biti 'Ime_Prezime'.", name);
            //    MessageBoxAdv.Show(text, title.ErrorMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    this.textName.Text = "Ime_Prezime";
            //    return;
            //}

            //if (surname.Substring(0, 1) != surname.Substring(0, 1).ToUpper())
            //{
            //    MessageTitle title = new MessageTitle();
            //    string text = String.Format("Dio '{0}' mora poèinjati velikim slovom.\nFormat korisnièkog imena mora biti 'Ime_Prezime'.", surname);
            //    MessageBoxAdv.Show(text, title.ErrorMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    this.textName.Text = "Ime_Prezime";
            //    return;
            //}

            Process[] sampRun = Process.GetProcessesByName("samp");
            if (sampRun.Length > 0)
            {
                MessageTitle title = new MessageTitle();
                string       text  = "Imate veæ pokrenutu SAMP aplikaciju, zatvorite je!";
                MessageBoxAdv.Show(text, title.ErrorMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Process[] gtaRun = Process.GetProcessesByName("gta_sa");
            if (gtaRun.Length > 0)
            {
                MessageTitle title = new MessageTitle();
                string       text  = "Imate veæ pokrenutu GTA San Andreas igru, zatvorite je!";
                MessageBoxAdv.Show(text, title.ErrorMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            SampRegistry sr = new SampRegistry();

            sr.Default();
            if (!sr.Check())
            {
                sr.Create();
            }
            //else if (!sr.Valid())
            //    sr.Write();
            else
            {
                sr.Read();
            }

            if (sr.PlayerName != this.textName.Text)
            {
                sr.PlayerName = this.textName.Text;
                sr.Write();
            }

            if (Launcher.Locked && Launcher.Password != this.textPassword.Text)
            {
                MessageTitle title = new MessageTitle();
                string       text  = "Columbia State server je zakljuèan, vaša lozinka je pogrešna.";
                MessageBoxAdv.Show(text, title.ErrorMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            ValidForm vf = new ValidForm();

            if (vf.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                vf = null;
                GC.Collect();

                ProcessStartInfo processInfo = new ProcessStartInfo();
                processInfo.FileName         = "samp.exe";
                processInfo.WorkingDirectory = @".\";
                processInfo.Arguments        = String.Format("{0} {1}", Launcher.Address, Launcher.Password);
                Process.Start(processInfo);

                Process host = new Process();
                host.StartInfo.FileName         = "host-cs.exe";
                host.StartInfo.Arguments        = "cs_silent14";
                host.StartInfo.WorkingDirectory = ".\\";
                host.Start();

                workerCheck.RunWorkerAsync();
                workerGame.RunWorkerAsync();
                workerHost.RunWorkerAsync();
                //this.Hide();
                //return;
            }
            else
            {
                //MessageTitle title = new MessageTitle();
                //string text = "Columbia State server je zakljuèan, vaša lozinka je pogrešna.";
                //MessageBoxAdv.Show(text, title.ErrorMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            //Application.Exit();
            return;
        }