mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
New Command Loader Pog
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
author "Andyyy#7666, N1K0#0001"
|
author "Andyyy#7666, N1K0#0001"
|
||||||
description "ND Framework Core"
|
description "ND Framework Core"
|
||||||
version "3.1.3"
|
version "3.1.4"
|
||||||
|
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
@@ -17,6 +17,7 @@ server_scripts {
|
|||||||
"@oxmysql/lib/MySQL.lua",
|
"@oxmysql/lib/MySQL.lua",
|
||||||
"config_server.lua",
|
"config_server.lua",
|
||||||
"server/main.lua",
|
"server/main.lua",
|
||||||
|
"server/commands.lua",
|
||||||
"server/functions.lua",
|
"server/functions.lua",
|
||||||
"server/events.lua"
|
"server/events.lua"
|
||||||
}
|
}
|
||||||
|
|||||||
39
server/commands.lua
Normal file
39
server/commands.lua
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
NDCore.Commands = {}
|
||||||
|
NDCore.Commands.Registry = {}
|
||||||
|
|
||||||
|
function NDCore.Commands.Add(name, help, arguments, argsrequired, callback, ...)
|
||||||
|
RegisterCommand(name, function(source, args, rawCommand)
|
||||||
|
if argsrequired and #args < #arguments then
|
||||||
|
return TriggerClientEvent("chat:addMessage", source, {
|
||||||
|
color = {255, 0, 0},
|
||||||
|
multiline = true,
|
||||||
|
args = {"System", "All arguments must be filled out!"}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
callback(source, args, rawCommand)
|
||||||
|
end, false)
|
||||||
|
|
||||||
|
NDCore.Commands.Registry[name:lower()] = {
|
||||||
|
name = name:lower(),
|
||||||
|
help = help,
|
||||||
|
arguments = arguments,
|
||||||
|
argsrequired = argsrequired,
|
||||||
|
callback = callback
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function NDCore.Commands.Refresh(source)
|
||||||
|
local src = source
|
||||||
|
local Player = NDCore.Functions.GetPlayer(src)
|
||||||
|
local suggestions = {}
|
||||||
|
if Player then
|
||||||
|
for command, info in pairs(NDCore.Commands.Registry) do
|
||||||
|
suggestions[#suggestions + 1] = {
|
||||||
|
name = "/" .. command,
|
||||||
|
help = info.help,
|
||||||
|
params = info.arguments
|
||||||
|
}
|
||||||
|
end
|
||||||
|
TriggerClientEvent("chat:addSuggestions", src, suggestions)
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user