• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

/commands Request

Yuji

Helper
Joined
Mar 18, 2010
Messages
438
Reaction score
33
Location
U.S.A New York
Hey guys could some one help me with this? I need help with a /commands command that shows the commands, lol! You can see them on any server but idk i cant make it!!!! Thanks!

Edit: Almost forgot lol! My server is a 9.60 TFS .2
 
Since TFS 0.2 distros lack of function getTalkActionList(), here's a hybrid solution
XML:
<talkaction words="/commands" script="script.lua"/>

Lua:
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
 
Back
Top