Thread Tools Display Modes
05-06-08, 02:55 AM   #1
Oldeface
A Murloc Raider
Join Date: May 2008
Posts: 4
Getting a players class from name

How would I go about getting a players class from their name, if they are not near me (targetable), in my party, raid, guild, etc (As UnitClass() can only detect under these circumstances.)

I have a solution working, a-la /who: (where arg2= string value of players name)
PHP Code:
SendWho(arg2);
local charnameguildnamelevelrace, class = GetWhoInfo(1);

if(
tostring(class)=="Mage")
    ...
end 
Currently I've hooked the chat frame, and am parsing the arg1 strings of CHAT_MSG_SYSTEM to see if they are for the /who call and just ignore them.. the addon seemingly does this check without you knowing, however I would like another way besides having to do this workaround if possible!

Please let me know if I'm missing something.

Suggestions?

Last edited by Oldeface : 05-06-08 at 03:16 AM.
  Reply With Quote
05-06-08, 05:54 AM   #2
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
If the players you want to learn the class of are not in your group and aren't targeted by anyone in your group (or any target of anyone in your group, etc), then you'll have to hope that some random clue can help.
For instance, a chat message saying that the player is casting frostbolt lets you know that he's a mage. But the again, it might be a mob, you won't know until you've target him, and when you target him, you know the class instantly.
I don't really know how expensive it is, memory and CPU-wise, to keep tables of all the spells that players have and parse the combat log for any name that hasn't been classified yet, to assign a class... It's probably not huge, but still sensible if active when grinding in a Isle-like area, or in Shattrah (where people will be using many trade skills and almost no class ability).
  Reply With Quote
05-06-08, 01:01 PM   #3
Oldeface
A Murloc Raider
Join Date: May 2008
Posts: 4
Well, I'm actually trying to find the class of someone probably not in the same city, maybe even continent. essentially it's a addon that lets you flag certain classes you don't want to get whispers from when looking for more people for a party.

I was able to get the classes from SendWho/GetWhoInfo combo but I had to hook the chat frame, and parse some strings to hide the fact that I was doing so.. and there is always the potential of getting a bad class back (aka. Bob the Hunter messages me, and my addon SendWho's Bob, and returns the class of the first person in the who search, Bobby)

So, I was hoping maybe there was a more efficient way?
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Getting a players class from name


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off