How can I refer to a table to make a level system? I'm working on a RPG website. Users are awarded userpoints (named XP for the need of the "game") depending on their actions.

I want to make a level system based on these userpoints. I already made a table using Drupal Data, which stores values for each level (level number, minimum XP, maximum XP, and some ratios to apply when a user is earning points).

My question is : How can I refer to this table to check a user level (and all the values attached) depending on the user's amount of XP?

I tried with Rules, but no success.
Give it some thought to replace that table you made with:


a new content type (eg called "XP") and
with custom fields as in your question, such as:


level number.
minimum XP.
maximum XP.
some ratios.



That way you could create 1 node for each row in your table, with field values matching the values in those table rows. If appropriate, use the Feeds module to automatically create 1 node for each row in your table.

After you'd have created such nodes, you could use them in combination with the modules you're already using / considering, such as User Points and Rules. 

To implement that "level system" (as in your question), you can probably use the Goals module (disclosure: I'm the maintainer of it). If you're not familar with this module, have a look at "How to implement gamification in a Drupal site and award incentives?".

Bonus tip: since you're thinking of using User Points and Rules already, you may also want to look at the answer to "How to access current amount of earned userpoints in a Rules Condition?" (pretty sure you'll need something like that also).

PS: All this only requires site builder skills (no need for any custom coding).