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

TalkAction !online shows players and support players separately

tosuxo

Member
Joined
Jun 14, 2007
Messages
1,253
Reaction score
21
I know it's not perfect but it works. And you didn't have to script it.

Also, it will tell you the player's rank name.

Delete all content of:
Lua:
data/talkactions/scripts/online.lua

Paste this into it, change the ranks to what your ranks are.
Lua:
local ranks = {
[1] = {"Tutor"},
[2] = {"S-Tutor"},
[3] = {"GM"},
[4] = {"CM"},
[5] = {"Admin"}
}
 
local config = {
	showGamemasters = getBooleanFromString(getConfigValue('displayGamemastersWithOnlineCommand'))
}
 
function onSay(cid, words, param, channel)
	local players = getPlayersOnline()
	local strings = {""}
	local i, position = 1, 1
	local added = false
 
	for _, pid in ipairs(players) do
		if(added) then
			if(i > (position * 7)) then
				strings[position] = strings[position] .. ","
				position = position + 1
				strings[position] = ""
			else
				strings[position] = i == 1 and "" or strings[position] .. ", "
			end
		end
 
		if getPlayerAccess(pid) < 3 then
			strings[position] = strings[position] .. getCreatureName(pid) .." ["..getPlayerLevel(pid).."]"
			i = i + 1
			added = true
		else
			added = false
		end
	end
 
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, (i - 1) .. " player(s) online:")
	for i, str in ipairs(strings) do
		if(str:sub(str:len()) ~= ",") then
			str = str .. "."
		end
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
	end
 
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "-----------")
 
	local players2 = getPlayersOnline()
	local helpon = 0
	local rank = ""
	local str2 = ""
 
	for _, pid2 in ipairs(players2) do		
		if getPlayerAccess(pid2) > 0 then
                        if((config.showGamemasters or getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES) or not getPlayerCustomFlagValue(pid2, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES)) and (not isPlayerGhost(pid2) or getPlayerGhostAccess(cid) >= getPlayerGhostAccess(pid2))) then
			        rank = ranks[getPlayerAccess(pid2)]
			        str2 = str2 .. getCreatureName(pid2) .." ["..rank[1].."]  "
			        helpon = helpon + 1
                        end
		end		
	end
	if helpon > 0 then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, (helpon) .. " support player(s) online:")
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str2)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are no support players currently online.")
	end
	return true
end

Edit: updated so it hides ghosted staff or that config blah blah

Current bugs:
None?
 
Last edited:
silly me thought it was obvious how it looked...

here you go:
C50Cc.png

https://i.imgur.com/C50Cc.png
 
no erexo, staff shoulfnt have lvl, it gives the ability to players to get highscore instead of u!
and its nothing special, just shows staff :p
and if it was me, id say if it doesnt show the staff, it would be better
so nothing new XD
 
Good but, if player are S Tut or tutor lvl shall be showed :S

Kinda simple way to change that...
Change:
Lua:
if getPlayerAccess(pid) == 0 then
To:
Lua:
if getPlayerAccess(pid) < 3 then

Learn basic scripting, it'll help you greatly... Also it will still show them in the staff, so they'll be in both lists.
 
works perfect now, but is it possible to not show invisible gms/admins in the list?
 
works perfect now, but is it possible to not show invisible gms/admins in the list?

of course it is, I was just too lazy to add it. I'll edit this later to add it for you

Edit: This (should) work. If it doesn't, tell me the error in the log:
Lua:
local ranks = {
[1] = {"Tutor"},
[2] = {"S-Tutor"},
[3] = {"GM"},
[4] = {"CM"},
[5] = {"Admin"}
}

local config = {
	showGamemasters = getBooleanFromString(getConfigValue('displayGamemastersWithOnlineCommand'))
}

function onSay(cid, words, param, channel)
	local players = getPlayersOnline()
	local strings = {""}
	local i, position = 1, 1
	local added = false
	
	for _, pid in ipairs(players) do
		if(added) then
			if(i > (position * 7)) then
				strings[position] = strings[position] .. ","
				position = position + 1
				strings[position] = ""
			else
				strings[position] = i == 1 and "" or strings[position] .. ", "
			end
		end

		if getPlayerAccess(pid) < 3 then
			strings[position] = strings[position] .. getCreatureName(pid) .." ["..getPlayerLevel(pid).."]"
			i = i + 1
			added = true
		else
			added = false
		end
	end
	
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, (i - 1) .. " player(s) online:")
	for i, str in ipairs(strings) do
		if(str:sub(str:len()) ~= ",") then
			str = str .. "."
		end
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
	end
	
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "-----------")
	
	local players2 = getPlayersOnline()
	local helpon = 0
	local rank = ""
	local str2 = ""
	
	for _, pid2 in ipairs(players2) do		
		if getPlayerAccess(pid2) > 0 then
                        if((config.showGamemasters or getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES) or not getPlayerCustomFlagValue(pid2, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES)) and (not isPlayerGhost(pid2) or getPlayerGhostAccess(cid) >= getPlayerGhostAccess(pid2))) then
			        rank = ranks[getPlayerAccess(pid2)]
			        str2 = str2 .. getCreatureName(pid2) .." ["..rank[1].."]  "
			        helpon = helpon + 1
                        end
		end		
	end
	if helpon > 0 then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, (helpon) .. " support player(s) online:")
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str2)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are no support players currently online.")
	end
	return true
end
 
Last edited:
not working :p

uhm dosnt get any error just this

Lua:
luagetplayercustomflagvalue > player not found
 
Back
Top