mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b6870dd87 | ||
|
|
aa73db1111 | ||
|
|
68563c6d18 | ||
|
|
a9d42b9861 | ||
|
|
eac4de4623 | ||
|
|
08815f2ecd | ||
|
|
88e8a4218a | ||
|
|
99b8d85901 | ||
|
|
378e552fe7 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
config_server.lua
|
||||||
16
README.md
16
README.md
@@ -4,19 +4,25 @@
|
|||||||
|
|
||||||
<p align='center'><b><a href="discord.gg/nc82d8zvjm">Discord</a></b>
|
<p align='center'><b><a href="discord.gg/nc82d8zvjm">Discord</a></b>
|
||||||
|
|
||||||
<p align='center'><b><a href="https://ndframework.gitbook.io/nd-framework/">Documentation</a></b>
|
<p align='center'><b><a href="https://ndfw.gitbook.io/nd-framework/">Documentation</a></b>
|
||||||
|
|
||||||
## Dependency:
|
## Dependency:
|
||||||
[oxmysql](https://github.com/overextended/oxmysql/releases/download/v2.4.0/oxmysql.zip)
|
[oxmysql](https://github.com/overextended/oxmysql/releases/download/v2.4.0/oxmysql.zip)
|
||||||
|
|
||||||
## Addons
|
## Addons
|
||||||
|
|
||||||
|
* [Ox Inventory](https://github.com/overextended/ox_inventory/releases)
|
||||||
* [Character Selection](https://github.com/ND-Framework/ND_CharacterSelection)
|
* [Character Selection](https://github.com/ND-Framework/ND_CharacterSelection)
|
||||||
|
* [No Characters (use framework without character selection)](https://github.com/ND-Framework/ND_NoCharacters)
|
||||||
|
* [Vehicle System](https://github.com/ND-Framework/ND_VehicleSystem)
|
||||||
|
* [Dealerships](https://github.com/ND-Framework/ND_Dealership)
|
||||||
* [Fuel (with nozzle and hose)](https://github.com/ND-Framework/ND_Fuel)
|
* [Fuel (with nozzle and hose)](https://github.com/ND-Framework/ND_Fuel)
|
||||||
|
* [Nitro](https://github.com/ND-Framework/ND_Nitro)
|
||||||
* [Shot Spotter](https://github.com/ND-Framework/ND_ShotSpotter)
|
* [Shot Spotter](https://github.com/ND-Framework/ND_ShotSpotter)
|
||||||
* [Banking](https://github.com/ND-Framework/ND_Banking)
|
* [Banking](https://github.com/ND-Framework/ND_Banking)
|
||||||
* [Door locks](https://github.com/ND-Framework/ND_Doorlocks)
|
* [Doorlocks](https://github.com/ND-Framework/ND_Doorlocks)
|
||||||
* [Ox Inventory](https://github.com/overextended/ox_inventory/releases)
|
* [Properties](https://github.com/ND-Framework/ND_Properties)
|
||||||
* [No Characters (use framework without character selection)](https://github.com/ND-Framework/ND_NoCharacters)
|
* [Appearance Shops](https://github.com/ND-Framework/ND_AppearanceShops)
|
||||||
|
|
||||||
# Need support?
|
# Need support?
|
||||||
[](https://discord.gg/Z9Mxu72zZ6)
|
[](https://discord.gg/Z9Mxu72zZ6)
|
||||||
|
|||||||
@@ -9,3 +9,51 @@ end
|
|||||||
function NDCore.Functions.GetCharacters()
|
function NDCore.Functions.GetCharacters()
|
||||||
return NDCore.Characters
|
return NDCore.Characters
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Callbacks are licensed under LGPL v3.0
|
||||||
|
-- <https://github.com/overextended/ox_lib>
|
||||||
|
NDCore.callback = {}
|
||||||
|
local events = {}
|
||||||
|
|
||||||
|
RegisterNetEvent("ND:callbacks", function(key, ...)
|
||||||
|
local cb = events[key]
|
||||||
|
return cb and cb(...)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local function triggerCallback(_, name, cb, ...)
|
||||||
|
local key = ("%s:%s"):format(name, math.random(0, 100000))
|
||||||
|
TriggerServerEvent(("ND:%s_cb"):format(name), key, ...)
|
||||||
|
|
||||||
|
local promise = not cb and promise.new()
|
||||||
|
|
||||||
|
events[key] = function(response, ...)
|
||||||
|
response = { response, ... }
|
||||||
|
events[key] = nil
|
||||||
|
|
||||||
|
if promise then
|
||||||
|
return promise:resolve(response)
|
||||||
|
end
|
||||||
|
|
||||||
|
if cb then
|
||||||
|
cb(table.unpack(response))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if promise then
|
||||||
|
return table.unpack(Citizen.Await(promise))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
setmetatable(NDCore.callback, {
|
||||||
|
__call = triggerCallback
|
||||||
|
})
|
||||||
|
|
||||||
|
function NDCore.callback.await(name, ...)
|
||||||
|
return triggerCallback(nil, name, false, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
function NDCore.callback.register(name, callback)
|
||||||
|
RegisterNetEvent(("ND:%s_cb"):format(name), function(key, ...)
|
||||||
|
TriggerServerEvent("ND:callbacks", key, callback(...))
|
||||||
|
end)
|
||||||
|
end
|
||||||
@@ -15,16 +15,17 @@ shared_scripts {
|
|||||||
client_scripts {
|
client_scripts {
|
||||||
"client/main.lua",
|
"client/main.lua",
|
||||||
"client/functions.lua",
|
"client/functions.lua",
|
||||||
"client/events.lua"
|
"client/events.lua",
|
||||||
|
"shared/import.lua"
|
||||||
}
|
}
|
||||||
|
|
||||||
server_scripts {
|
server_scripts {
|
||||||
"@oxmysql/lib/MySQL.lua",
|
"@oxmysql/lib/MySQL.lua",
|
||||||
"config_server.lua",
|
"config_server.lua",
|
||||||
"server/main.lua",
|
"server/main.lua",
|
||||||
"server/functions.lua",
|
"server/functions.lua",
|
||||||
"server/events.lua",
|
"server/events.lua",
|
||||||
"server/commands.lua"
|
"server/commands.lua",
|
||||||
|
"shared/import.lua"
|
||||||
}
|
}
|
||||||
|
|
||||||
exports {
|
exports {
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ end)
|
|||||||
-- Update the characters clothes.
|
-- Update the characters clothes.
|
||||||
RegisterNetEvent("ND:updateClothes", function(clothing)
|
RegisterNetEvent("ND:updateClothes", function(clothing)
|
||||||
local player = source
|
local player = source
|
||||||
NDCore.Functions.SetPlayerData(player, "clothing", clothing)
|
local character = NDCore.Players[player]
|
||||||
|
NDCore.Functions.SetPlayerData(character.id, "clothing", clothing)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Disconnecting a player
|
-- Disconnecting a player
|
||||||
|
|||||||
@@ -690,6 +690,7 @@ function NDCore.Functions.VersionChecker(expectedResourceName, resourceName, dow
|
|||||||
end
|
end
|
||||||
PerformHttpRequest(rawGithubLink, function(errorCode, resultData, resultHeaders)
|
PerformHttpRequest(rawGithubLink, function(errorCode, resultData, resultHeaders)
|
||||||
local i, j = tostring(resultData):find("version")
|
local i, j = tostring(resultData):find("version")
|
||||||
|
if not i or not j then return end
|
||||||
local resultData = tostring(resultData):sub(i, j + 12)
|
local resultData = tostring(resultData):sub(i, j + 12)
|
||||||
local resultData = resultData:gsub("version \"", "")
|
local resultData = resultData:gsub("version \"", "")
|
||||||
local i, j = resultData:find("\"")
|
local i, j = resultData:find("\"")
|
||||||
@@ -717,3 +718,53 @@ function NDCore.Functions.VersionChecker(expectedResourceName, resourceName, dow
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
NDCore.Functions.VersionChecker("ND_Core", GetCurrentResourceName(), "https://github.com/ND-Framework/ND_Core", "https://raw.githubusercontent.com/ND-Framework/ND_Core/main/fxmanifest.lua")
|
NDCore.Functions.VersionChecker("ND_Core", GetCurrentResourceName(), "https://github.com/ND-Framework/ND_Core", "https://raw.githubusercontent.com/ND-Framework/ND_Core/main/fxmanifest.lua")
|
||||||
|
|
||||||
|
|
||||||
|
-- Callbacks are licensed under LGPL v3.0
|
||||||
|
-- <https://github.com/overextended/ox_lib>
|
||||||
|
NDCore.callback = {}
|
||||||
|
local events = {}
|
||||||
|
|
||||||
|
RegisterNetEvent("ND:callbacks", function(key, ...)
|
||||||
|
local cb = events[key]
|
||||||
|
return cb and cb(...)
|
||||||
|
end)
|
||||||
|
|
||||||
|
function triggerCallback(_, name, playerId, cb, ...)
|
||||||
|
local key = ("%s:%s:%s"):format(name, math.random(0, 100000), playerId)
|
||||||
|
TriggerClientEvent(("ND:%s_cb"):format(name), playerId, key, ...)
|
||||||
|
|
||||||
|
local promise = not cb and promise.new()
|
||||||
|
|
||||||
|
events[key] = function(response, ...)
|
||||||
|
response = { response, ... }
|
||||||
|
events[key] = nil
|
||||||
|
|
||||||
|
if promise then
|
||||||
|
return promise:resolve(response)
|
||||||
|
end
|
||||||
|
|
||||||
|
if cb then
|
||||||
|
cb(table.unpack(response))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if promise then
|
||||||
|
return table.unpack(Citizen.Await(promise))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
setmetatable(NDCore.callback, {
|
||||||
|
__call = triggerCallback
|
||||||
|
})
|
||||||
|
|
||||||
|
function NDCore.callback.await(name, playerId, ...)
|
||||||
|
return triggerCallback(nil, name, playerId, false, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
function NDCore.callback.register(name, callback)
|
||||||
|
RegisterNetEvent(("ND:%s_cb"):format(name), function(key, ...)
|
||||||
|
local src = source
|
||||||
|
TriggerClientEvent("ND:callbacks", src, key, callback(src, ...))
|
||||||
|
end)
|
||||||
|
end
|
||||||
1
shared/import.lua
Normal file
1
shared/import.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||||
Reference in New Issue
Block a user