Guest User

Untitled

a guest
Jan 18th, 2016
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. internal class LotteryCommand : Command
  2. {
  3. public LotteryCommand()
  4. : base("lottery", "Lottery Command - Can be used every 24 hours, if you win, you get gold, if you lose, you get nothing.")
  5. {
  6. }
  7.  
  8. protected override bool Process(Player player, RealmTime time, string[] args)
  9. {
  10. Random rand = new Random();
  11.  
  12. string name = player.Name;
  13.  
  14. string lottonum = rand.Next(0, 100).ToString();
  15. if (player.Client.Account.Lottery == false) //false means they are free to use the command
  16. {
  17. if (int.Parse(lottonum) > 49)
  18. {
  19. player.Manager.Database.DoActionAsync(db =>
  20. {
  21. player.Credits = db.UpdateCredit(player.Client.Account, +5000);
  22. player.UpdateCount++;
  23.  
  24. });
  25. }
  26. foreach (Client i in player.Manager.Clients.Values)
  27. {
  28. i.SendPacket(new TextPacket
  29. {
  30. BubbleTime = 0,
  31. Stars = -1,
  32. Name = "Lottery - " + name,
  33. Text = "rolled a " + lottonum
  34. });
  35. }
  36. }
  37. if (player.Client.Account.Lottery == true) // true means they used the command within the past 24h, so return false
  38. {
  39. player.SendError("You've already used this within the past 24 hours");
  40. return false;
  41. }
  42. return true;
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment