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

!partycheck - !guildcheck

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,766
Solutions
1
Reaction score
225
Location
Chile, Santiago
Hi there, I need a command that works like this: 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).

Also the same for !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.

If someone could make this, I would be glad, :)
 
i use this but it wont work as u want it will just show guild memmbers online

PHP:
function onSay(cid, words, param)
	local onlineMembers = {}
	local playerGuild = getPlayerGuildId(cid)
 
	if playerGuild == 0 then
		return TRUE
	end
 
	for _, name in ipairs(getOnlinePlayers()) do
		if getPlayerGuildId(getPlayerByName(name)) == playerGuild then
			table.insert(onlineMembers, name)
		end
	end
 
	if #onlineMembers == 0 then
		doPlayerSendTextMessage(cid, 24, "There are no players online from your guild..")
	else
		local playersOnline = #onlineMembers
		local tmp = ""
		if(playersOnline > 1) then
			local tmp = "(s)"
		end
 
		local header = playersOnline .. " player" .. tmp .. " online from your guild."
		local str = ""
		for i, string in ipairs(onlineMembers) do
			str = "\n" .. str .. string .. "\n"
		end
		doPlayerPopupFYI(cid, header .. ".\n " .. str)
	end
	return LUA_NO_ERROR
end
 
Kito2, take this script. The code it works fine on TFS 0.3.6! The code follows all the features that you previously gave.

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)
				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 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)
			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 .. "."
		else
			text = "You are not in a guild."
		end
	end

	return doPlayerSendTextMessage(cid, 22, text)
end
 
Last edited:
Back
Top