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:
*. 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.)
talkactions.xml
Any error, ask here, very thanks and good bye.
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:
*. 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: