Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. public void AddXP(string channel, string user)
  2. {
  3. XElement XP = XElement.Load(@"Data\XP.xml");
  4. string NewXP = null;
  5. string NewLvl = null;
  6. string Lvl = null;
  7. foreach (XElement ele in XP.Descendants(GetTopic(channel, user)))
  8. {
  9. NewXP = Convert.ToString(Convert.ToInt32(ele.Attribute("XP").Value) + 2);
  10. NewLvl = Convert.ToString(Math.Floor(0.18 * (Math.Sqrt(Convert.ToInt32(NewXP))) + 1));
  11. Lvl = ele.Attribute("Lvl").Value.ToString();
  12. }
  13. XDocument AddXP = XDocument.Load(@"Data\XP.xml");
  14. XElement users = AddXP.Element("users").Element(GetTopic(channel, user));
  15. users.SetAttributeValue("XP", NewXP);
  16. if (Convert.ToInt32(NewLvl) > Convert.ToInt32(Lvl))
  17. {
  18. users.SetAttributeValue("Lvl", NewLvl);
  19. }
  20. AddXP.Save(@"Data\XP.xml");
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement