• 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

KylerXX

Active Member
Joined
Jun 24, 2010
Messages
439
Reaction score
30
Request thread (the idea of the script): http://otland.net/f132/partycheck-guildcheck-142338/

Commands explanations:
-!partycheck:
-. It should show on Server Log channel how many knights, paladins, druids and sorcerers are in the party, and show the 3 knights with higher level (to know who is blocking or will do it).

-!guildcheck
-. It should show on Server Log channel how many players of the guild are online, showing their names, and after that, show the 3 knights with higher level.



*. IMG:
sinttulozqq.png


*. Tested on: TFS 0.3.6
*. If someone can adapt this code to TFS 0.4!(Special request)

_

Create a LUA file called partyguildcheck.lua and add this:
Note: (If you need the change max range you will edit the local 'highlevel', thanks.)
Lua:
	-- Dnt edit.
	function getOnlineGuildMembers(cid) -- by Xafterin
		local t = {}
		local p = getPlayersOnline()
		local g = getPlayerGuildId(cid)
		for _, ps in ipairs(p) do
			local gs = getPlayerGuildId(ps)
			if(g == gs and gs > 0 and g > 0) then
				table.insert(t, ps)
			end
		end
		return t
	end
	function getGuildMembersByVoc(cid, voc) -- by Xafterin
		local h = getOnlineGuildMembers(cid)
		for _, gid in ipairs(h) do
			local vg = getPlayerVocation(gid)
			if(vg == voc) then
				local gv = {}
				table.insert(gv, gid)
				return gv
			end
		end
		return false
	end
	function getPartyMembersByVoc(cid, voc) -- by Xafterin
		local h = getPartyMembers(cid)
		local yv = {}
		for _, yid in ipairs(h) do
			local vx = getPlayerVocation(yid)
			if(vx == voc) then
				table.insert(yv, yid)
			end
		end
		return yv
	end
	--No edit.
	local text = ""
	local count = 0
	local vocCount = {}
	local regv = {}
    -- Can edit.
	local highlevel = 125
