When i start the program, it simply freezes. I mean if i push any button, it doesn't work. Only button10 is working which is closing the form.
What is the problem here?
using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
using System.Windows. Forms;
using System.Diagnost ics;
using System.IO;
using System.Threadin g;
namespace Samp_cpanel
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}
Process p = new Process();
new bool running = false;
new bool loaded = false;
private void button1_Click(o bject sender, EventArgs e)
{
if (running == true)
{
MessageBox.Show ("Server already running!", "Error!");
}
else
{
p.StartInfo.Fil eName = "samp-server.exe";
p.Start();
running = true;
Thread.Sleep(20 0);
Query.Query sQuery = new Query.Query("76 .10.223.139", 7777);
sQuery.Send('i' );
int count = sQuery.Recieve( );
string[] info = sQuery.Store(co unt);
if (info.Length == 0)
{
hostname.Text = "The server is DOWN!";
}
else
{
Query.Query dQuery = new Query.Query("76 .10.223.139", 7777);
dQuery.Send('c' );
int c2 = dQuery.Recieve( );
string[] pl = dQuery.Store(c2 );
for (int i = 0; i < Convert.ToInt64 (info[1])*2; i++)
{
ListViewItem lvi = new ListViewItem(pl[i]);
lvi.SubItems.Ad d(pl[i + 1]);
listView1.Items .Add(lvi);
i++;
}
hostname.Text = info[3];
players.Text = info[1] + " / " + info[2];
mapname.Text = info[5];
gmtext.Text = info[4];
}
}
}
private void button2_Click(o bject sender, EventArgs e)
{
try
{
p.Kill();
running = false;
}
catch { }
}
private void Form1_Load(obje ct sender, EventArgs e)
{
}
private void button3_Click(o bject sender, EventArgs e)
{
try
{
p.Kill();
p.Start();
}
catch { }
}
private void button5_Click(o bject sender, EventArgs e)
{
textBox1.Text = File.ReadAllTex t("server.cfg") ;
loaded = true;
}
private void button4_Click(o bject sender, EventArgs e)
{
if (loaded == false)
{
MessageBox.Show ("You must load the cfg file", "Error!");
}
else
{
File.WriteAllTe xt("server.cfg" , textBox1.Text);
MessageBox.Show ("The cfg file was totally edited", "Success!") ;
}
}
private void button6_Click(o bject sender, EventArgs e)
{
Query.RCONQuery jQuery = new Query.RCONQuery (textBox5.Text, Convert.ToInt16 (textBox6.Text) , textBox7.Text);
if (textBox2.Text == "")
{
if (textBox3.Text == "")
{
if (textBox4.Text == "")
{
}
else
{
jQuery.Send("ma pname " + textBox4.Text);
}
}
else
{
jQuery.Send("ga memodetext " + textBox3.Text);
}
}
else
{
jQuery.Send("ho stname " + textBox2.Text);
}
}
private void textBox6_TextCh anged(object sender, EventArgs e)
{
}
private void button7_Click(o bject sender, EventArgs e)
{
Query.Query cQuery = new Query.Query("12 7.0.0.1", 7777);
cQuery.Send('i' );
int count = cQuery.Recieve( );
string[] info = cQuery.Store(co unt);
if (info.Length == 0)
{
hostname.Text = "Serverul este DOWN!";
players.Text = "";
mapname.Text = "";
gmtext.Text = "";
}
else
{
hostname.Text = info[3];
players.Text = info[1] + " / " + info[2];
mapname.Text = info[5];
gmtext.Text = info[4];
}
}
private void button10_Click( object sender, EventArgs e)
{
this.Close();
}
private void groupBox1_Enter (object sender, EventArgs e)
{
}
}
}
What is the problem here?
using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
using System.Windows. Forms;
using System.Diagnost ics;
using System.IO;
using System.Threadin g;
namespace Samp_cpanel
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}
Process p = new Process();
new bool running = false;
new bool loaded = false;
private void button1_Click(o bject sender, EventArgs e)
{
if (running == true)
{
MessageBox.Show ("Server already running!", "Error!");
}
else
{
p.StartInfo.Fil eName = "samp-server.exe";
p.Start();
running = true;
Thread.Sleep(20 0);
Query.Query sQuery = new Query.Query("76 .10.223.139", 7777);
sQuery.Send('i' );
int count = sQuery.Recieve( );
string[] info = sQuery.Store(co unt);
if (info.Length == 0)
{
hostname.Text = "The server is DOWN!";
}
else
{
Query.Query dQuery = new Query.Query("76 .10.223.139", 7777);
dQuery.Send('c' );
int c2 = dQuery.Recieve( );
string[] pl = dQuery.Store(c2 );
for (int i = 0; i < Convert.ToInt64 (info[1])*2; i++)
{
ListViewItem lvi = new ListViewItem(pl[i]);
lvi.SubItems.Ad d(pl[i + 1]);
listView1.Items .Add(lvi);
i++;
}
hostname.Text = info[3];
players.Text = info[1] + " / " + info[2];
mapname.Text = info[5];
gmtext.Text = info[4];
}
}
}
private void button2_Click(o bject sender, EventArgs e)
{
try
{
p.Kill();
running = false;
}
catch { }
}
private void Form1_Load(obje ct sender, EventArgs e)
{
}
private void button3_Click(o bject sender, EventArgs e)
{
try
{
p.Kill();
p.Start();
}
catch { }
}
private void button5_Click(o bject sender, EventArgs e)
{
textBox1.Text = File.ReadAllTex t("server.cfg") ;
loaded = true;
}
private void button4_Click(o bject sender, EventArgs e)
{
if (loaded == false)
{
MessageBox.Show ("You must load the cfg file", "Error!");
}
else
{
File.WriteAllTe xt("server.cfg" , textBox1.Text);
MessageBox.Show ("The cfg file was totally edited", "Success!") ;
}
}
private void button6_Click(o bject sender, EventArgs e)
{
Query.RCONQuery jQuery = new Query.RCONQuery (textBox5.Text, Convert.ToInt16 (textBox6.Text) , textBox7.Text);
if (textBox2.Text == "")
{
if (textBox3.Text == "")
{
if (textBox4.Text == "")
{
}
else
{
jQuery.Send("ma pname " + textBox4.Text);
}
}
else
{
jQuery.Send("ga memodetext " + textBox3.Text);
}
}
else
{
jQuery.Send("ho stname " + textBox2.Text);
}
}
private void textBox6_TextCh anged(object sender, EventArgs e)
{
}
private void button7_Click(o bject sender, EventArgs e)
{
Query.Query cQuery = new Query.Query("12 7.0.0.1", 7777);
cQuery.Send('i' );
int count = cQuery.Recieve( );
string[] info = cQuery.Store(co unt);
if (info.Length == 0)
{
hostname.Text = "Serverul este DOWN!";
players.Text = "";
mapname.Text = "";
gmtext.Text = "";
}
else
{
hostname.Text = info[3];
players.Text = info[1] + " / " + info[2];
mapname.Text = info[5];
gmtext.Text = info[4];
}
}
private void button10_Click( object sender, EventArgs e)
{
this.Close();
}
private void groupBox1_Enter (object sender, EventArgs e)
{
}
}
}
Comment