• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

Question - Checking zone for PCs from a particular guild

Joined
Jul 25, 2023
RedCents
2,967¢
I'm struggling to do something with a Lua that I thought would be fairly simple and wondered if anyone could set me straight please!

I want a simple Lua to tell me if there is anyone from a particular guild in the zone and then I can set up text and audio alerts. I have been trying to get a condition working but think I am doing it wrong. I'm testing against:

mq.TLO.Spawncount.Guildname('guildnamehere')() > 0

... but I'm not sure I have the hang of these TLOs yet!

Anyone? I just need a nudge in the right direction to get a working condition.
 
I'm struggling to do something with a lua that I thought would be fairly simple and wondered if anyone could set me straight please!

I want a simple lua to tell me if there is anyone from a particular guild in the zone and then I can set up text and audio alerts. I have been trying to get a condition working but think I am doing it wrong. I'm testing against:

mq.TLO.Spawncount.Guildname('guildnamehere')() > 0

... but I'm not sure I have the hang of these TLOs yet!

Anyone? I just need a nudge in the right direction to get a working condition.
mq.TLO.SpawnCount('guildname SuperDuperGuild ')() >0
 
Doh! I tried something very close to that! Will try that format now - thank you!

EDIT:
OK - tried it and I'm clearly not getting this right. This is what I have as a test:

If mq.TLO.SpawnCount('Guildname guildnamehere ')() > 0 then
mq.cmd.echo('guildnamehere in ZONE')
end

It appears to parse without errors but I don't see the echo being reported anywhere.

I'm puzzled :confused:
 
Last edited:
Doh! I tried something very close to that! Will try that format now - thank you!

EDIT:
OK - tried it and I'm clearly not getting this right. This is what I have as a test:



It appears to parse without errors but I don't see the echo being reported anywhere.

I'm puzzled :confused:
You could start by debugging this in smaller steps. Like echo'ing the result of mq.TLO.SpawnCount('guildname SuperDuperGuild ')(), then you could echo the whole condition (... > 0). Until you get it to work for your usecase.
 
You could start by debugging this in smaller steps. Like echo'ing the result of mq.TLO.SpawnCount('guildname SuperDuperGuild ')(), then you could echo the whole condition (... > 0). Until you get it to work for your usecase.
Lua eval would be much more useful
 
Doh! I tried something very close to that! Will try that format now - thank you!

EDIT:
OK - tried it and I'm clearly not getting this right. This is what I have as a test:



It appears to parse without errors but I don't see the echo being reported anywhere.

I'm puzzled :confused:
Doh! I tried something very close to that! Will try that format now - thank you!

EDIT:
OK - tried it and I'm clearly not getting this right. This is what I have as a test:



It appears to parse without errors but I don't see the echo being reported anywhere.

I'm puzzled :confused:
mq.cmd('/echo WARNING GuildNameHere in zone')
 
This would be a useful tool with a GUI with the ability to add or remove guilds. Maybe even with an auto refresh rate with notification when a guild member arrives in zone, or when none of the members are still in zone. Maybe call it something like "Guild Watcher Lua". I know that many of us have caught heat from some guilds and would prefer to avoid them when possible. 🙏
 
It needs to be tested but I think I finally got something to work.

