Skip to content

Commit 1d07444

Browse files
Bugfix and Code Cleanup
- Fixed a bug that caused MSync to be unable to add itself to the servers table - Removed unecessary whitespaces
1 parent 23be597 commit 1d07444

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

lua/msync/server/sv_mysql.lua

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ MSync.func = MSync.func or {}
77
--[[
88
Description: initializes the MySQL part
99
Returns: nothing
10-
]]
11-
function MSync.mysql.initialize()
10+
]]
11+
function MSync.mysql.initialize()
1212
if (file.Exists( "bin/gmsv_mysqloo_linux.dll", "LUA" ) or file.Exists( "bin/gmsv_mysqloo_win32.dll", "LUA" )) and MSync.settings.data.mysql then
1313
require("mysqloo")
14-
14+
1515
MSync.DBServer = mysqloo.connect(
1616
MSync.settings.data.mysql.host,
1717
MSync.settings.data.mysql.username,
@@ -34,7 +34,7 @@ function MSync.mysql.initialize()
3434
UNIQUE INDEX `group_UNIQUE` (`group_name`)
3535
);
3636
]] ))
37-
37+
3838
initDatabase:addQuery(MSync.DBServer:query( [[
3939
CREATE TABLE IF NOT EXISTS `tbl_msync_servers` (
4040
`p_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
@@ -59,7 +59,7 @@ function MSync.mysql.initialize()
5959
UNIQUE INDEX `steamid64_UNIQUE` (`steamid64`)
6060
);
6161
]] ))
62-
62+
6363
function initDatabase.onSuccess()
6464
MSync.mysql.saveServer()
6565
MSync.initModules()
@@ -89,10 +89,10 @@ end
8989
Description: Adds a user to the users table
9090
Arguments: player
9191
Returns: nothing
92-
]]
92+
]]
9393
function MSync.mysql.addUser(ply)
9494
if not MSync.DBServer then print("[MSync] No Database connected yet. Please connect to a Database to be able to create users."); return end;
95-
95+
9696
local addUserQ = MSync.DBServer:prepare( [[
9797
INSERT INTO `tbl_users` (steamid, steamid64, nickname, joined)
9898
VALUES (?, ?, ?, ?)
@@ -123,8 +123,8 @@ end
123123
--[[
124124
Description: Function to print the MySQL informations to the console
125125
Returns: nothing
126-
]]
127-
function MSync.mysql.getInfo()
126+
]]
127+
function MSync.mysql.getInfo()
128128
print("--Database Server Information--")
129129
print("Version: "..MSync.DBServer:serverVersion())
130130
print("Fancy Version: "..MSync.DBServer:serverInfo())
@@ -134,7 +134,7 @@ end
134134
--[[
135135
Description: Function to save the server date to the database
136136
Returns: nothing
137-
]]
137+
]]
138138
function MSync.mysql.saveServer()
139139

140140
local addServerGroup = MSync.DBServer:prepare( [[
@@ -151,15 +151,16 @@ function MSync.mysql.saveServer()
151151
)
152152
ON DUPLICATE KEY UPDATE server_name=VALUES(server_name), server_group=VALUES(server_group);
153153
]] )
154-
154+
155155
local hostname = GetHostName()
156-
156+
local ip, port = string.Split(game.GetIPAddress(), ":")
157+
157158
if string.len(hostname) > 75 then
158159
hostname = string.sub( hostname, 1, 75 )
159160
end
160161
addServer:setString(1, hostname)
161-
addServer:setString(2, GetConVar( "hostip" ):GetString())
162-
addServer:setString(3, GetConVar( "hostport" ):GetString())
162+
addServer:setString(2, ip)
163+
addServer:setString(3, port)
163164
addServer:setString(4, MSync.settings.data.serverGroup)
164165

165166
function addServer.onSuccess()

0 commit comments

Comments
 (0)