mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
update: loading sql
This commit is contained in:
@@ -22,6 +22,28 @@ function NDCore.getPlayers(key, value)
|
|||||||
return players
|
return players
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param fileLocation string|tabale
|
||||||
|
---@return boolean
|
||||||
|
function NDCore.loadSQL(fileLocation, resource)
|
||||||
|
local resourceName = resource or GetInvokingResource() or GetCurrentResourceName()
|
||||||
|
|
||||||
|
if type(fileLocation) == "string" then
|
||||||
|
local file = LoadResourceFile(resourceName, fileLocation)
|
||||||
|
if not file then return end
|
||||||
|
MySQL.query(file)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=1, #fileLocation do
|
||||||
|
local file = LoadResourceFile(resourceName, fileLocation[i])
|
||||||
|
if file then
|
||||||
|
MySQL.query(file)
|
||||||
|
Wait(100)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
for name, func in pairs(NDCore) do
|
for name, func in pairs(NDCore) do
|
||||||
if type(func) == "function" then
|
if type(func) == "function" then
|
||||||
exports(name, func)
|
exports(name, func)
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ ActivePlayers = {}
|
|||||||
PlayersInfo = {}
|
PlayersInfo = {}
|
||||||
local resourceName = GetCurrentResourceName()
|
local resourceName = GetCurrentResourceName()
|
||||||
local tempPlayersInfo = {}
|
local tempPlayersInfo = {}
|
||||||
local databaseFiles = {
|
|
||||||
"database/characters.sql",
|
|
||||||
"database/vehicles.sql"
|
|
||||||
}
|
|
||||||
local discordErrors = {
|
local discordErrors = {
|
||||||
[400] = "Improper HTTP request",
|
[400] = "Improper HTTP request",
|
||||||
[401] = "Discord bot token might be missing or incorrect",
|
[401] = "Discord bot token might be missing or incorrect",
|
||||||
@@ -121,9 +117,9 @@ AddEventHandler("playerDropped", function()
|
|||||||
PlayersInfo[src] = nil
|
PlayersInfo[src] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
for i=1, #databaseFiles do
|
SetTimeout(500, function()
|
||||||
local file = LoadResourceFile(resourceName, databaseFiles[i])
|
NDCore.loadSQL({
|
||||||
if file then
|
"database/characters.sql",
|
||||||
MySQL.query(file)
|
"database/vehicles.sql"
|
||||||
end
|
}, resourceName)
|
||||||
end
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user