Index: pages/api/blackjack/index.js
===================================================================
--- pages/api/blackjack/index.js	(revision e90323425d07a533dfc916a6cd7c156c1cc2b8f6)
+++ pages/api/blackjack/index.js	(revision faff3347934f6f886535c1e4519dcea679db385d)
@@ -6,5 +6,5 @@
 import { calculateEarnings, calculateSideBetEarnings } from './calculateEarnings';
 
-import { rooms, update_rooms_to_database } from '../postgre/index'
+import { rooms, saveGameInHistory, update_rooms_to_database } from '../postgre/index'
 
 /**
@@ -37,5 +37,5 @@
 
       if (rooms[session_id] !== undefined && rooms[session_id].status.substr(1, 1) === '5') {
-        rooms[session_id] = {...game, playerCards: [...game.playerCards], dealerCards: [...game.dealerCards]};
+        rooms[session_id] = {...game, displayName: rooms[session_id].displayName, username: rooms[session_id].username, playerCards: [...game.playerCards], dealerCards: [...game.dealerCards]};
 
         rooms[session_id].betOutcomeMessageShown = true;
@@ -141,4 +141,6 @@
           }
         });
+
+        saveGameInHistory('blackjack', rooms[session_id], rooms[session_id].username);
 
         return ;
@@ -201,4 +203,6 @@
             }
           });
+          
+          saveGameInHistory('blackjack', rooms[session_id], rooms[session_id].username);
         }
         else {
Index: pages/api/poker/tableSpecific.js
===================================================================
--- pages/api/poker/tableSpecific.js	(revision e90323425d07a533dfc916a6cd7c156c1cc2b8f6)
+++ pages/api/poker/tableSpecific.js	(revision faff3347934f6f886535c1e4519dcea679db385d)
@@ -1,3 +1,3 @@
-import { tables } from '../postgre/index';
+import { saveGameInHistory, tables } from '../postgre/index';
 
 import { deck } from './gameStates'
@@ -209,4 +209,6 @@
 
             player.wonAmount = winnings;
+
+            saveGameInHistory('poker', table, player.username)
         })
 
Index: pages/api/postgre/index.js
===================================================================
--- pages/api/postgre/index.js	(revision e90323425d07a533dfc916a6cd7c156c1cc2b8f6)
+++ pages/api/postgre/index.js	(revision faff3347934f6f886535c1e4519dcea679db385d)
@@ -179,4 +179,97 @@
     /**
      * /---------------------- GET ----------------------/
+     * Get all the games played in the past.
+     * @action get_games_history
+     * @param session_id
+     */
+     if (req.query?.action === 'get_games_history' && req.query?.session_id) {
+      const session_id = req.query.session_id
+      const session = sessions.find(session => session.id === session_id)
+
+      let blackjackHistory = [];
+      let rouletteHistory = [];
+      let pokerHistory = [];
+
+      if (session) {
+        // work
+        pool.query('SELECT * FROM blackjack_history WHERE username = $1', [session.username], (error, blackjackResults) => {
+          if (error) throw error;
+
+          if (blackjackResults.rows.length > 0) {
+            blackjackHistory = blackjackResults.rows[0];
+          }
+          
+          pool.query('SELECT * FROM roulette_history WHERE username = $1', [session.username], (error, rouletteResults) => {
+            if (error) throw error;
+
+            if (rouletteResults.rows.length > 0) {
+              rouletteHistory = rouletteResults.rows[0];
+            }
+            
+            pool.query('SELECT * FROM poker_history WHERE username = $1', [session.username], (error, pokerResults) => {
+              if (error) throw error;
+
+              if (pokerResults.rows.length > 0) {
+                pokerHistory = pokerResults.rows[0];
+              }
+
+              res.json({
+                success: true,
+                blackjack: JSON.parse(blackjackHistory.history ?? "[]"),
+                roulette: JSON.parse(rouletteHistory.history ?? "[]"),
+                poker: JSON.parse(pokerHistory.history ?? "[]"),
+              })
+            });
+          });
+        });
+        
+        return ;
+      }
+      else {
+        res.json({
+          success: false,
+        })
+      }
+    }
+
+    /**
+     * /---------------------- GET ----------------------/
+     * /--------------------- ADMIN ----------------------/
+     * Get all the games currently played.
+     * @action get_live_games_as_admin
+     * @param admin_id
+     */
+     if (req.query?.action === 'get_live_games_as_admin' && req.query?.admin_id) {
+      const admin_id = req.query.admin_id
+      const adminSession = adminSessions.find(adminSession => adminSession.id === admin_id)
+
+      if (adminSession) {
+        let tmpRooms = [];
+  
+        for (let key in rooms) {
+          if (key === "loaded") continue ;
+
+          tmpRooms.push(rooms[key]);
+          tmpRooms[tmpRooms.length - 1].id = key;
+        }
+
+        res.json({
+          success: true,
+          blackjack: tmpRooms,
+          roulette: game,
+          poker: tables,
+        })
+        
+        return ;
+      }
+      else {
+        res.json({
+          success: false,
+        })
+      }
+    }
+
+    /**
+     * /---------------------- GET ----------------------/
      * /--------------------- ADMIN ----------------------/
      * Get complaints from the players and show them to the admin
@@ -207,8 +300,9 @@
         return ;
       }
-
-      res.json({
-        success: false,
-      })
+      else {
+        res.json({
+          success: false,
+        })
+      }
     }
 
@@ -1171,2 +1265,72 @@
 }
 load_rooms_from_database();
+
+export async function saveGameInHistory(gameType, game, username) {
+  if (!username || !game || !gameType) return ;
+
+  if (gameType === 'blackjack') {
+    pool.query('SELECT * FROM blackjack_history WHERE username = $1', [username], (error, results) => {
+      if (error) throw error;
+  
+      if (results.rows.length > 0) {
+        let games = JSON.parse(results?.rows[0]?.history ?? []);
+
+        if (games.indexOf(game) === -1)
+          games.push(game);
+
+        pool.query('UPDATE blackjack_history SET history = $1 WHERE username = $2', [JSON.stringify(games), username], (error, newResults) => {
+          if (error) throw error;
+        });
+      }
+      else {
+        pool.query('INSERT INTO blackjack_history (username, history) VALUES ($1, $2)', [username, JSON.stringify([game])], (error, newResults) => {
+          if (error) throw error;
+        });
+      }
+    });
+  }
+
+  if (gameType === 'roulette') {
+    pool.query('SELECT * FROM roulette_history WHERE username = $1', [username], (error, results) => {
+      if (error) throw error;
+  
+      if (results.rows.length > 0) {
+        let games = JSON.parse(results?.rows[0]?.history ?? []);
+
+        if (games.indexOf(game) === -1)
+          games.push(game);
+
+        pool.query('UPDATE roulette_history SET history = $1 WHERE username = $2', [JSON.stringify(games), username], (error, newResults) => {
+          if (error) throw error;
+        });
+      }
+      else {
+        pool.query('INSERT INTO roulette_history (username, history) VALUES ($1, $2)', [username, JSON.stringify([game])], (error, newResults) => {
+          if (error) throw error;
+        });
+      }
+    });
+  }
+
+  if (gameType === 'poker') {
+    pool.query('SELECT * FROM poker_history WHERE username = $1', [username], (error, results) => {
+      if (error) throw error;
+  
+      if (results.rows.length > 0) {
+        let games = JSON.parse(results?.rows[0]?.history ?? []);
+
+        if (games.indexOf(game) === -1)
+          games.push(game);
+
+        pool.query('UPDATE poker_history SET history = $1 WHERE username = $2', [JSON.stringify(games), username], (error, newResults) => {
+          if (error) throw error;
+        });
+      }
+      else {
+        pool.query('INSERT INTO poker_history (username, history) VALUES ($1, $2)', [username, JSON.stringify([game])], (error, newResults) => {
+          if (error) throw error;
+        });
+      }
+    });
+  }
+}
Index: pages/api/roulette/gameStates.js
===================================================================
--- pages/api/roulette/gameStates.js	(revision e90323425d07a533dfc916a6cd7c156c1cc2b8f6)
+++ pages/api/roulette/gameStates.js	(revision faff3347934f6f886535c1e4519dcea679db385d)
@@ -1,5 +1,5 @@
 import { calculateWinnings } from './calculateWinnings'
 
-import { game } from '../postgre/index'
+import { game, saveGameInHistory } from '../postgre/index'
 
 import axios from 'axios';
@@ -79,4 +79,7 @@
             }
         });
+
+        if (player.whichBets?.length > 0)
+            saveGameInHistory('roulette', game, player.username)
     }
 }
