Obtaining Player Class from Name

Donavin69

Member
I am trying to find a way to get the class of a player from a chat message. I can easily get the name, but the name doesn't resolve in any way in mafia that I have found. Is there a way to do something along the lines of a /whois, and return a result?
 

Catch-22

Active member
get_player_id( string ) might be more useful for you than just the name, from that you should be able to visit their profile and extract the class. It's not as nice to have to do things that way though, so feel free to open up a feature request as I believe KoLmafia can get that information for you in a more efficient way (I can't say the feature will actually be approved, though).
 

Bale

Minion
It may not be as "nice" a way, but it is a better way. If the player has a custom title, /whois will return that instead of their class so it won't always work properly. visit_url( "showplayer.php?who=" + get_player_id( name )) will always contain the player's class, even if they do have a custom title. That's why I don't think that the /whois method deserves a feature request.


PHP:
matcher classy = create_matcher("Class:</b></td><td>(.+?)</td>"
   , visit_url( "showplayer.php?who=" + get_player_id( name ));
if(find(classy)) 
   print("Player: " + name + ", Class: " + classy.group(1));
 
Last edited:

Catch-22

Active member
It may not be as "nice" a way, but it is a better way. If the player has a custom title, /whois will return that instead of their class so it won't always work properly. visit_url( "showplayer.php?who=" + get_player_id( name )) will always contain the player's class, even if they do have a custom title. That's why I don't think that the /whois method deserves a feature request.

Very good point, I agree wholeheartedly.
 

Donavin69

Member
The Get_Player_ID(String) is exactly what I was looking for, it isn't on the 'Master function list' on the wiki. Bale you rock, saved me figuring out how to make that matcher!

Thanks for your help!
 

Bale

Minion
The Get_Player_ID(String) is exactly what I was looking for, it isn't on the 'Master function list' on the wiki.

Yeah, it's only on the "to do" list page. I'm kinda behind on adding new functions, but at least I keep a list of stuff that isn't done.


Bale you rock, saved me figuring out how to make that matcher!

Thanks for your help!

You're welcome. I figured that since I was actually looking at the page I'd do it since it was a pretty simple matcher.
 
Top