2023-07-10 03:17:32 +02:00
|
|
|
---@param src number
|
|
|
|
|
---@return table
|
2023-07-09 21:19:35 +02:00
|
|
|
function NDCore.getPlayer(src)
|
|
|
|
|
return ActivePlayers[src]
|
|
|
|
|
end
|
|
|
|
|
|
2023-07-10 03:17:32 +02:00
|
|
|
---@param metadata string
|
|
|
|
|
---@param data any
|
|
|
|
|
---@return table
|
2023-07-13 01:22:58 +02:00
|
|
|
function NDCore.getPlayers(key, value)
|
|
|
|
|
if not key or not value then return ActivePlayers end
|
|
|
|
|
|
2023-07-09 21:19:35 +02:00
|
|
|
local players = {}
|
2023-07-13 01:22:58 +02:00
|
|
|
local keyTypes = {firstname = "firstname", lastname = "lastname", gender = "gender", groups = "groups"}
|
|
|
|
|
local findBy = keyTypes[key] or "metadata"
|
|
|
|
|
|
2023-07-09 21:19:35 +02:00
|
|
|
for src, info in pairs(ActivePlayers) do
|
2023-07-13 01:22:58 +02:00
|
|
|
if info[findBy][key] == value then
|
2023-07-09 21:19:35 +02:00
|
|
|
players[src] = info
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return players
|
|
|
|
|
end
|
|
|
|
|
|
2023-07-22 23:59:11 +02:00
|
|
|
---@param source number
|
|
|
|
|
---@return table
|
|
|
|
|
function NDCore.getPlayerServerInfo(source)
|
|
|
|
|
return PlayersInfo[source]
|
|
|
|
|
end
|
|
|
|
|
|
2023-07-16 12:31:02 +02:00
|
|
|
---@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
|
|
|
|
|
|
2023-07-09 21:19:35 +02:00
|
|
|
for name, func in pairs(NDCore) do
|
|
|
|
|
if type(func) == "function" then
|
|
|
|
|
exports(name, func)
|
|
|
|
|
end
|
|
|
|
|
end
|