Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- A table that will hold entities that were there when the map started.
- GM.Entities = {}
- local function onConnected(db)
- GM:Log(EVENT_SQLDEBUG,"Connected to the MySQL server!");
- for _, ply in pairs(player.GetAll()) do
- ply:SaveData();
- end
- end
- local function onConnectionFailed(db, err)
- GM:Log(EVENT_ERROR,"Error connecting to the MySQL server: %s", err);
- timer.Simple(60, GM.Database.connect, GM.Database);
- end
- -- Called when the server initializes.
- function GM:Initialize()
- GM = self; -- ¬_¬ garru
- ErrorNoHalt"----------------------\n"
- ErrorNoHalt(os.date().." - Server starting up\n")
- ErrorNoHalt"----------------------\n"
- local hostname = self.Config["MySQL Host"]
- local username = self.Config["MySQL Username"]
- local password = self.Config["MySQL Password"]
- local database = self.Config["MySQL Database"]
- -- Initialize a connection to the MySQL database.
- self.Database = mysqloo.connect(hostname, username, password, database);
- self.Database.onConnected = onConnected;
- self.Database.onConnectionFailed = onConnectionFailed;
- self.Database:connect();
- -- Call the base class function.
- return self.BaseClass:Initialize()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement