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

[Need help from scripter] Simple problem

mpa

Member
Joined
Oct 8, 2008
Messages
319
Reaction score
13
Location
Sweden
How do i get all the names in 1 box instead of like 1 million?

Code:
local config = {
	showGamemasters = getConfigInfo('displayGamemastersWithOnlineCommand')
}

function onSay(cid, words, param)
	local players = getPlayersOnline()
	local strings = {}
	local curStr = 1
	local nrGMs = 0
	for i, pid in ipairs(players) do
		if(i > curStr * 7) then
			curStr = curStr + 1
		end

		if(strings[curStr] == nil) then
			strings[curStr] = ""
			breakline = ""
		elseif(strings[curStr] ~= "") then
			breakline = ", "
		end

		if(config.showGamemasters ~= "yes") then
			if(getPlayerCustomFlagValue(pid, PlayerCustomFlag_GamemasterPrivileges) == FALSE or getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges) == TRUE) then
				strings[curStr] = strings[curStr] .. breakline .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. "]"
			else
				nrGMs = nrGMs + 1
			end
		else
			strings[curStr] = strings[curStr] .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. "]"
		end
	end

	doPlayerPopupFYI(cid,(#players - nrGMs) .. " player(s) online:")
	for i, string in ipairs(strings) do
		if(string ~= "") then
			doPlayerPopupFYI(cid, string .. ".")
		end
	end
	return TRUE
end
 
Well, Im noob but maybe...
change:
Code:
	for i, string in ipairs(strings) do
		if(string ~= "") then
			doPlayerPopupFYI(cid, string .. ".")
		end
	end
to
Code:
doPlayerPopupFYI(cid, strings)

;o
 
Well, Im noob but maybe...
change:
Code:
	for i, string in ipairs(strings) do
		if(string ~= "") then
			doPlayerPopupFYI(cid, string .. ".")
		end
	end
to
Code:
doPlayerPopupFYI(cid, strings)

;o

Lol didn't work. First a box came up where it said: "52 players online", i pressed ok and got de-bug :D
 
Last edited:
I don't know LUA so I'll comment what should go there and maybe it'll work if you translate it.
Code:
	for i, string in ipairs(strings) do
		if(string ~= "") then
			--string1 = string & new line
                -- else
                        -- exit for
		end
	end
        doPlayerPopupFYI(cid, string1)
Would that work?

Jo3
 
I don't know LUA so I'll comment what should go there and maybe it'll work if you translate it.
Code:
	for i, string in ipairs(strings) do
		if(string ~= "") then
			--string1 = string & new line
                -- else
                        -- exit for
		end
	[COLOR="Red"]end[/COLOR]
        doPlayerPopupFYI(cid, string1)
Would that work?

Jo3

You already 'exit' for where the red end is. :p

string & newline would be something like:
string1 = string.."\n
 
Code:
DISPLAY_MESSAGES = 1
DISPLAY_INBOX = 2

local config = {
	showGamemasters = asBoolean(getConfigInfo('displayGamemastersWithOnlineCommand')),
	displayType = DISPLAY_INBOX
}

function onSay(cid, words, param)
	local players = getPlayersOnline()
	local strings = {}
	local curStr = 1
	local nrGMs = 0
	local breakline = ""
	for i, pid in ipairs(players) do
		if(i > curStr * 7) then
			curStr = curStr + 1
		end

		if(strings[curStr] == nil) then
			strings[curStr] = ""
			breakline = ""
		elseif(strings[curStr] ~= "") then
			breakline = ", "
		end

		if(config.displayType ~= 1) then
			breakline = "\n"
		end

		if(config.showGamemasters ~= TRUE) then
			if(getPlayerCustomFlagValue(pid, PlayerCustomFlag_GamemasterPrivileges) == FALSE or getPlayerCustomFlagValue(cid, 

PlayerCustomFlag_GamemasterPrivileges) == TRUE) then
				strings[curStr] = strings[curStr] .. breakline .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. "]"
			else
				nrGMs = nrGMs + 1
			end
		else
			strings[curStr] = strings[curStr] .. breakline .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. "]"
		end
	end

	local playersOnline = #players
	local tmp = ""
	if(playersOnline > 1) then
		local tmp = "(s)"
	end

	local header = (playersOnline - nrGMs) .. " player" .. tmp .. " online"
	if(config.displayType == DISPLAY_MESSAGES) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, header .. ":")
		for i, string in ipairs(strings) do
			if(string ~= "") then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, string .. ".")
			end
		end
	else
		local str = ""
		for i, string in ipairs(strings) do
			str = str .. string
		end
		doPlayerPopupFYI(cid, header .. ".\n " .. str)
	end
	return TRUE
end

You can change in config displayType
 
After pasting it into file change:
Code:
if(getPlayerCustomFlagValue(pid, PlayerCustomFlag_GamemasterPrivileges) == FALSE or getPlayerCustomFlagValue(cid, 

PlayerCustomFlag_GamemasterPrivileges) == TRUE) then
to
Code:
if(getPlayerCustomFlagValue(pid, PlayerCustomFlag_GamemasterPrivileges) == FALSE or getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges) == TRUE) then

:eek:
 
Then remove it and change this line:
if(config.showGamemasters ~= TRUE) then
to
if(config.showGamemasters ~= "yes") then
 
Code:
DISPLAY_MESSAGES = 1
DISPLAY_INBOX = 2

local config = {
	showGamemasters = 0
}

function onSay(cid, words, param)
	local players = getPlayersOnline()
	local strings = {}
	local curStr = 1
	local nrGMs = 0
	local breakline = ""
	for i, pid in ipairs(players) do
		if(i > curStr * 7) then
			curStr = curStr + 1
		end

		if(strings[curStr] == nil) then
			strings[curStr] = ""
			breakline = ""
		elseif(strings[curStr] ~= "") then
			breakline = ", "
		end

		if(config.displayType ~= 1) then
			breakline = "\n"
		end

		if(config.showGamemasters ~= TRUE) then
			if(getPlayerCustomFlagValue(pid, PlayerCustomFlag_GamemasterPrivileges) == FALSE or getPlayerCustomFlagValue(cid, 

PlayerCustomFlag_GamemasterPrivileges) == TRUE) then
				strings[curStr] = strings[curStr] .. breakline .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. "]"
			else
				nrGMs = nrGMs + 1
			end
		else
			strings[curStr] = strings[curStr] .. breakline .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. "]"
		end
	end

	local playersOnline = #players
	local tmp = ""
	if(playersOnline > 1) then
		local tmp = "(s)"
	end

	local header = (playersOnline - nrGMs) .. " player" .. tmp .. " online"
	if(config.displayType == DISPLAY_MESSAGES) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, header .. ":")
		for i, string in ipairs(strings) do
			if(string ~= "") then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, string .. ".")
			end
		end
	else
		local str = ""
		for i, string in ipairs(strings) do
			str = str .. string
		end
		doPlayerPopupFYI(cid, header .. ".\n " .. str)
	end
	return TRUE
end

It's working now!
 
Back
Top