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

Lua:
local function getMembersOnline(tabla)
	if (type(tabla) == 'table') then
	local nohay = "There are not."
	str = "Members list:\n"
	str = str.. " Sorcerers (".. #players.sorcs.."): ".. (#players.sorcs == 1 and players.sorcs[1].."." or #players.sorcs > 1  and table.concat (players.sorcs, ", ").."." or nohay).. " \n"	
	str = str.. "Druids ("..#players.druids.."): ".. (#players.druids == 1 and players.druids[1].."." or #players.druids > 1 and table.concat (players.druids, ", ").."." or nohay).. "\n"
	str = str.. "Paladins ("..#players.paladins.."): "..(#players.paladins == 1 and paladins[1].."." or #players.paladins > 1  and table.concat (players.paladins, ", ").."." or nohay).. "\n"
	str = str.. "Kinas ("..#players.kinas.."): ".. (#players.kinas == 1 and players.kinas[1].."." or #players.kinas > 1 and not table.sort(players.sorcs,  function (a, b) return (a:match("%d+") < b:match("%d+")) end) and table.concat (players.kinas, ", ").."." or nohay).."\n"
	str = str .. "The best kinas are: "..(#players.kinas == 0 and nohay or #players.kinas == 1 and players.kinas[1].."." or #players.kinas == 2 and players.kinas[1]..", "..players.kinas[2] or #players.kinas == 3 and players.kinas[1]..", "..players.kinas[2] .. ", "..players.kinas[3])	
	end
				
	return str
end
			

function onSay(cid, words, param, channel)

	if (words == '/guildcheck') then
		if (getPlayerGuildId(cid) > 0) then
			players = {} 
			players.sorcs = {}
			players.druids = {}
			players.paladins = {}
			players.kinas = {}
	
			for _, pid in pairs (getPlayersOnline()) do
				if (getPlayerGuildId(pid) == getPlayerGuildId(cid) ) then
					local str = getPlayerName(pid).. " ["..getPlayerLevel(pid).."]"
					if (isSorcerer(pid)) then
						table.insert(players.sorcs, str)
					elseif (isDruid(pid)) then 
						table.insert(players.druids, str)
					elseif (isPaladin(pid)) then
						table.insert(players.paladins, str)
					elseif (isKnight(pid)) then
						table.insert(players.kinas, str)
					end
				end
			end
	
			doPlayerSendTextMessage(cid, MESSAGE_TYPES["blue"], getMembersOnline(players))
		else
			doPlayerSendCancel(cid, "You are not in a guild.")
		end
	elseif (words == '/partycheck') then
		if (isInParty(cid)) then
			players = {} 
			players.sorcs = {}
			players.druids = {}
			players.paladins = {}
			players.kinas = {}
			
			for _, pid in pairs(getPlayersOnline()) do
				
				if (isInParty(pid) and getPlayerParty(pid) == getPlayerParty(cid)) then
					str = getPlayerName(pid).. " ["..getPlayerLevel(pid).."]"
					if (isSorcerer(pid)) then
						table.insert(players.sorcs, str)
					elseif (isDruid(pid)) then 
						table.insert(players.druids, str)
					elseif (isPaladin(pid)) then
						table.insert(players.paladins, str)
					elseif (isKnight(pid)) then
						table.insert(players.kinas, str)
					end
				end
			end
			
			doPlayerSendTextMessage(cid, MESSAGE_TYPES["blue"],getMembersOnline(players) )
		else
			doPlayerSendCancel(cid,"You are not in a party.")
		end
	end
	return true
end
 
Last edited:
Thanks Jetro, it was working great a few minutes but now:

Code:
[13:28:15.026] [Error - TalkAction Interface]
[13:28:15.026] data/talkactions/scripts/mtibia/check_party_guild.lua:onSay
[13:28:15.026] Description:
[13:28:15.026] ...ata/talkactions/scripts/mtibia/check_party_guild.lua:9: attempt to concatenate a boolean value
[13:28:15.026] stack traceback:
[13:28:15.026]  ...ata/talkactions/scripts/mtibia/check_party_guild.lua:9: in function 'getMembersOnline'
[13:28:15.026]  ...ata/talkactions/scripts/mtibia/check_party_guild.lua:41: in function <...ata/talkactions/scripts/mtibia/check_party_guild.lua:16>
 
Error:

Code:
[17:22:20.615] [Error - TalkAction Interface]
[17:22:20.615] data/talkactions/scripts/mtibia/check_party_guild.lua:onSay
[17:22:20.615] Description:
[17:22:20.615] ...ata/talkactions/scripts/mtibia/check_party_guild.lua:9: attempt to concatenate a boolean value
[17:22:20.615] stack traceback:
[17:22:20.615]  ...ata/talkactions/scripts/mtibia/check_party_guild.lua:9: in function 'getMembersOnline'
[17:22:20.615]  ...ata/talkactions/scripts/mtibia/check_party_guild.lua:41: in function <...ata/talkactions/scripts/mtibia/check_party_guild.lua:16>
 
Known bug: it will show just the max characters of a normal message... Example:

Code:
21:38 Members list:
 Sorcerers (1): Kito [192]. 
Druids (22): Nylrad [190], Benners [192], Cerberous [206], Sellair Rush [188],
Charlex [210], Krewprecyz [202], Fardmorix [201], Quubo [206], Nazhoo [202],
Deathcrush [214], Scontrik [200], Jotapek [213], Chonox [178], Haron Rah [214],
Injek [196], Lord Zarpao [205], Bambino [184], Novinha [187], Nyziczciel fon [203],
Warrior Jah [218], Druiiidax [197], Dof Nacho [231].
Paladins (3): Teth [212], Conithaaxz [212], Malkka [191].
Kinas (3): Eternal Oblivion [152], Re

Solution:
Print Sorcerers (number):
Print 10 names and levels.
Print 10 names and levels.
etc....
Print Druids (number):
Print 10 names and levels.
Print 10 names and levels.
etc...
...
...
 
Back
Top