The online racing simulator
.NET C# - Open Source Race App (using LFS_External) (-OsR- Old skool Racing)
I believe that this is by far the most successful project I have worked on in my LFS time. And since I'm not really active in LFS lately, and -OsR- isn't up either, I decided to post the source of it. I really wanted to do this earlier, but I just couldn't find the time, or the mood.

Big thanks to:
T-RonX for LFS_External, which is used as the main base for this project;
DarkTimes for InSimSniffer, from which I stole a few things (yeah, again) ;
morpha for so much stuff, that I'm even lazy to write them down. Luv u {} (as a friend of course.. I'm not gay ..much);
dougie-lampkin for Open Source Cruise Server, from which I have learned the basics of C#.

And bah... Gotta include a license again, don't I?
I've always hated that part. But here goes..
On 2nd thought: I'm just going to stick with the MIT license, but still post it anyway:
Copyright (c) 2010 Loran Mutafov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Ok, so.. Some advices to get you started.
Database server configuration settings are in the dbProcess class.
It is pretty obvious which ones they are, but I would feel more comfortable if I show them to you here. So, there they are:

static public string dbServer = "database IP";
static public string dbPort = "database PORT | default: 3306";
static public string dbUser = "database USER";
static public string dbPass = "database PASS";
static public string dbDatabase = "database DATABASE";

It's more than obvious what's for what, so I'm not going to explain any further. I will attach an sql file, which you will need in order for the whole system to work as it should. You will see a lot of fields that aren't being used. That's cause I planned it to be a much bigger project, but I was just a lazy kid.

LFS Server configuration settings are being set in settings.ini. A file that should always be in the same folder as the built exe. In case you lose it, here is a copy of it as is when you first download the project:
Admin adminpassGOESHERE
Port portGOESHERE
IP ipGOESHERE
carsGlobStr 0111111111111111111111

Little explanation about that last line is probably what you want right now. Ok, so, basicaly, this is a string, representing the allowed cars, that users are able to pick for the next race.
The 01 in front of them, I think should not be changed, because it is read by the so called matrix system(it was my best invention at that time, and I knew nothing about binary, so I had to give it a killer name ). Basically, that 01 is doing nothing more but to tell the matrix functions that the string contains only 1 digit numbers.
For example: If you wanted the same string, but with 02 in front, you would have to put a zero in front of each 1 after that, or in other words: make it like that - 020101010101010101010101010101010101010101, so that ones can stay ones. That's just in case you want to use the matrix system for other purposes. It isn't really necessary at the current state of the insim, but I told you already: I had further plans for it. Had is the keyword.

Well, let me not keep you busy with more useless information. There's the source and have fun with it.
Attached files
-OsR- Racing - Public.zip - 1.4 MB - 1245 views
osr_table_sql.zip - 743 B - 952 views
sounds interesting i might test it
what are the features?
Not many really. But the idea behind this insim is what was unique.

Whenever you win a race, you get the chance to pick the car for the next race. You also win points, according to how many people you have raced off. For now, all you can do with those points is check your position in the rankings. There were supposed to be not only bronze points, but also silver, gold, platinum and global ones. But I never got to finish this tbh. I had a pretty cool plan on how to combine them all, but well... Graduating high school makes your life kinda busier..

Anyway, there are also a few little details for the racing too: If you join the race after the 1st person has made the 1st lap, you will not receive any points at the end. Making the 1st lap makes the insim "lock" the stats. Whenever you pit/join during the 1st lap the stats will update and include you in the scoring.

You may be wondering what the idea behind this is: Well, it's pretty simple. At the end the winner of the race wins points equal to the total racers. Each position below that wins 1 point less. This means that the last person would win 1p. Something like a prize to not feel like you've raced for nothing. ANYWAY, you wouldn't want to detect how many players there are on the track in the moment the 1st guy finishes, because if the race started with 2 people that would mean that he would win ..25 points for example, if there are 25 people on track. Instead, the number of racers stays dynamic until the 1st lap is made. Then it locks this number, along with a few other variables to make sure that nobody gets points at the end if they have joined AFTER that point. Pitting also counts - if you pit after the 1st lap you will not win any points from that race. But the winner still gets a point from you being in the race for the 1st lap.
Pretty simple I said, and wrote a wall of text.

There are some cool features too. Like the collision detection: If you have stopped somewhere on the track and somebody is coming fast towards you, you will get spectated at some point. When less than 1.5 seconds are left to impact iirc. The racing car receives warning window(s) about stopped car(s), so the racer can act appropriately, as you can't always rely on the insim, since when the speeds are too high the insim itself has less time to react, and sending a /spec message to the server slows the whole operation too. This may make racing less realistic, but stopping in the middle of the track itself isn't realistic(in most cases in LFS), cause clean racers spectate when they crash, and "bad" drivers just stop to make sure the race gets screwed. The windows show you times to impact, distances, player names and idk what else about the coming stopped cars. The insim takes action really at the last moment(especially when racing on Oval, since that's where OsR was on most of the time), so once again - beware, that's why there's a window too.

Also there was one unfinished thing about this. I really don't want to say it cause it may get exploted, but for the sake of the programmers: At the start, if someone jump starts - it spectates the driver in front, because the insim detects it as a dangerous situation. Yeah, kinda dull, but I never got around fixing this. Sorry.
One more thing: If the guy that has stopped is one or more laps ahead of you, they will not get spectated. It is something that I found necessary, I don't remember why. But I still see some logic in it.

And, that's about it I think. There may be more stuff, I don't really remember. But I told you the things I'm proud of and the things in them that I'm not proud of.

And WHEN the hell did I write all this.. I guess I'm still excited about my most successful C# project, haha..
I Have A Problem with The Database (mysql) i can´t let them Connect.
Help? PM, or in This Thread - Thx
Quote from marcel1 :I Have A Problem with The Database (mysql) i can´t let them Connect.
Help? PM, or in This Thread - Thx

What is the problem?
Who can't connect?
Provide some error message(s)? Provide some code maybe?
In this thread of course - what if anyone else encounters the same problem?
HI!, I start it and Then it shows me This message.
see (attachment). Now my question How to "fix"?
Attached images
Database.jpg
Have you set up a database?
Is remote access allowed to the database(in case it's in another host)?
Have you created a users table, like the one in the sql file attached?
Have you changed the db connection settings in the insim(as said in the 1st post)?

This is not a problem from the insim, I am certain. But it is however it's protection, against connection problems.

In case anyone cares how it works: It tries to not mess up any user accounts. But in the moment someone disconnects and the database can't be reached - they lose the stats they have built till that moment. However, in case they have connected, while the db has been down, and they've made some points - when the connection is restored, those points will be summed up with the points from their account. Of course, if the db goes down, and you make some points on top of the ones loaded(from the db obviously) the previous time - they won't be summed up with the points from your account again, because that would be stupid.
That's why there's a !save command. And for admins there are also the !saveall and !save [user] commands.
I Think There is My Problem, i dont know how to set up a database !
could you please tell me HOW?
hm? how to start it? i downloaded it against and i cant start it up?O.o

FGED GREDG RDFGDR GSFDG