2

I want to make an XP shop but I'm not sure about how to detect if people have sufficient XP Levels.

Can anyone help me?

5

You can test for player's levels using the l= or lm= arguments in the target selector.

For example, if I am looking for all players with at 5 or more levels, I would use:

/testfor @a[lm=5]

or, all players that have 3 or more levels of EXP, but equal to/less than 8:

/testfor @a[l=8,lm=3]

or, all players that have 5 or less levels:

/testfor @a[l=5]

or, exactly 8 levels:

/testfor @a[l=8,lm=8]

as 8 will be true for both lm and l but 7 will become false for lm and 9 would be false for l because a selector will only select players IF all the arguments are true.

See the wiki for more information.

| improve this answer | |
  • So would I do /testfor @a[l=8,lm=8] if I wanted players to have to have exactly 8 levels? – FireStrike289 Nov 16 '14 at 11:04
  • That's correct. 8 will be true for both lm and l but 7 will become false for lm and 9 would be false for l. Remember: A selector will only select players IF all the arguments are true. – aytimothy Nov 16 '14 at 11:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.