- 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
Instead, in place of the vocation name for all players it displays "None".
Thank you
Below is the script, the part to pay attention to is
This should display in the format "Player Name [level:voc]" in the online list... getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. ":" .. getPlayerVocationName(cid) .. "]"
Instead, in place of the vocation name for all players it displays "None".
Any insight would be great16: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]
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