• 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!

Presenting a group name instead of group id

Xagul

deathzot.net
Joined
Jun 30, 2008
Messages
1,295
Solutions
3
Reaction score
1,043
I have modified the script Cykotitan made for the in-game guild list, and I made it basically an in-game staff list. I am trying to learn sql queries so I do not have to ask for so much help and so far it seems I have got it figured out pretty good except the script I have here shows staff_name [group_id]. I tried to compare the returned group_id to a value and then define it as a word for the list to present like this:

Code:
if(list:getDataString("group_id") == 6) then
    staffpos = "Administrator"
end

When I do that it throws me an error saying
Code:
attempt to concatenate global 'staffpos' <a nil value>

The script I am using currently due to the error is here:


Code:
function onSay(cid, words, param, channel)
	if param == '' then
		local list = db.getResult("SELECT `name`, `group_id` FROM `players` WHERE group_id > 1 ORDER BY `group_id`;")
		if(list:getID() ~= -1) then
			local v = ''
			repeat
				v = v .. list:getDataString("name")  .. " [" .. list:getDataString("group_id")  .. "]\n"
			until not list:next()
			list:free()
			doShowTextDialog(cid, 2529, v)
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are no staff members.")
		end
	end
	return true
end
 
Code:
local groups = {
	[2] = 'Tutor',
	[3] = 'Senior Tutor',
	[4] = 'Gamemaster',
	[5] = 'Community Manager',
	[6] = 'Administrator'
}
function onSay(cid, words, param, channel)
	local list = db.getResult("SELECT `name`, `group_id` FROM `players` WHERE group_id > 1 ORDER BY `group_id`;")
	if(list:getID() ~= -1) then
		local v = ''
		repeat
			v = v .. list:getDataString("name")  .. " [" .. groups[list:getDataInt("group_id")]  .. "]\n"
		until not list:next()
		list:free()
		doShowTextDialog(cid, 2529, v)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are no staff members.")
	end
	return true
end
 
Back
Top