local o, file
do
o = io.open("./data/XML/commands.xml","r")
if o then
file = o:read('*a')
o:close()
end
end
local commands = {}
for text in file:gmatch('<commands>(.-)/commands>') do
for cmd, group, acctype in text:gmatch('<command.-cmd="(.-)".-group="(.-)".-acctype="(.-)".-/>') do
table.insert(commands, {cmd, tonumber(group), tonumber(acctype)})
end
end
table.sort(commands, function(a, b) return a[1] < b[1] end)
function getAccountType(cid)
local resultId = db.storeQuery("SELECT `type` FROM `accounts` WHERE `name` = " .. getAccountNumberByPlayerName(getCreatureName(cid)) .. ";")
local value = result.getDataInt(resultId, "type")
result.free(resultId)
return value
end
function onSay(cid, words, param)
local txt = ''
for i, command in ipairs(commands) do
if (getPlayerGroupId(cid) >= command[2]) and (getAccountType(cid) >= command[3]) then
txt = txt .. command[1] .. '\n'
end
end
doShowTextDialog(cid, 2160, txt)
end