The online racing simulator
[C#] What's wrong ?
(9 posts, started )
[SOLVED] [C#] What's wrong ?
Hello

I have this code and i don't know what's wrong :

private void MinuteTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
#region ' Auto Message '
if (Connections.Count > 1)
{
switch (Message)
{
case 0:
MsgAll("»^7 Drive on the ^1Right side of the Road!");
break;

case 1:
MsgAll("»^7 Swearing, Ramming, Insults and Disrespecting");
MsgAll("»^7 May Result to ban.");
break;


case 2:
MsgAll("»^7 Please visit us for more information");
MsgAll("»^7 " + Website);
break;

case 3:

MsgAll("»^7 Keep the server clean from swearing.");

break;
}
//Message += 1;
}
#endregion

private void MinuteTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
{
if (Messages == 1)
{
MsgAll("^1»^7 Drive on the ^3RIGHT ^7side of the road!");
}
else if (Messages == 2)
{
MsgAll("^7For more updates, events, and more,");
MsgAll("^7Access us at ^3" + Website);
}
else if (Messages == 3)
{
MsgAll("^7Report a player, Abuse or Ramming");
MsgAll("^7Post a report: ^3" + Website);
}
else if (Messages == 4)
{
MsgAll("^7Found a ^1BUG^7?");
MsgAll("^7Report at ^3" + Website);
}
else if (Messages == 5)
{
MsgAll("^7Currently Running [Dc] System ^3V" + FileInfo.GetVersion(InsimVer) + " ");
Messages = -5;
}
Messages += 1;

}
}
catch { }
}
Not working ):
You're making it next to impossible to help you. When you tell us stuff like "I don't know what's wrong with this" or "Not working" nobody can even guess what could be wrong. What do you expect your program to do and what actually happens?
Ok i will explain.. I downloaded the model [iC] InSim at first because I did not know where to start and how to start.
Now I do own InSim but I want to add that insim Auto Messages and not funnctioneaza and I thought to ask for help forum.

Sorry for my bad english ):
This should work, unless something is happening to the variable 'Message' somewhere else.

private void MinuteTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
#region ' Auto Message '
if (Connections.Count > 1)
{
switch (Message)
{
case 1:
MsgAll("»^7 Drive on the ^1Right side of the Road!");
break;

case 2:
MsgAll("»^7 Swearing, Ramming, Insults and Disrespecting");
MsgAll("»^7 May Result to ban.");
break;


case 3:
MsgAll("»^7 Please visit us for more information");
MsgAll("»^7 " + Website);
break;

case 4:
MsgAll("»^7 Keep the server clean from swearing.");
break;

default: // always have a 'default' in a case which sets everything to known values. This will also be 'case 0'.
MsgAll("»^7 Welcome to the server.");
Message = 0; // 'Message' must be reset somewhere to start the loop again
break;
}
Message += 1; // 'Message' must be changed each time for a different message
}
#endregion

Quote from Kiyoshi :This should work, unless something is happening to the variable 'Message' somewhere else.


Message = 0; // 'Message' must be reset somewhere to start the loop again



This working but when messages reset, not start with first
example: Msg2 then Msg3 then Msg4 and then reset to 2nm Msg

Sorry for my bad english Frown
Did you copy the whole code? I renumbered the 'case' statements.
That code should go:

default
case 1
case 2
case 3
case 4
default
case 1
case 2
etc...

If you put a breakpoint and step through the code, you can see how the 'Message' is changing, and how that chooses each case. You can then change it yourself to do any thing you want. Wink
It would be good for you to understand how this code works - read about switch-case statements. It's a simple bit of code, but very useful.
Ahaaahaa (:
Thx .. It working Big grin

[C#] What's wrong ?
(9 posts, started )
FGED GREDG RDFGDR GSFDG