See this page for some usefull info about lua texts:
http://www.wowace.com/addons/pitbull4/pages/lua-texts/
This, along with PARTY_MEMBERS_CHANGED as event might be all that is needed.
Code:
if not UnitInRaid("player") then return
local myname = UnitName('player')
for i = 1 , GetNumRaidMembers() do
local name = GetRaidRosterInfo(i)
if ( name == myname ) then
return subgroup
end
end