The online racing simulator
Crash insim
(23 posts, started )
Crash insim
Hello

I have one probleme

When one men write !pay 10000000 or more my insim crach ?

Could you help me ?

And one restart insim have create ?

Thanks you
kordan, learn to use search key my friend, here, there is a code bit, wich lets the players send no more then 75000
search
no kiss me 75000 is for send and when i give more 85000 i have one mess but here is now for send is for pay one men have write !pay 999999999 and inssim close

And other probleme sometime when insim crash one or two acount are totaly reset cash 0 car : ....
then search, all those problems have a fix!
auto saver for 5 min etc
ok ok but i have searsh i dont see dude :'(
this will save each 5 min,
add this to form1/load
BackUp.Enabled = true;
BackUp.Elapsed += new System.Timers.ElapsedEventHandler(BackUp_Elapsed);

Then add this code somewhere in the class, but not in a method.
System.Timers.Timer BackUp = new System.Timers.Timer(300000);

void BackUp_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
foreach (clsConnection C in Connections)
FileInfo.UpdateUserLeave(C.Username, C.Cash, C.Cars);
}

all this is in
http://www.lfsforum.net/showthread.php?t=39706&page=5
that topic, you dont search... you just copy and paste code
He is not asking for an autosave... he is asking how to stop the crash...
well the auto save is a start to the money loss, till we find solution
he wants to stop people from paying over a certain amount and something that will stop his insim crashing if someone pays like !pay 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 etc..
If the charge amount if bigger than 10k, kick and dont alter the file/array info.
It sounds like it's crashing because you're trying to use int.Parse() to parse a value larger than 2147483647 into an integer, which is not possible. Ideally you should just use int.TryParse() instead, which will allow you to deal with any parsing errors you encounter with an if/else statement.
Quote from mcgas001 :I acutally dread to see your code if you think like that.

Why? It makes perfect sense to use try/catch...as we've already discussed in another thread, it's the same as .TryParse(). Except that it uses 0.001% extra juice or something...In fact, everything in my code is protected by a try/catch statement, so if something does go wrong, I'll know exactly on which line it's stopped on, and what the error code is. Plus, inside in the catch part, I can send a message to the person who used a command wrong, telling them what they did wrong...What are the impracticalities of a try/catch?
Quote from dougie-lampkin :...In fact, everything in my code is protected by a try/catch statement...

Please, Stop programming....
Why? Because I want to see what's gone wrong when a program crashes? So you're saying it's better practice to not know what's wrong when your program crashes, so that you have to spend hours fixing it, and get an extra 0.001% power out of your program, rather than know exactly what's wrong and fix it instantly, and lose 0.001% power? Maybe you should stop programming
Quote from dougie-lampkin :Why? Because I want to see what's gone wrong when a program crashes?

Microsoft spend hours of programming and coding, Into something called Microsoft Visual C# Express edition. The reason for that is because it also contains something called a Visual Debugger. A debugger is there to catch errors in program code. So, You are so gratefull to microsoft, You catch errors yourself. Great idea.

Quote from dougie-lampkin :
So you're saying it's better practice to not know what's wrong when your program crashes, so that you have to spend hours fixing it,

As stated above, Thats why you have a Visual debugger. For seeing errors in code, Then fixing them.

Quote from dougie-lampkin :
and get an extra 0.001% power out of your program, rather than know exactly what's wrong and fix it instantly, and lose 0.001% power?

You acutally will lose a fair amount of speed if you plaster Try-Catch everywhere.

Quote from dougie-lampkin :
Maybe you should stop programming

Maybe I should, You seem to forget, Who helped you?

I also, Dont mean to sound like a ****, but you seem to have become very big headed just lately.
Because I can't run the debugger at run time...if my InSim program encounters a problem while it's on the server, then I'll have to go through hours of testing myself to find the problem...I've obviously done all the testing I can myself before it's in use, and there is a good chance I'll miss something, I can't simulate everything...

I haven't plastered try-catch everywhere either, I have one for each method.

I know you helped me when I was starting out, I haven't forgot that. But just because that's my style of writing code, I'm not going to stop programming altogether...I don't see how I'm getting big headed, I was just giving my solution to his problem. If you can think of a better way to catch errors, then just say it...
I'm afraid I agree with mcgas001 on this (although I really don't agree with his rather brutal method of getting his point across), that overuse of exception handling, like as you describe, is actually a very poor practice in programming.

By using exception handling code on everything you are actually masking and hiding the natural errors that will occur in your program. If you swallow errors in this way, how will you know how to fix them and how to avoid them in future? You should write your code so that errors are avoided, not swallowed. You should not use exceptions to deal with bugs and problems that occur through bad coding (which incidentally, we are all guilty of).

You should always let errors run to the surface, you should let your program crash and fail, even if it crashes for a user, as this is the only way you will learn to fix your errors and how to avoid them. You may think this is shite, but I'm expressing views held by most, if not all, programming evangelists here.

I'd advise you to spend some time reading some of the best practice guides for exception handling that exist on the internet, and learn how leading programmers advise for dealing with these sorts of issues. Also if you would like to see a better way of handling errors in release code, there are many instances of free source-code you can look at to see how it can be done. For C# I'd recommend the Paint.NET and SharpEdit sources, but there are many others available. There are also tutorials and guides for how to do this which you can find using Google.

Simply put, exception handlers should be the last solution you reach for, rather than the first.
I've done all of the testing that I can, but naturally under actual use, there may be errors that I have missed. But by using try-catch, it actually tells you what the error was, what caused it, and how to fix it. So when it does go down, my host can tell me what the catch has reported (I send them in message boxes), and I can go to the line that it's reported. And the program can continue in the mean time, until I fix it This is the approach I have taught myself...

I shall have a look at the open source releases though, thanks for the tip

Exception handling is the last solution I use, as I've done all other possible exception detection myself...
Quote from DarkTimes :(although I really don't agree with his rather brutal method of getting his point across)

Wow, That was brutal? Damn...
Quote from DarkTimes :You may think this is shite, but I'm expressing views held by most, if not all, programming evangelists here.

No arguments there :up: Good post.
Quote from mcgas001 :Wow, That was brutal? Damn...

A single-line post telling someone to quit programming because they don't handle exceptions in the same way as you, I thought was a little brutal and unnecessary, yes.

Crash insim
(23 posts, started )
FGED GREDG RDFGDR GSFDG