function onSay(cid, words, param, channel)-- Made by Xafterin / KylerXX (from Otserv.es)
	if(words == "!partycheck") then
		local pmem = getPartyMembers(getPartyLeader(cid))
		text = "-- Party Check --\n"
		if(type(pmem) == "table") then
			if(#pmem <= 1) then
				text = text .. "You are alone!!!"
				return doPlayerSendTextMessage(cid, 22, text)
			elseif(#pmem > 1) then
				for i = 0, 4 do
					local k = getPartyMembersByVoc(cid, i)
					local vocvar = getVocationInfo(i).name
					text = text .. " " .. #k .. " " .. vocvar .. "\n" 
				end
				local k2 = getPartyMembersByVoc(cid, 4)
				text = text .. "\n  --High knights: "
				for _, kid in ipairs(k2) do
					local klvl = getPlayerLevel(kid)
					if(klvl >= highlevel) then
						count = count + 1
						if(count <= 3) then
							text = text .. getPlayerName(kid) .. "[".. klvl .."]" .. (count < 3 and ", " or ".")
						end
					end
				end
				text = text .. "."
			end                                          
		else
			text = "-- You are not in any party. -- "
		end
	elseif(words == "!guildcheck") then
		local gmem = getOnlineGuildMembers(cid)
		text = "-- Guild Check --\n"
		if(#gmem ~= 0) then
			local noneCount = 0
			local g = {name = getPlayerGuildName(cid)}
			text = "[".. g.name .."] There are ".. #gmem .." players playing. "
			for _, gid in ipairs(gmem) do
				noneCount = noneCount + 1
				text = text .. getPlayerName(gid) .. (noneCount == #gmem and "." or ", ") 
			end
			local k2 = getPartyMembersByVoc(cid, 4)
			text = text .. "\n  --High knights: "
			for _, kid in ipairs(k2) do
				local klvl = getPlayerLevel(kid)
				if(klvl >= highlevel) then
					count = count + 1
					if(count <= 3) then
						text = text .. getPlayerName(kid) .. "[".. klvl .."]" .. (count < 3 and ", " or ".")
					end
				end
			end
			text = text .. "."
		else
			text = "You are not in a guild."
		end
	end

	return doPlayerSendTextMessage(cid, 22, text)
end


talkactions.xml
XML:
	<talkaction words="!guildcheck;!partycheck" event="script" value="partyguildcheck.lua"/>


Any error, ask here, very thanks and good bye.
 
Last edited:
0.4

!partycheck error
Code:
[1:18:22.650] [Error - TalkAction Interface] 
[1:18:22.650] data/talkactions/scripts/mtibia/check_party_guild.lua:onSay
[1:18:22.650] Description: 
[1:18:22.650] ...ata/talkactions/scripts/mtibia/check_party_guild.lua:63: bad argument #1 to 'ipairs' (table expected, got boolean)
[1:18:22.650] stack traceback:
[1:18:22.650]   [C]: in function 'ipairs'
[1:18:22.650]   ...ata/talkactions/scripts/mtibia/check_party_guild.lua:63: in function <...ata/talkactions/scripts/mtibia/check_party_guild.lua:39>
There are 400 players online.


!guildcheck error
Code:
[1:18:24.373] [Error - TalkAction Interface] 
[1:18:24.373] data/talkactions/scripts/mtibia/check_party_guild.lua:onSay
[1:18:24.373] Description: 
[1:18:24.373] ...ata/talkactions/scripts/mtibia/check_party_guild.lua:91: bad argument #1 to 'ipairs' (table expected, got boolean)
[1:18:24.373] stack traceback:
[1:18:24.373]   [C]: in function 'ipairs'
[1:18:24.373]   ...ata/talkactions/scripts/mtibia/check_party_guild.lua:91: in function <...ata/talkactions/scripts/mtibia/check_party_guild.lua:39>
 
Last edited:
that's because there are not knights in the guild, then returns false and can't enter to the loop

Lua:
function getOnlineGuildMembers(cid) -- by Xafterin
		local t = {}
		local p = getPlayersOnline()
		local g = getPlayerGuildId(cid)
		for _, ps in ipairs(p) do
			local gs = getPlayerGuildId(ps)
			if(g == gs and gs > 0 and g > 0) then
				table.insert(t, ps)
			end
		end
		return t
	end
	function getGuildMembersByVoc(cid, voc) -- by Xafterin
		local h = getOnlineGuildMembers(cid)
		for _, gid in ipairs(h) do
			local vg = getPlayerVocation(gid)
			if(vg == voc) then
				local gv = {}
				table.insert(gv, gid)
				return gv
			end
		end
		return false
	end
	function getPartyMembersByVoc(cid, voc) -- by Xafterin
		local h = getPartyMembers(cid)
		for _, yid in ipairs(h) do
			local vx = getPlayerVocation(yid)
			if(vx == voc) then
				local yv = {}
				table.insert(yv, yid)
				return yv
			end
		end
		return false
	end
	local text = ""
	local vocCount = {}
function onSay(cid, words, param, channel)-- Made by Xafterin / KylerXX (from Otserv.es)
	if(words == "!partycheck") then
		local pmem = getPartyMembers(getPartyLeader(cid))
		text = "-- Party Check --\n"
		if(type(pmem) == "table") then
			if(#pmem == 1) then
				text = text .. "You are alone!!!"
				return doPlayerSendTextMessage(cid, 22, text)
			else
				for _, pyd in ipairs(pmem) do
					local v = getPlayerVocation(pyd)
					local getp = getPlayerParty(pyd)
					for i = 0, 4 do
						local regv = {}
						regv[i] = 0
						if(v == i) then
							regv[v] = regv[v]+1
							local vocvar = getVocationInfo(i).name
							text = text .. " " .. regv[v] .. " " .. vocvar .. "\n"
						end
					end
				end
				local k = getPartyMembersByVoc(cid, 4)
				
				if (k) then
					text = text .. "\n  --High knights: "
					for _, kid in ipairs(k) do
						local count = 0
						local klvl = getPlayerLevel(kid)
						if(klvl > 0) then
							count = count + 1
							if(count <= 3) then
								text = text .. getPlayerName(kid) .. "[".. klvl .."]" .. (count < 3 and ", " or ".")
							end
						end
					end
					text = text .. "."
				end
			end                                          
		else
			text = "-- You are not in any party. -- "
		end
	elseif(words == "!guildcheck") then
		local gmem = getOnlineGuildMembers(cid)
		text = "-- Guild Check --\n"
		if(#gmem ~= 0) then
			local noneCount = 0
			local g = {name = getPlayerGuildName(cid)}
			text = "[".. g.name .."] There are ".. #gmem .." players playing. "
			for _, gid in ipairs(gmem) do
				noneCount = noneCount + 1
				text = text .. getPlayerName(gid) .. (noneCount == #gmem and "." or ", ") 
			end
			local k = getGuildMembersByVoc(cid, 4)
			
			if (k ) then
				text = text .. "\n  --High knights: "
		
				for _, kid in ipairs(k) do
					local count = 0
					local klvl = getPlayerLevel(kid)
					if(klvl > 0) then
						count = count + 1
						if(count <= 3) then
							text = text .. getPlayerName(kid) .. "[".. klvl .."]" .. (count < 3 and ", " or ".")
						end
					end
				end
			
				text = text .. "."
			end
		else
			text = "You are not in a guild."
		end
	end
 
	return doPlayerSendTextMessage(cid, 22, text)
end
btw, nice script Xafterin xD
 
Last edited:
Not really working the party check part and also I would make some improvements to the guild check.

1) The guild check should show line by line each player name with the vocation and the level, why? Becausee you could show around 80 players without problem, if you don't do like this, you will be able to show around just 200 characters (letters), also the top knights is not beeing shown... Read the code down here.
2) The party check part isn't working, take a look at this:

Code:
01:22 Bienvenido a mtibia 2011!
01:22 Your last visit was on Wed Dec 21 01:19:32 2011..
01:23 [Insomniacs] There are 24 players playing. Piscolero, Necroz, Nachote, Point One, Gore, Existenz, Horo Horo, Volao, Nino, Arwen, Naliu Mastermind, Cryscrys war, Spartacus, Hirurinaceus, Walking, Janoxx, Capel, Psymagic, Zerodark, Gonzalo The Great, Galactica Rush, Residente, Kendo Kaponi, Kito.
01:23 -- You are not in any party. -- 
01:23 Unnamed has been invited. Open the party channel to communicate with your members.
01:23 Master Pala has been invited. Open the party channel to communicate with your members.
01:23 Marley has been invited. Open the party channel to communicate with your members.
01:23 Superiouz has been invited. Open the party channel to communicate with your members.
01:24 Cristian has been invited. Open the party channel to communicate with your members.
01:24 Master Pala has joined the party.
01:24 Izokka has been invited.
01:24 Unnamed has joined the party.
01:24 Cristian has joined the party.
01:24 Nixon has been invited.
01:24 Abandon all ships has been invited.
01:24 Tulon has been invited.
01:24 Nixon has joined the party.
01:24 Tepaseoql has been invited.
01:24 Izokka has joined the party.
01:24 -- Party Check --
 1 Paladin
 1 Sorcerer
01:24 Tulon has joined the party.
01:24 Kito: Algun knight online?
01:24 Zagita has been invited.
01:24 Zagita has joined the party.
01:24 -- Party Check --
 1 Paladin
 1 Sorcerer
01:24 -- Party Check --
 1 Paladin
 1 Sorcerer
01:25 Izokka has left the party.
01:25 You see cobbled pavement.
01:25 Capitan gope has been invited.
01:25 Capitan gope has joined the party.
01:25 -- Party Check --
 1 Paladin
 1 Sorcerer
 
Okay, I will try to fix the top knights code and !partycheck code (I refresh the thread with this script):
Lua:
	-- Dnt edit.
	function getOnlineGuildMembers(cid) -- by Xafterin
		local t = {}
		local p = getPlayersOnline()
		local g = getPlayerGuildId(cid)
		for _, ps in ipairs(p) do
			local gs = getPlayerGuildId(ps)
			if(g == gs and gs > 0 and g > 0) then
				table.insert(t, ps)
			end
		end
		return t
	end
	function getGuildMembersByVoc(cid, voc) -- by Xafterin
		local h = getOnlineGuildMembers(cid)
		for _, gid in ipairs(h) do
			local vg = getPlayerVocation(gid)
			if(vg == voc) then
				local gv = {}
				table.insert(gv, gid)
				return gv
			end
		end
		return false
	end
	function getPartyMembersByVoc(cid, voc) -- by Xafterin
		local h = getPartyMembers(cid)
		for _, yid in ipairs(h) do
			local vx = getPlayerVocation(yid)
			if(vx == voc) then
				local yv = {}
				table.insert(yv, yid)
				return yv
			end
		end
		return false
	end
	--Dnt edit.
	local text = ""
	local count = 0
	local vocCount = {}
	local regv = {}
	local noneCount = 0
    -- Can edit.
	local highlevel = 100
function onSay(cid, words, param, channel)-- Made by Xafterin / KylerXX (from Otserv.es)
	if(words == "!partycheck") then
		local pmem = getPartyMembers(getPartyLeader(cid))
		text = "-- Party Check --\n"
		if(type(pmem) == "table") then
			if(#pmem == 1) then
				text = text .. "You are alone!!!"
				return doPlayerSendTextMessage(cid, 22, text)
			else
				for _, pyd in ipairs(pmem) do
					local v = getPlayerVocation(pyd)
					local getp = getPlayerParty(pyd)
					if(v > 0) then
						regv[i] = 0
						regv[v] = regv[v]+1
						local vocvar = getVocationInfo(i).name
						text = text .. regv[v] .. "" .. vocvar .. "\n " 
					end
				end
				local k = getPartyMembersByVoc(cid, 4)
				text = text .. "\n  --High knights: "
				for _, kid in ipairs(k) do
					local klvl = getPlayerLevel(kid)
					if(klvl > highlevel) then
						count = count + 1
						if(count <= 3) then
							text = text .. getPlayerName(kid) .. "[".. klvl .."]" .. (count < 3 and ", " or ".")
						end
					end
				end
				text = text .. "."
			end                                          
		else
			text = "-- You are not in any party. -- "
		end
	elseif(words == "!guildcheck") then
		local gmem = getOnlineGuildMembers(cid)
		text = "-- Guild Check --\n"
		if(#gmem ~= 0) then
			local g = {name = getPlayerGuildName(cid)}
			text = "[".. g.name .."] There are ".. #gmem .." players playing. "
			for _, gid in ipairs(gmem) do
				noneCount = noneCount + 1
				text = text .. getPlayerName(gid) .. (noneCount == #gmem and "." or ", ") 
			end
			local k = getGuildMembersByVoc(cid, 4)
			text = text .. "\n  --High knights: "
			for _, kid in ipairs(k) do
				local klvl = getPlayerLevel(kid)
				if(klvl > highlevel) then
					count = count + 1
					if(count <= 3) then
						text = text .. getPlayerName(kid) .. "[".. klvl .."]" .. (count < 3 and ", " or ".")
					end
				end
			end
			text = text .. "."
		else
			text = "You are not in a guild."
		end
	end

	return doPlayerSendTextMessage(cid, 22, text)
end

I hope it works!
 
Last edited:
Code:
[2:6:52.805] [Error - TalkAction Interface]
[2:6:52.805] data/talkactions/scripts/mtibia/check_party_guild.lua:onSay
[2:6:52.805] Description:
[2:6:52.805] ...ata/talkactions/scripts/mtibia/check_party_guild.lua:93: bad argument #1 to 'ipairs' (table expected, got boolean)
[2:6:52.805] stack traceback:
[2:6:52.805]    [C]: in function 'ipairs'
[2:6:52.805]    ...ata/talkactions/scripts/mtibia/check_party_guild.lua:93: in function <...ata/talkactions/scripts/mtibia/check_party_guild.lua:46>

Uhmm...

Code:
[2:7:51.824] [Error - TalkAction Interface]
[2:7:51.824] data/talkactions/scripts/mtibia/check_party_guild.lua:onSay
[2:7:51.824] Description:
[2:7:51.824] ...ata/talkactions/scripts/mtibia/check_party_guild.lua:59: table index is nil
[2:7:51.824] stack traceback:
[2:7:51.824]    ...ata/talkactions/scripts/mtibia/check_party_guild.lua:59: in function <...ata/talkactions/scripts/mtibia/check_party_guild.lua:46>

Uhmmm x2 xD
 
This one, on 0.3.6 works fine, if someone can convert to 0.4 for kito2 and Knight God!
Lua:
-- Dnt edit.
	function getOnlineGuildMembers(cid) -- by Xafterin
		local t = {}
		local p = getPlayersOnline()
		local g = getPlayerGuildId(cid)
		for _, ps in ipairs(p) do
			local gs = getPlayerGuildId(ps)
			if(g == gs and gs > 0 and g > 0) then
				table.insert(t, ps)
			end
		end
		return t
	end
	function getGuildMembersByVoc(cid, voc) -- by Xafterin
		local h = getOnlineGuildMembers(cid)
		for _, gid in ipairs(h) do
			local vg = getPlayerVocation(gid)
			if(vg == voc) then
				local gv = {}
				table.insert(gv, gid)
				return gv
			end
		end
		return false
	end
	function getPartyMembersByVoc(cid, voc) -- by Xafterin
		local h = getPartyMembers(cid)
		local yv = {}
		for _, yid in ipairs(h) do
			local vx = getPlayerVocation(yid)
			if(vx == voc) then
				table.insert(yv, yid)
			end
		end
		return yv
	end
	--No edit.
	local text = ""
	local count = 0
	local vocCount = {}
	local regv = {}
    -- Can edit.
	local highlevel = 125
function onSay(cid, words, param, channel)-- Made by Xafterin / KylerXX (from Otserv.es)
	if(words == "!partycheck") then
		local pmem = getPartyMembers(getPartyLeader(cid))
		text = "-- Party Check --\n"
		if(type(pmem) == "table") then
			if(#pmem <= 1) then
				text = text .. "You are alone!!!"
				return doPlayerSendTextMessage(cid, 22, text)
			elseif(#pmem > 1) then
				for i = 0, 4 do
					local k = getPartyMembersByVoc(cid, i)
					local vocvar = getVocationInfo(i).name
					text = text .. " " .. #k .. " " .. vocvar .. "\n" 
				end
				local k2 = getPartyMembersByVoc(cid, 4)
				text = text .. "\n  --High knights: "
				for _, kid in ipairs(k2) do
					local klvl = getPlayerLevel(kid)
					if(klvl >= highlevel) then
						count = count + 1
						if(count <= 3) then
							text = text .. getPlayerName(kid) .. "[".. klvl .."]" .. (count < 3 and ", " or ".")
						end
					end
				end
				text = text .. "."
			end                                          
		else
			text = "-- You are not in any party. -- "
		end
	elseif(words == "!guildcheck") then
		local gmem = getOnlineGuildMembers(cid)
		text = "-- Guild Check --\n"
		if(#gmem ~= 0) then
			local noneCount = 0
			local g = {name = getPlayerGuildName(cid)}
			text = "[".. g.name .."] There are ".. #gmem .." players playing. "
			for _, gid in ipairs(gmem) do
				noneCount = noneCount + 1
				text = text .. getPlayerName(gid) .. (noneCount == #gmem and "." or ", ") 
			end
			local k2 = getPartyMembersByVoc(cid, 4)
			text = text .. "\n  --High knights: "
			for _, kid in ipairs(k2) do
				local klvl = getPlayerLevel(kid)
				if(klvl >= highlevel) then
					count = count + 1
					if(count <= 3) then
						text = text .. getPlayerName(kid) .. "[".. klvl .."]" .. (count < 3 and ", " or ".")
					end
				end
			end
			text = text .. "."
		else
			text = "You are not in a guild."
		end
	end

	return doPlayerSendTextMessage(cid, 22, text)
end
 
Back
Top