Example #1
0
 private void OnResourceStart()
 {
     try
     {
         connectionStr = String.Format("server={0};user={1};password={2};database={3};port={4}",
                                       API.getSetting <string>("host"),
                                       API.getSetting <string>("user"),
                                       API.getSetting <string>("password"),
                                       API.getSetting <string>("database"),
                                       API.getSetting <string>("port")
                                       );
         using (MySqlConnection conn = new MySqlConnection(connectionStr))
         {
             API.consoleOutput("[MySQL][INFO] Attempting connecting to MySQL");
             conn.Open();
             if (conn.State == ConnectionState.Open)
             {
                 API.consoleOutput("[MySQL][INFO] Connected to MySQL");
                 DBVehicles.GetCarSpawn();
             }
         }
     }
     catch (Exception ex)
     {
         API.consoleOutput("[MySQL][ERROR] " + ex.ToString());
         API.delay(5000, true, () => { Environment.Exit(1); });
     }
 }
 public void SavePlayerLoop(Client player)
 {
     try
     {
         if (IsPlayerLoggedIn(player))
         {
             if (player.vehicle != null)
             {
                 DBVehicles.SaveVehicle(player.vehicle);
             }
             UpdatePlayerInfo(player);
         }
     }
     catch (Exception ex)
     {
         API.consoleOutput("[MySQL][ERROR] " + ex.ToString());
     }
 }