The online racing simulator
Searching in All forums
(81 results)
jobans
Demo licensed
Maybe someone want to share their works?
jobans
Demo licensed
Anyone?
Need some help with code.
jobans
Demo licensed
Hello! I was making InSim which would put 1st place against 16th then 2nd vs 15, 3rd vs 14 etc. and would print it out as a list with buttons. Got stuck in this place cant figure out how to get that ot work. Hope someone could help. I edited this code here so there can be some mistakes but I put it just so you could understand what im talking about. Each place is stored in seperate user file.


<?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(6f.Length 10) != "")
                        {
                            
string name f.Substring(6f.Length 10);


                            
byte place;

                            
placeConvert.ToByte(FileInfo.GetUserVieta(name));
}


InSim.Send_BTN_CreateButton("^7Name"Flags.ButtonStyles.ISB_C1 Flags.ButtonStyles.ISB_DARK540251142C.UniqueID40false);
                        
InSim.Send_BTN_CreateButton(""Flags.ButtonStyles.ISB_DARK70402515C.UniqueID40false);

                        
InSim.Send_BTN_CreateButton("^1" 1stplace  " ^1vs " 16thplaceFlags.ButtonStyles.ISB_LEFT540LocationX1ButtonID1C.UniqueID40false);

LocationX += 5;
                        
ButtonID1++;
}

?>

jobans
Demo licensed
Could someone update links please? Hope someone still got this
jobans
Demo licensed
Oh, thanks
jobans
Demo licensed
Mybe I need to make different storage? If yes could you tell me how would it look like?
Last edited by jobans, .
jobans
Demo licensed
Can you update site? http://denisbatya.narod.ru/ It doesnt work anymore
jobans
Demo licensed
No I cant.
jobans
Demo licensed
Thanksm but how can I make it to send buttons to LFS. I cant get it to print results in any way to LFS.
jobans
Demo licensed
So I need to add something like this?

<?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(6f.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("");
                }
            }
        }
?>

Cant get it to work
Last edited by jobans, .
jobans
Demo licensed
Help please, this is just so close!
jobans
Demo licensed
Thanks MadCatX awesome as always 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?

EDIT: I got that it sorts each score in each user file. But I need it to sort all scores from all user files and print out Users from biggest to lowest score.
Last edited by jobans, .
jobans
Demo licensed
Those points are saved in each user file. Could you please show some example with code?
Sorting.
jobans
Demo licensed
Hello. 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);

So how to make it to do that?
jobans
Demo licensed
Nice Thanks.
Black screen help.
jobans
Demo licensed
Hello. I was wondering is it possible to get black screen to connection through BTN? Well there is ISB_DARK but I want it to be fully black so that user cant see through. I tried to put a lot of big symbols but it just looked lame Any idea?

Thanks.
jobans
Demo licensed
No idea?
jobans
Demo licensed
I added this
double Vx = (-211 - Conn.CompCar.X / 196608);
double Vy = (-90 - Conn.CompCar.Y / 196608);

And this
Alpha = Alpha * 180 / Math.PI;

But I still get those big negative numbers. Any idea why?


EDIT: I made that it shows me directions to that destination Already thought that I ahve done it but when I changed coordinates to different place, it shows the same direction.
Last edited by jobans, .
jobans
Demo licensed
This was right formula, wasnt it?
Alpha = Alpha * 180 / Math.PI;

Still get same results. I think I just need some sleep. Goodnight
Last edited by jobans, . Reason : Wrong formula
jobans
Demo licensed
Added this to convert Alpha to degrees
Alpha = Alpha * 3.14 / 180;

Results look the same, will check those coordinates tomorrow.
Thanks for help

EDIT: Results are about from -65 000 to 0.
Last edited by jobans, .
jobans
Demo licensed
Tried something like this, but all I get is minus values. Im not sure about that vector V. You wrote
Quote :Getting V is easy: V = B - A = (B.x - A.x; B.y - A.y)

What is B.x and A.x ? Where is the mistake in this?
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);
}

Thank you.
jobans
Demo licensed
MadCatX please answer
jobans
Demo licensed
Still waiting :/
jobans
Demo licensed
And what about those calculations above? Cant get them to work right could you tell me whats wrong?
FGED GREDG RDFGDR GSFDG