private void Savetimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { try { foreach (var c in _connections.Values) { c.totalplaytime += 1; } foreach (var conn in _connections.Values) { if (ConnectedToSQL) { try { SqlInfo.UpdateUser(_connections[conn.UCID].UName, StringHelper.StripColors(SqlInfo.RemoveStupidCharacters(_connections[conn.UCID].PName)), false, _connections[conn.UCID].TotalDistance, _connections[conn.UCID].Timezone, _connections[conn.UCID].KMHorMPH, _connections[conn.UCID].Rank, _connections[conn.UCID].Driftpoints, _connections[conn.UCID].timesCrashed, _connections[conn.UCID].timesChatted, _connections[conn.UCID].timesReset, _connections[conn.UCID].timesJoined, _connections[conn.UCID].timesSpectated, _connections[conn.UCID].kmXRG, _connections[conn.UCID].kmLX4, _connections[conn.UCID].kmLX6, _connections[conn.UCID].kmRB4, _connections[conn.UCID].kmFXO, _connections[conn.UCID].kmXRT, _connections[conn.UCID].kmRAC, _connections[conn.UCID].kmFZ5, _connections[conn.UCID].totalplaytime); } catch (Exception EX) { if (!SqlInfo.IsConnectionStillAlive()) { ConnectedToSQL = false; SQLReconnectTimer.Start(); } LogTextToFile("sqlerror", "[" + conn.UCID + "] " + StringHelper.StripColors(_connections[conn.UCID].PName) + "(" + _connections[conn.UCID].UName + ") conn - Exception: " + EX.Message, false); } } } } catch (Exception f) { MessageBox.Show("" + f.Message, "AN ERROR OCCURED"); } }
private void Savetimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { try { foreach (var conn in _connections.Values) { if (ConnectedToSQL) { try { SqlInfo.UpdateUser(_connections[conn.UCID].UName, StringHelper.StripColors(SqlInfo.RemoveStupidCharacters(_connections[conn.UCID].PName)), false, _connections[conn.UCID].cash, _connections[conn.UCID].bankbalance, _connections[conn.UCID].TotalDistance, _connections[conn.UCID].cars, _connections[conn.UCID].totaljobsdone, _connections[conn.UCID].totalearnedfromjobs, _connections[conn.UCID].Timezone, _connections[conn.UCID].KMHorMPH, _connections[conn.UCID].TotalConnectionTime); } catch (Exception EX) { if (!SqlInfo.IsConnectionStillAlive()) { SQL_label.Text = "MySQL : NOT CONNECTED!"; ConnectedToSQL = false; SQLReconnectTimer.Start(); } LogTextToFile("sqlerror", "[" + conn.UCID + "] " + StringHelper.StripColors(_connections[conn.UCID].PName) + "(" + _connections[conn.UCID].UName + ") conn - Exception: " + EX.Message, false); } } } } catch (Exception f) { MessageBox.Show("" + f.Message, "AN ERROR OCCURED"); } }
private void MessageReceived(InSim insim, IS_MSO mso) { try { { if (mso.UserType == UserType.MSO_PREFIX) { string Text = mso.Msg.Substring(mso.TextStart, (mso.Msg.Length - mso.TextStart)); string[] command = Text.Split(' '); command[0] = command[0].ToLower(); var conn = _connections[mso.UCID]; switch (command[0]) { case "!find": insim.Send(mso.UCID, "^8Been online for ^3" + conn.totalplaytime + " seconds"); break; case "!info": CommandInfo(mso.UCID); break; case "!stats": if (conn.DisplaysOpen == false && conn.inStats == false) { CommandStats(mso.UCID); } break; case "!ac": { //Admin chat if (mso.UCID == _connections[mso.UCID].UCID) { if (!IsConnAdmin(_connections[mso.UCID])) { insim.Send(mso.UCID, 0, "You are not an admin"); break; } if (command.Length == 1) { insim.Send(mso.UCID, 0, "^1Invalid command format. ^2Usage: ^7!ac <text>"); break; } string atext = Text.Remove(0, command[0].Length + 1); foreach (var Conn in _connections.Values) { { if (IsConnAdmin(Conn) && Conn.UName != "") { insim.Send(Conn.UCID, 0, "^3Admin Chat ^7" + _connections[mso.UCID].PName + " ^8(" + _connections[mso.UCID].UName + "):"); insim.Send(Conn.UCID, 0, "^7" + atext); } } } } break; } case "!pos": if (_connections[mso.UCID].IsAdmin == false) { insim.Send(mso.UCID, "^1Error: ^7You are not an Admin!"); break; } if (AskedPosition == true) { insim.Send(mso.UCID, "^1Error: ^7Someone else already wants their position, please try again."); break; } //position @ MCI Packet AskedPosUCID = mso.UCID; AskedPosition = true; break; case "!teamspeak": case "!ts": insim.Send(mso.UCID, "^8Teamspeak 3 Server: ^3" + "ts.eugaming.org"); break; case "!website": case "!web": insim.Send(mso.UCID, "^8Our website: ^3" + "www.eugaming.org"); insim.Send(mso.UCID, "^8Global statistics can be found on the website too."); break; case "!p": case "!pen": case "!penalty": insim.Send("/p_clear " + _connections[mso.UCID].UName); break; case "!ban": insim.Send(mso.UCID, "^8This command is inactive"); SqlInfo.AddtoBanlist(k.UName, StringHelper.StripColors(k.PName), "14.01.2016", "no longer welcome"); break; case "!help": insim.Send(mso.UCID, 0, "^3Commands:"); insim.Send(mso.UCID, 0, "^7!help ^8- See a list of available commands"); insim.Send(mso.UCID, 0, "^7!info ^8- See a few lines of server info"); insim.Send(mso.UCID, 0, "^7!stats ^8- Check your personal stats"); insim.Send(mso.UCID, 0, "^7!pen (!p) ^8- Remove the pit penalty"); insim.Send(mso.UCID, 0, "^7!gmt <timezone> ^8- Set your own timezone, ex: !gmt +12"); insim.Send(mso.UCID, 0, "^7!teamspeak (!ts) ^8- To view our teamspeak address"); insim.Send(mso.UCID, 0, "^7!website (!web) ^8- To view our website address"); // Admin commands foreach (var CurrentConnection in _connections.Values) { if (CurrentConnection.UCID == mso.UCID) { if (IsConnAdmin(CurrentConnection) && CurrentConnection.UName != "") { insim.Send(CurrentConnection.UCID, 0, "^3Administrator commands:"); insim.Send(CurrentConnection.UCID, 0, "^7!ac ^8- Talk with the other admins that are online"); insim.Send(CurrentConnection.UCID, 0, "^7!pos ^8- Check your current position in x, y, z"); insim.Send(CurrentConnection.UCID, 0, "^7!ban <username> <days> ^8- Ban the selected player for x days (0 = 12 hours)"); } } } break; case "!gmt": var connn = _connections[mso.UCID]; if (command.Length == 1) { insim.Send(mso.UCID, "^1Invalid command. ^7Usage: ^3!gmt <timezone>"); } else if (command.Length == 2) { #region ' Command ' if (command[1] == "-12" || command[1] == "-12:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = -12; } else if (command[1] == "-11" || command[1] == "-11:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = -11; } else if (command[1] == "-10" || command[1] == "-10:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = -10; } else if (command[1] == "-9" || command[1] == "-9:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = -9; } else if (command[1] == "-8" || command[1] == "-8:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = -8; } else if (command[1] == "-7" || command[1] == "-7:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = -7; } else if (command[1] == "-6" || command[1] == "-6:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = -6; } else if (command[1] == "-5" || command[1] == "-5:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = -5; } else if (command[1] == "-4" || command[1] == "-4:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = -4; } else if (command[1] == "-3" || command[1] == "-3:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = -3; } else if (command[1] == "-2" || command[1] == "-2:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = -2; } else if (command[1] == "-1" || command[1] == "-1:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = -1; } else if (command[1] == "0" || command[1] == "0:00" || command[1] == "+0" || command[1] == "+0:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "default (GMT 0:00)"); connn.Timezone = 0; } else if (command[1] == "1" || command[1] == "1:00" || command[1] == "+1" || command[1] == "+1:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = 1; } else if (command[1] == "2" || command[1] == "2:00" || command[1] == "+2" || command[1] == "+2:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = 2; } else if (command[1] == "3" || command[1] == "3:00" || command[1] == "+3" || command[1] == "+3:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = 3; } else if (command[1] == "4" || command[1] == "4:00" || command[1] == "+4" || command[1] == "+4:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = 4; } else if (command[1] == "5" || command[1] == "5:00" || command[1] == "+5" || command[1] == "+5:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = 5; } else if (command[1] == "6" || command[1] == "6:00" || command[1] == "+6" || command[1] == "+6:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = 6; } else if (command[1] == "7" || command[1] == "7:00" || command[1] == "+7" || command[1] == "+7:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = 7; } else if (command[1] == "8" || command[1] == "8:00" || command[1] == "+8" || command[1] == "+8:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = 8; } else if (command[1] == "9" || command[1] == "9:00" || command[1] == "+9" || command[1] == "+9:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = 9; } else if (command[1] == "10" || command[1] == "10:00" || command[1] == "+10" || command[1] == "+10:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = 10; } else if (command[1] == "11" || command[1] == "11:00" || command[1] == "+11" || command[1] == "+11:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = 11; } else if (command[1] == "12" || command[1] == "12:00" || command[1] == "+12" || command[1] == "+12:00") { insim.Send(mso.UCID, "^8Your timezone has been set to ^3" + "GMT " + command[1]); connn.Timezone = 12; } #endregion } break; default: insim.Send(mso.UCID, 0, "^8Invalid command, type {0} to see available commands", "^2!help^8"); break; } } else { chat.Text += SqlInfo.RemoveStupidCharacters(StringHelper.StripColors(mso.Msg + " \r\n")); } } } catch (Exception e) { LogTextToFile("commands", "[" + mso.UCID + "] " + StringHelper.StripColors(_connections[mso.UCID].PName) + "(" + GetConnection(mso.PLID).UName + ") NPL - Exception: " + e, false); } }