Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix database connection #427

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions gamemode/core/hooks/sv_hooks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -768,14 +768,15 @@ end
function GM:ShutDown()
ix.shuttingDown = true
ix.config.Save()
if ix.database_connected then
hook.Run("SaveData")

hook.Run("SaveData")

for _, v in ipairs(player.GetAll()) do
v:SaveData()
for _, v in ipairs(player.GetAll()) do
v:SaveData()

if (v:GetCharacter()) then
v:GetCharacter():Save()
if (v:GetCharacter()) then
v:GetCharacter():Save()
end
end
end
end
Expand Down Expand Up @@ -945,7 +946,8 @@ function GM:DatabaseConnected()
ix.log.LoadTables()

MsgC(Color(0, 255, 0), "Database Type: " .. ix.db.config.adapter .. ".\n")

ix.database_connected = true
ix.database_start_connected = true
timer.Create("ixDatabaseThink", 0.5, 0, function()
mysql:Think()
end)
Expand Down
15 changes: 15 additions & 0 deletions gamemode/core/libs/sv_database.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,24 @@ end

hook.Add("InitPostEntity", "ixDatabaseConnect", function()
-- Connect to the database using SQLite, mysqoo, or tmysql4.
ix.database_start_connected = false
ix.db.Connect()
timer.Create("START_FIX_DB_CONNECTED", 10, 0, function()
if ix.database_start_connected == false then
ix.db.Connect()
else
timer.Remove("START_FIX_DB_CONNECTED")
end
end)
end)

hook.Add("CheckPassword", "NoDatabaseConnectedStartServer", function()
if !ix.database_start_connected then
return false, "Database not connected"
end
end)


local resetCalled = 0

concommand.Add("ix_wipedb", function(client, cmd, arguments)
Expand Down
1 change: 1 addition & 0 deletions helix
Submodule helix added at f6fbfc
Loading