Ir para conteúdo
  • 0

Hamsterbob

Pergunta

Tenho esse comando aqui de online

 

 

 

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) .. "]"
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

ele já vem nos otservers, mas eu quero mudar ele, o normal dele é :
22:47 2 player(s) online:
22:47 Insane fuck [230], Test [151].
só que eu quero que fique assim:
22:47 2 player(s) online:
22:47 Insane fuck [230, MS], Test [151, ED].
22:47 Tem 1 sorceres, 1 druids, 0 paladins e 0 knights online no server.
Eu não entendo nada de script ai fui tentar fazer algo e ficou assim:
22:51 2 player(s) online:
22:51 Insane fuck [230, 5], Test [151, 6].

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) .. ", " .. getPlayerVocation(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

Eu sei que pode por o getPlayerVocationName mas a menságem vai ficar muito grande :/
Alguem sabe? :D
Editado por Hamsterbob
Link para o comentário
Compartilhar em outros sites

9 respostass a esta questão

Posts Recomendados

  • 0

Editado:

 

 

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

local function getAccessName(pid)
	local name = ""
	local access = getPlayerAccess(pid)
	if (access == 0) then name = "Player"
	elseif access == 1 then name = "Tutor"
	elseif access == 2 then name = "S.Tutor"
	elseif access == 3 then name = "GM"
	elseif access == 4 then name = "CM"
	elseif access == 5 then name = "GOD"
	else return false
	end
	return name
end

 
function onSay(cid, words, param, channel)
	local players = getPlayersOnline()
	local strings = {""}
	local stringsx = {""}
	local sorc,druid,paladin,knight,rook = 0,0,0,0,0
	local staff = 0
 
	local i, j, position, positionx = 1, 1, 1, 1
	local added = false
	local addedx = false
	local vocations = {
		[0] = "None",
		[1] = "S",
		[2] = "D",
		[3] = "P",
		[4] = "K",
		[5] = "MS",
		[6] = "ED",
		[7] = "RP",
		[8] = "EK",
		}
 
	for _, pid in ipairs(players) do
        -- Implementacion por Xafterin.
        if isSorcerer(pid) then
            sorc = sorc + 1
        elseif isDruid(pid) then
            druid = druid + 1
        elseif isPaladin(pid) then
            paladin = paladin + 1
        elseif isKnight(pid) then
            knight = knight + 1
		end
		--
 
		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))) and not (getPlayerAccess(pid) > 0)) then
			strings[position] = strings[position] .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. ", " .. vocations[getPlayerVocation(pid)] .. "]"
			i = i + 1
			added = true
		else		
			added = false
		end	
	end
	
	for _, pid in ipairs(players) do
		if (getPlayerAccess(pid) > 0) then
			
			if(addedx) then
				if(j > (positionx * 7)) then
					stringsx[positionx] = stringsx[positionx] .. ","
					positionx = positionx + 1
					stringsx[positionx] = ""
				else
					stringsx[positionx] = j == 1 and "" or stringsx[positionx] .. ", "
				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
				stringsx[positionx] = stringsx[positionx] .. getCreatureName(pid) .. " [" .. getAccessName(pid) .. "]"
				j = j + 1
				addedx = true
			else		
				addedx = false
			end	
		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 .. "\n" .. sorc .." sorcerers, ".. druid .." druids, ".. paladin .." paladins e  ".. knight .." knights."
		end
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
	end
	
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tem " .. (j - 1) .. " staff online:")
	for j, strx in ipairs(stringsx) do
		if(strx:sub(strx:len()) ~= ",") then
			strx = strx .. "."
		end
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, strx)
 	end
 
return true
end 

 

 

Link para o comentário
Compartilhar em outros sites

  • 0

