Advertisement
Guest User

Untitled

a guest
Jul 19th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. -- A table that will hold entities that were there when the map started.
  2. GM.Entities = {}
  3.  
  4. local function onConnected(db)
  5.     GM:Log(EVENT_SQLDEBUG,"Connected to the MySQL server!");
  6.     for _, ply in pairs(player.GetAll()) do
  7.         ply:SaveData();
  8.     end
  9. end
  10. local function onConnectionFailed(db, err)
  11.     GM:Log(EVENT_ERROR,"Error connecting to the MySQL server: %s", err);
  12.     timer.Simple(60, GM.Database.connect, GM.Database);
  13. end
  14.  
  15.  
  16. -- Called when the server initializes.
  17. function GM:Initialize()
  18.     GM = self; -- ¬_¬ garru
  19.     ErrorNoHalt"----------------------\n"
  20.     ErrorNoHalt(os.date().." - Server starting up\n")
  21.     ErrorNoHalt"----------------------\n"
  22.     local hostname = self.Config["MySQL Host"]
  23.     local username = self.Config["MySQL Username"]
  24.     local password = self.Config["MySQL Password"]
  25.     local database = self.Config["MySQL Database"]
  26.  
  27.     -- Initialize a connection to the MySQL database.
  28.     self.Database = mysqloo.connect(hostname, username, password, database);
  29.     self.Database.onConnected = onConnected;
  30.     self.Database.onConnectionFailed = onConnectionFailed;
  31.     self.Database:connect();
  32.  
  33.     -- Call the base class function.
  34.     return self.BaseClass:Initialize()
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement