You can't use arg2 with GetGuildInfo, but since you're scanning the party/raid you can make an adjustment to return the unit usable in GetGuildInfo:
Code:
local function NameIsGrouped(name)
if GetNumPartyMembers()>0 then
for i=1,4 do
if UnitName("party"..i)==name then
return "party"..i -- person in party, return party unit id
end
end
end
if not inGroup and GetNumRaidMembers()>0 then
for i=1,40 do
if UnitName("raid"..i)==name then
return "raid"..i -- person in raid, return raid unit id
end
end
end
return -- return nil (not necessary), name not in party/raid
end
Instead of true/nil, the function above will return the unit or nil. If Carl is raid30, then it will return "raid30" that you can use in GetGuildInfo. The final return isn't necessary, a function that doesn't return a value will always return nil.
Code:
OnEvent:
if event=="CHAT_MSG_WHISPER" then
local unit = NameIsGrouped(arg2 or "")
if unit and GetGuildInfo(unit)==GetGuildInfo("player") then
--[[ someone in party/raid in the same guild as you sent you that whisper ]]
end
end