Assim vai funcionar:

 

 

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
	local vocations = {
	[0] = "None",
	[1] = "S",
	[2] = "D",
	[3] = "P",
	[4] = "K",
	[5] = "MS",
	[6] = "ED",
	[7] = "RP",
	[8] = "EK",
	}	
	
	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) .. ", " .. vocations[getPlayerVocation(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 

 

 

 

--- Você tem que usar uma tabela para colocar qual vai ser o nome das vocações

 

--Edit: Cometi um erro

Editado por Incur
Link para o comentário
Compartilhar em outros sites

  • 0

Sem pressa, tu é foda cara


Galera, quero o script ainda, peguei o do incur e outro que achei aqui e tentei fazer

 

ele ficou assim :

 

18:38 [GOD] [100, ED].
18:38 [GOD] [100, ED]0 sorcerers, 1 druids, 0 paladins e 0 knights.
eu quero que fique assim :
18:38 [GOD] [100, ED].
18:38 Tem 0 sorcerers, 1 druids, 0 paladins e 0 knights.

local config = {
showGamemasters = getBooleanFromString(getConfigValue('displayGamemastersWithOnlineCommand'))
}
function onSay(cid, words, param, channel)
local players = getPlayersOnline()
local strings = {""}
local sorc,druid,paladin,knight,rook = 0,0,0,0,0
local i, position = 1, 1
local added = false
local vocations = {
[0] = "None",
[1] = "S",
[2] = "D",
[3] = "P",
[4] = "K",
[5] = "MS",
[6] = "ED",
[7] = "RP",
[8] = "EK",
}
for _, pid in ipairs(players) do
-- Implementacion por Xafterin.
if isSorcerer(pid) then
sorc = sorc + 1
elseif isDruid(pid) then
druid = druid + 1
elseif isPaladin(pid) then
paladin = paladin + 1
elseif isKnight(pid) then
knight = knight + 1
end
---
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) .. ", " .. vocations[getPlayerVocation(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
for i, str in ipairs(strings) do
if(str:sub(str:len()) ~= ",") then
str = str .. sorc .." sorcerers, ".. druid .." druids, ".. paladin .." paladins e ".. knight .." knights."
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
end
return true
end

Eu sei que o problema fica ali no segundo str mas não sei mudar sem dar error, alguem ajuda? A linda pessoa que me ajudar vai ganhar vários reps '-'
Editado por Hamsterbob
Link para o comentário
Compartilhar em outros sites

  • 0

quase perfeito, só ficou ruim a parte dos staffs

 

eu mudei algumas coisas ao meu gosto ficou assim

 

 

 

local config = {
showGamemasters = getBooleanFromString(getConfigValue('displayGamemastersWithOnlineCommand'))
}
local function getAccessName(pid)
local name = ""
local access = getPlayerAccess(pid)
if (access == 0) then name = "Player"
elseif access == 1 then name = "Tutor"
elseif access == 2 then name = "Senior Tutor"
elseif access == 3 then name = "GM"
elseif access == 4 then name = "CM"
elseif access == 5 then name = "GOD"
else return false
end
return name
end
function onSay(cid, words, param, channel)
local players = getPlayersOnline()
local strings = {""}
local stringsx = {""}
local sorc,druid,paladin,knight,rook = 0,0,0,0,0
local staff = 0
local i, j, position, positionx = 1, 1, 1, 1
local added = false
local addedx = false
local vocations = {
[0] = "None",
[1] = "S",
[2] = "D",
[3] = "P",
[4] = "K",
[5] = "MS",
[6] = "ED",
[7] = "RP",
[8] = "EK",
}
for _, pid in ipairs(players) do
-- Implementacion por Xafterin.
if isSorcerer(pid) then
sorc = sorc + 1
elseif isDruid(pid) then
druid = druid + 1
elseif isPaladin(pid) then
paladin = paladin + 1
elseif isKnight(pid) then
knight = knight + 1
end
--
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))) and not (getPlayerAccess(pid) > 0)) then
strings[position] = strings[position] .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. ", " .. vocations[getPlayerVocation(pid)] .. "]"
i = i + 1
added = true
else
added = false
end
end
for _, pid in ipairs(players) do
if (getPlayerAccess(pid) > 0) then
if(addedx) then
if(j > (positionx * 7)) then
stringsx[positionx] = stringsx[positionx] .. ","
positionx = positionx + 1
stringsx[positionx] = ""
else
stringsx[positionx] = j == 1 and "" or stringsx[positionx] .. ", "
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
stringsx[positionx] = stringsx[positionx] .. getCreatureName(pid) .. " [" .. getAccessName(pid) .. "]"
j = j + 1
addedx = true
else
addedx = false
end
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 .. "\n" .. "Vocações : " .. sorc .." sorcerers, ".. druid .." druids, ".. paladin .." paladins e ".. knight .." knights."
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Tem " .. (j - 1) .. " staff online:")
for j, strx in ipairs(stringsx) do
if(strx:sub(strx:len()) ~= ",") then
strx = strx .. "."
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, strx)
end
return true
end

não da error na distro, mas ficou assim,
10:59 1 player(s) online:
10:59 Elaa [1, P]
Vocações : 0 sorcerers, 1 druids, 1 paladins e 0 knights.
10:59 Tem 1 staff online:
10:59 [GOD] [GOD].

 

e se um player normal desse online mesmo tendo staff online aparece

 

11:03 1 player(s) online:
11:03 Elaa [1, P]
Vocações : 0 sorcerers, 1 druids, 1 paladins e 0 knights.
11:03 Tem 0 staff online:
11:03 .
ficaria melhor tbm se n tivesse staff online aparecesse a mensagem: Não há staffs online no momento.
Editado por Hamsterbob
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...