I couldn't make "guildname" work on anything (it may be that I never lighted on the right formatting, not sure). I did manage something with NearestSpawn and Guild but I had to set up different tests for when I'm in a group and out of a group (and iterate the NearestSpawn number when in group.

I'll test it properly and report back.
 
you can use something like this to look for the players in a guild by guildname


[CODE lang="Lua" title="search spawns by guildname"]local function GuildSearchPC(guild_name)
local tmp = {} -- holds results
local search = string.format('pc guildname "%s"', guild_name)
local cnt = mq.TLO.SpawnCount(search)() -- number of entities in said guild.
if cnt ~= nil or cnt > 0 then
for i = 1, cnt do
local pc = mq.TLO.NearestSpawn(i, search) -- itterate through the spawns one at a time to add the data to the temp table.
if pc ~= nil and pc.DisplayName() ~= nil then
local name = pc.DisplayName()
local guild = pc.Guild() or 'No Guild'
tmp[name] = {
name = name,
guild = string.format("<%s>", guild)
distance = math.floor(pc.Distance() or 0),
time = os.time(),
}
end
end
end
return tmp -- return the results for use later.
end[/CODE]

then you can iterate through the results and display how you choose either gui table \ list or printf to console.
 
[CODE lang="Lua" title="Gui GuildCheck"]
local mq = require('mq')
local ImGui = require('ImGui')
local RUNNING = false
local guildName = ''
local list = {}
local function GuildSearchPC(guild_name)
local tmp = {} -- holds results
local search = string.format('pc guildname %s', guild_name)
-- if check_safe_zone() then return tmp end
local cnt = mq.TLO.SpawnCount(search)()
if cnt ~= nil or cnt > 0 then
for i = 1, cnt do
local pc = mq.TLO.NearestSpawn(i, search)
if pc ~= nil and pc.DisplayName() ~= nil then
local name = pc.DisplayName()
local guild = pc.Guild() or 'No Guild'
tmp[name] = {
name = name,
guild = string.format("<%s>", guild),
distance = math.floor(pc.Distance() or 0),
time = os.time(),
}
end
end
end
return tmp
end
local function RenderGUI()
ImGui.SetNextWindowSize(400, 300, ImGuiCond.FirstUseEver)
local open, show = ImGui.Begin('Guild Search', true)
if show then
ImGui.Text('Search for players in a guild:')
guildName = ImGui.InputText('Guild Name', guildName)
ImGui.Separator()
if ImGui.BeginTable('Results', 3) then
ImGui.TableSetupColumn('Name')
ImGui.TableSetupColumn('Guild')
ImGui.TableSetupColumn('Distance')
ImGui.TableHeadersRow()
ImGui.TableNextRow()
for _, v in pairs(list) do
ImGui.TableNextColumn()
ImGui.Text(v.name)
ImGui.TableNextColumn()
ImGui.Text(v.guild)
ImGui.TableNextColumn()
ImGui.Text(tostring(v.distance))
end
ImGui.EndTable()
end
end
if not open then
RUNNING = false
end
ImGui.End()
end
local function init()
mq.imgui.init('Guild Search', RenderGUI)
RUNNING = true
end
local function MainLoop()
while RUNNING do
if guildName ~= '' then
list = GuildSearchPC(guildName)
else
list = {}
end
mq.delay(1000)
end
end
init()
MainLoop()
[/CODE]

simple GUI GuildCheck
 
[CODE lang="lua" title="Gui GuildCheck"]
local mq = require('mq')
local ImGui = require('ImGui')
local RUNNING = false
local guildName = ''
local list = {}
local function GuildSearchPC(guild_name)
local tmp = {} -- holds results
local search = string.format('pc guildname %s', guild_name)
-- if check_safe_zone() then return tmp end
local cnt = mq.TLO.SpawnCount(search)()
if cnt ~= nil or cnt > 0 then
for i = 1, cnt do
local pc = mq.TLO.NearestSpawn(i, search)
if pc ~= nil and pc.DisplayName() ~= nil then
local name = pc.DisplayName()
local guild = pc.Guild() or 'No Guild'
tmp[name] = {
name = name,
guild = string.format("<%s>", guild),
distance = math.floor(pc.Distance() or 0),
time = os.time(),
}
end
end
end
return tmp
end
local function RenderGUI()
ImGui.SetNextWindowSize(400, 300, ImGuiCond.FirstUseEver)
local open, show = ImGui.Begin('Guild Search', true)
if show then
ImGui.Text('Search for players in a guild:')
guildName = ImGui.InputText('Guild Name', guildName)
ImGui.Separator()
if ImGui.BeginTable('Results', 3) then
ImGui.TableSetupColumn('Name')
ImGui.TableSetupColumn('Guild')
ImGui.TableSetupColumn('Distance')
ImGui.TableHeadersRow()
ImGui.TableNextRow()
for _, v in pairs(list) do
ImGui.TableNextColumn()
ImGui.Text(v.name)
ImGui.TableNextColumn()
ImGui.Text(v.guild)
ImGui.TableNextColumn()
ImGui.Text(tostring(v.distance))
end
ImGui.EndTable()
end
end
if not open then
RUNNING = false
end
ImGui.End()
end
local function init()
mq.imgui.init('Guild Search', RenderGUI)
RUNNING = true
end
local function MainLoop()
while RUNNING do
if guildName ~= '' then
list = GuildSearchPC(guildName)
else
list = {}
end
mq.delay(1000)
end
end
init()
MainLoop()
[/CODE]

simple GUI GuildCheck

Wow - thanks very much for this Grimmier! This looks like a much better basis for what I want than I had.

The only issue I have is that it appears to search on the PC name rather than the player's guild. Looking at the code, I can't see why that is - any suggestions? I'm wondering whether the "guildname" search simply doesn't work!
 
Last edited:
so *guildname* doesnt always return a result on EQ side.. not sure how it responds the way it does, or why, but /who coolguildname from eq might want /who coolg or /who guildna to give a result.
 
It should search for whatever guild name you entered in the text field.

Then it stores player name guild name and distance for the spawns found into the table for display.
 
It should search for whatever guild name you entered in the text field.

Then it stores player name guild name and distance for the spawns found into the table for display.
Yep - that's what it looks as if it should do.

However, for me at least, it displays all of the right details for any character that has a name matching what is put in the text field (e.g. I type an "a" and get a list of all toons with an "a" in their name). It appears to be searching by PC name. Odd. I suspect the "guildname" spawn search filter is FUBARed (or there is something I am not seeing!)
 
Yep - that's what it looks as if it should do.

However, for me at least, it displays all of the right details for any character that has a name matching what is put in the text field (e.g. I type an "a" and get a list of all toons with an "a" in their name). It appears to be searching by PC name. Odd. I suspect the "guildname" spawn search filter is FUBARed (or there is something I am not seeing!)
I just said.. see what EQ wants /who coolguild, /who coolg... guilds are not partial name matches afaik, they are treated on there own table.
 
I just said.. see what EQ wants /who coolguild, /who coolg... guilds are not partial name matches afaik, they are treated on there own table.

Yes, I am using full names. The /who works fine as long as you use quotation marks (and yes, I have tried using quotes). The issue is that the search is on PC name and NOT guild name. This can be tested, for example, using the Lua Expression Evaluator on mq.TLO.SpawnCount('PC guildname a')() - it will tell you how many PCs in zone have an "a" in their name. That ain't right!
 
Yes, I am using full names. The /who works fine as long as you use quotation marks (and yes, I have tried using quotes). The issue is that the search is on PC name and NOT guild name. This can be tested, for example, using the LUA Expression Evaluator on mq.TLO.SpawnCount('PC guildname a')() - it will tell you how many PCs in zone have an "a" in their name. That ain't right!
Have you used other spawnsearch parameters?
Dropped PC, added equal, etc?
<https://docs.macroquest.org/reference/general/spawn-search/>
 
ok so it seems the guildname filter isn't working on live?

try this one then it just adds an extra step

[CODE lang="Lua" title="guildcheck"]local mq = require('mq')
local ImGui = require('ImGui')
local RUNNING = false
local guildName = ''
local list = {}
local function GuildSearchPC(guild_name)
local tmp = {} -- holds results
-- local search = string.format('pc guildname %s', guild_name)
local search = string.format('pc ') -- grab all players in zone
local cnt = mq.TLO.SpawnCount(search)()
if cnt ~= nil or cnt > 0 then
for i = 1, cnt do
local pc = mq.TLO.NearestSpawn(i, search)
if pc ~= nil and pc.DisplayName() ~= nil then
local name = pc.DisplayName()
local guild = pc.Guild() or 'No Guild'
-- check guild name matches if matched add to the table otherwise skip
if guild:lower() == guild_name:lower() or string.find(guild:lower(), guild_name:lower()) then
tmp[name] = {
name = name,
guild = string.format("<%s>", guild),
distance = math.floor(pc.Distance() or 0),
time = os.time(),
}
end
end
end
end
return tmp
end
local function RenderGUI()
ImGui.SetNextWindowSize(400, 300, ImGuiCond.FirstUseEver)
local open, show = ImGui.Begin('Guild Search', true)
if show then
ImGui.Text('Search for players in a guild:')
guildName = ImGui.InputText('Guild Name', guildName)
ImGui.Separator()
if ImGui.BeginTable('Results', 3) then
ImGui.TableSetupColumn('Name')
ImGui.TableSetupColumn('Guild')
ImGui.TableSetupColumn('Distance')
ImGui.TableHeadersRow()
ImGui.TableNextRow()
for _, v in pairs(list) do
ImGui.TableNextColumn()
ImGui.Text(v.name)
ImGui.TableNextColumn()
ImGui.Text(v.guild)
ImGui.TableNextColumn()
ImGui.Text(tostring(v.distance))
end
ImGui.EndTable()
end
end
if not open then
RUNNING = false
end
ImGui.End()
end
local function init()
mq.imgui.init('Guild Search', RenderGUI)
RUNNING = true
end
local function MainLoop()
while RUNNING do
if guildName ~= '' then
list = GuildSearchPC(guildName)
else
list = {}
end
mq.delay(1000)
end
end
init()
MainLoop()
[/CODE]
 
I gave up on the guildname spawnsearch and simply listed all PCs then checked their guild. What I have below uses Grimmier's lovely UI and lists everyone in zone and their distance.

It then prints a warning message (well, it spams it right now!) for anyone in the zone from the entered guild. That can be used to alert you to open the UI and see their distance (or just get out).

If I can stop it spamming I may add an audio alert but it works (thanks to Grimmier!)

EDIT: Just seen Grimmier's post so trying that!

local mq = require('mq')
local ImGui = require('ImGui')
local RUNNING = false
local guildName = ''
local list = {}
local function GuildSearchPC(guild_name)
local tmp = {} -- holds results
local search = string.format('pc')
-- if check_safe_zone() then return tmp end
local cnt = mq.TLO.SpawnCount(search)()
if cnt ~= nil or cnt > 0 then
for i = 1, cnt do
local pc = mq.TLO.NearestSpawn(i, search)
if pc ~= nil and pc.DisplayName() ~= nil then
local name = pc.DisplayName()
local guild = pc.Guild() or 'No Guild'
tmp[name] = {
name = name,
guild = string.format("<%s>", guild),
distance = math.floor(pc.Distance() or 0),
time = os.time(),
}
end
end
end
if cnt ~= nil or cnt > 0 then
for i = 1, cnt do
local pc = mq.TLO.NearestSpawn(i, search)
if pc.Guild() == guildName then printf('!!! WARNING %s in ZONE !!!', pc.DisplayName())
end
end
return tmp
end
end
local function RenderGUI()
ImGui.SetNextWindowSize(400, 300, ImGuiCond.FirstUseEver)
local open, show = ImGui.Begin('Guild Search', true)
if show then
ImGui.Text('Search for players in a guild:')
guildName = ImGui.InputText('Guild Name', guildName)
ImGui.Separator()
if ImGui.BeginTable('Results', 3) then
ImGui.TableSetupColumn('Name')
ImGui.TableSetupColumn('Guild')
ImGui.TableSetupColumn('Distance')
ImGui.TableHeadersRow()
ImGui.TableNextRow()
for _, v in pairs(list) do
ImGui.TableNextColumn()
ImGui.Text(v.name)
ImGui.TableNextColumn()
ImGui.Text(v.guild)
ImGui.TableNextColumn()
ImGui.Text(tostring(v.distance))
end
ImGui.EndTable()
end
end
if not open then
RUNNING = false
end
ImGui.End()
end
local function init()
mq.imgui.init('Guild Search', RenderGUI)
RUNNING = true
end
local function MainLoop()
while RUNNING do
if guildName ~= '' then
list = GuildSearchPC(guildName)
else
list = {}
end
mq.delay(1000)
end
end
init()
MainLoop()
 
[CODE lang="Lua" title="added alerts"]
local mq = require('mq')
local ImGui = require('ImGui')
local RUNNING = false
local doBeep = false
local lastZone = mq.TLO.Zone.ShortName() or ''
local guildName = ''
local list = {}
local alerted = {}
local function GuildSearchPC(guild_name)
local tmp = {} -- holds results
-- local search = string.format('pc guildname %s', guild_name)
local search = string.format('pc ')
local cnt = mq.TLO.SpawnCount(search)()
if cnt ~= nil or cnt > 0 then
for i = 1, cnt do
local pc = mq.TLO.NearestSpawn(i, search)
if pc ~= nil and pc.DisplayName() ~= nil then
local name = pc.DisplayName()
local guild = pc.Guild() or 'No Guild'
-- check guild name matches
if guild:lower() == guild_name:lower() or string.find(guild:lower(), guild_name:lower()) then
tmp[name] = {
name = name,
guild = string.format("<%s>", guild),
distance = math.floor(pc.Distance() or 0),
time = os.time(),
}
end
end
end
end
return tmp
end
local function RenderGUI()
ImGui.SetNextWindowSize(400, 300, ImGuiCond.FirstUseEver)
local open, show = ImGui.Begin('Guild Search', true)
if show then
ImGui.Text('Search for players in a guild:')
guildName = ImGui.InputText('Guild Name', guildName)
ImGui.SameLine()
if ImGui.Button('Clear') then
guildName = ''
list = {}
end
doBeep = ImGui.Checkbox('Do Beep', doBeep)
ImGui.Separator()
if ImGui.BeginTable('Results', 3) then
ImGui.TableSetupColumn('Name')
ImGui.TableSetupColumn('Guild')
ImGui.TableSetupColumn('Distance')
ImGui.TableHeadersRow()
ImGui.TableNextRow()
for _, v in pairs(list) do
ImGui.TableNextColumn()
ImGui.Text(v.name)
ImGui.TableNextColumn()
ImGui.Text(v.guild)
ImGui.TableNextColumn()
ImGui.Text(tostring(v.distance))
end
ImGui.EndTable()
end
end
if not open then
RUNNING = false
end
ImGui.End()
end
local function init()
mq.imgui.init('Guild Search', RenderGUI)
RUNNING = true
end
local function MainLoop()
while RUNNING do
local zone = mq.TLO.Zone.ShortName() or ''
if zone ~= lastZone then
alerted = {}
list = {}
printf('\ayZone changed from \ax\at%s \ax\ayto \ax\at%s\ax', lastZone, zone)
lastZone = zone
end
if guildName ~= '' then
list = GuildSearchPC(guildName)
else
list = {}
alerted = {}
end
local didAlert = false
for _, v in pairs(list) do
if alerted[v.name] == nil then
didAlert = true
printf("\arWARNING!!! \ax\at %s \ax\ay%s \axis in the Zone and is\ag %s\ax away!", v.name, v.guild, v.distance)
alerted[v.name] = true
end
end
if doBeep and didAlert then mq.cmdf('/beep') end
mq.delay(1000)
end
end
init()
MainLoop()
[/CODE]

added alerting and an option to do beeps
won't re-alert the same PC unless you have changed the filter or zoned =)
 
@grimmier - I can't thank you enough! I'm trying to learn a bit of Lua and this is so helpful as it has opened my eyes to some new things.
 
Question - Checking zone for PCs from a particular guild

Users who are viewing this thread

Back
Top
Cart