Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions plugins/sam_commands.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
PLUGIN.name = "Integrated SAM Commands"
PLUGIN.desc = "Integrates SAM Commands into NutScript"
PLUGIN.author = "Tov"

if not (sam and sam.command) then return end -- Make sure SAM is installed

for _, commandInfo in ipairs(sam.command.get_commands()) do
local customSyntax = ""
for _, argInfo in ipairs(commandInfo.args) do
customSyntax = customSyntax == "" and "[" or customSyntax .. " ["
customSyntax = customSyntax .. (argInfo.default and tostring(type(argInfo.default)) or "string") .. " "
customSyntax = customSyntax .. argInfo.name .. "]"
end

nut.command.add(commandInfo.name, {
adminOnly = commandInfo.default_rank == "admin",
superAdminOnly = commandInfo.default_rank == "superadmin",
syntax = customSyntax,
onRun = function(client, arguments)
--run the sam command
RunConsoleCommand("sam", commandInfo.name, unpack(arguments))
end
})
end