okay .. with the following code ( some bug fixes to spelling mistakes ) it worked. I turned nameplates always on and walked in and out of range of my other character in the guild and the sound played. It may get annoying if several guildies arrive at the same time or you are running back and forth. So you may want to consider some sort of timing system so that it only alerts you for a person once every x seconds/minutes etc.
Lua Code:
local guildie={}
local f=CreateFrame("Frame") >>>>> Upper case F here
f:RegisterEvent("GUILD_ROSTER_UPDATE")
f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
f:SetScript("OnEvent",function(self,event,unit)
if event=="GUILD_ROSTER_UPDATE" then
local total=GetNumGuildMembers()
wipe(guildie)
for i=1,total do
local guid=select(17,GetGuildRosterInfo(i))
local localizedClass, englishClass, localizedRace, englishRace, sex, name, realm = GetPlayerInfoByGUID(guid)
if guid then
guildie[guid]=true
end
end
elseif event=="NAME_PLATE_UNIT_ADDED" then
local guid = UnitGUID(unit)
local localizedClass, englishClass, localizedRace, englishRace, sex, name, realm = GetPlayerInfoByGUID(guid)
if guildie[guid] then
PlaySound(416) >>> Upper case S here
print(name) >>> Displays name of guild member to know who .. you can use whatever alert system you want to display the message to make it more prominent if you want.
end
end
end) >>> Remember the bracket here