Files
ND_Core/server/functions.lua

52 lines
1.3 KiB
Lua
Raw Normal View History

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
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 = {}
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
if info[findBy][key] == value then
2023-07-09 21:19:35 +02:00
players[src] = info
end
end
return players
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