• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction (Support) Modified online command

Michael Orsino

Premium User
Premium User
Support Team
Joined
Nov 15, 2007
Messages
854
Solutions
10
Reaction score
389
Location
Santiago, Chile (Australian)
I have been editing my online command for a few reasons and I thought it would be good if the command also displayed the vocation of each player. I thought this would be very straight forward and I believe it should have been, but it is not working as it should for some reason. Hopefully you can help.

Below is the script, the part to pay attention to is
.. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. ":" .. getPlayerVocationName(cid) .. "]"
This should display in the format "Player Name [level:voc]" in the online list.
Instead, in place of the vocation name for all players it displays "None".

16:40 12 player(s) online:
16:40 Leos [106:None] - Monte [126:None] - Cyrus [150:None] - Fletch [159:None] - Shaylz [99:None] - Brightside [8:None] - Selur [176:None],
16:40 Migz [195:None] - Hr puffin stuff [123:None] - Sephiroth [176:None] - Bloker [162:None] - Dumb ***** With Gun [157:None]
Any insight would be great
Thank you

Code:
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((config.showGamemasters or getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges) or not getPlayerCustomFlagValue(pid, PlayerCustomFlag_GamemasterPrivileges)) and (not isPlayerGhost(pid) or getPlayerGhostAccess(cid) >= getPlayerGhostAccess(pid))) then
			strings[position] = strings[position] .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. ":" .. getPlayerVocationName(cid) .. "]"
			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

	return true
end
 
!online 200 would be a better update to this command. Showing level 200+. This would save you from a spammage full of noobs.
 
Fixed.

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((config.showGamemasters or getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges) or not getPlayerCustomFlagValue(pid, PlayerCustomFlag_GamemasterPrivileges)) and (not isPlayerGhost(pid) or getPlayerGhostAccess(cid) >= getPlayerGhostAccess(pid))) then
strings[position] = strings[position] .. .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. ":" .. getPlayerVocationName(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

return true
end
 
Back
Top