
<?php
foreach (clsConnection C in Connections)
{
byte LocationX = 31;
byte ButtonID1 = 10;
byte ButtonID2 = 60;
byte ButtonID3 = 120;
byte ButtonID4 = 180;
string[] files = Directory.GetFiles(@"users", "*.txt");
if (files.Length < 1)
{
Console.WriteLine("No files.");
InSim.Send_MST_Message("No files.");
}
foreach (string f in files)
{
if (f.Substring(6, f.Length - 10) != "")
{
string name = f.Substring(6, f.Length - 10);
byte place;
place= Convert.ToByte(FileInfo.GetUserVieta(name));
}
InSim.Send_BTN_CreateButton("^7Name", Flags.ButtonStyles.ISB_C1 | Flags.ButtonStyles.ISB_DARK, 5, 40, 25, 1, 142, C.UniqueID, 40, false);
InSim.Send_BTN_CreateButton("", Flags.ButtonStyles.ISB_DARK, 70, 40, 25, 1, 5, C.UniqueID, 40, false);
InSim.Send_BTN_CreateButton("^1" + 1stplace + " ^1vs " + 16thplace, Flags.ButtonStyles.ISB_LEFT, 5, 40, LocationX, 1, ButtonID1, C.UniqueID, 40, false);
LocationX += 5;
ButtonID1++;
}
?>

<?php
void SortAndPrint()
{
Dictionary<string, List<int>> scores = new Dictionary<string, List<int>>();
Dictionary<string, List<int>> results = new Dictionary<string, List<int>>();
string[] files = Directory.GetFiles(@"users", "*.txt");
if (files.Length == 0)
{
MsgAll("No files.");
return;
}
foreach (string f in files)
{
string name = f.Substring(6, f.Length - 10); /* No trailing ".txt" and leading "./" */
string[] lines;
try
{
lines = System.IO.File.ReadAllLines(f);
}
catch (Exception e)
{
MsgAll(e.ToString());
continue;
}
scores.Add(name, new List<int>());
foreach (string s in lines)
{
int val;
try
{
val = Convert.ToInt32(s);
}
catch (Exception)
{
continue;
}
scores[name].Add(val);
}
scores[name].Sort();
results.Add(name, new List<int>());
foreach (int s in scores[name])
{
results[name].Add(Convert.ToInt32(scores[name]));
}
results[name].Sort();
}
foreach (KeyValuePair<string, List<int>> pair in results)
{
MsgAll("--- " + pair.Key);
foreach (int i in pair.Value)
{
MsgAll(i + "");
}
}
}
?>
So I save those score like this - everyone have his Username.txt file and in that file he has his score. Now it prints me out users with their score in their username.txt order as they are in Users folder. How to get it to print with biggest score first?
I am making application that will fix score and then I want it to make list of players like 1st place 2nd etc. Some example:foreach (clsConnection c in Connections)
{
if (c.Username != "")
{
InSim.Send_BTN_CreateButton(c.PlayerName, Flags.ButtonStyles.ISB_LEFT, 5, 15, LocationX, 1, ButtonID1, C.UniqueID, 40, false);
InSim.Send_BTN_CreateButton("^7 " + c.Score, Flags.ButtonStyles.ISB_CLICK, 5, 10, LocationX, 16, ButtonID2, (C.UniqueID), 40, false);
Any idea?double Vx = (-211 - Conn.CompCar.X / 196608);
double Vy = (-90 - Conn.CompCar.Y / 196608);Alpha = Alpha * 180 / Math.PI;Alpha = Alpha * 180 / Math.PI;
Alpha = Alpha * 3.14 / 180;
if (Conn.Username == "jobans")
{
double Vx = (-211 - Conn.CompCar.X); // -211 Destination X
double Vy = (-90 - Conn.CompCar.Y); // -90 Destination Y
double Alpha = Math.Atan2(Vy, Vx);
if (Vy < 0)
{
Alpha = 2 * Math.PI + Alpha;
}
else
{
Alpha = Alpha;
}
double Beta = Conn.CompCar.Heading + 90;
if (Beta >= 360)
{
Beta = Beta - 360;
}
double R = Alpha - Beta;
InSim.Send_BTN_CreateButton("^1" + R, Flags.ButtonStyles.ISB_DARK, 4, 25, 40, 60, 51, C.UniqueID, 2, false);
}