1function onUpdateDatabase()
2 print("> Updating database to version 12 (storing players record and message of the day in database)")
3
4 local motdNum = ""
5 local motd = ""
6
7 local lastMotdFile = io.open("lastMotd.txt", "r")
8 if lastMotdFile then
9 motdNum = lastMotdFile:read()
10 motd = lastMotdFile:read()
11 lastMotdFile:close()
12 end
13
14 local record = 0
15
16 local playersRecordFile = io.open("playersRecord.txt", "r")
17 if playersRecordFile then
18 record = playersRecordFile:read("*n")
19 playersRecordFile:close()
20 end
21
22 db.query("INSERT INTO `server_config` (`config`, `value`) VALUES ('players_record', '" .. record .. "'), ('motd_hash', SHA1(" .. db.escapeString(motd) .. ")), ('motd_num', " .. db.escapeString(motdNum) .. ")")
23 return true
24end
25