Thursday, April 19, 2012

Getting the level of another player

So i need to get the level of another player other than my own and am getting it from a chat event so the name of that player is arg2, and then i try and pass that to the unit level command like this


Code:
level = UnitLevel("arg2");

but this returns wierd values(told me a level 68 was level 0) and not the level of the other person, what am i doing wrong or have i used the wrong command?

civil|||Code:
level = UnitLevel("unit")

Where unit is one of the strings found here ... http://www.wowwiki.com/UnitId

Player name is not one of the Base Values.|||Quote:









Code:
level = UnitLevel("unit")

Where unit is one of the strings found here ... http://www.wowwiki.com/UnitId

Player name is not one of the Base Values.




This is true - a player name is not one of the base values, but using a players name is valid.



According to WoWWiki:

"You can also use the name of a party or raid member as a unit ID: "name"

This must be spelled exactly and will be invalid if the named player is not a part of your party or raid.



Just remember that the person must be a part of your party/raid. If not then you have to use one of the base values.



Try removing the quotes around arg2 so you get:


Code:
level = UnitLevel(arg2);

With the quotes you are telling the program that arg2 is a literal string and to find a player with the name arg2 - thus the level return of 0.

No comments:

Post a Comment