Guest User

Untitled

a guest
Jan 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. else if (command.length() >= 6 && command.compare(0,6,"insert") == 0 && arguments.size() >= 1)
  2. {
  3. int GambleLimit = 50000;
  4. int random_win = util::rand(0, 100);
  5. int bGold = static_cast<int>(util::variant(arguments[0]));
  6.  
  7. PacketBuilder builder;
  8. PacketBuilder reply;
  9.  
  10. int target_x = this->player->character->x;
  11. int target_y = this->player->character->y;
  12.  
  13. switch (this->player->character->direction)
  14. {
  15. case DIRECTION_UP:
  16. target_y -= 1;
  17. break;
  18.  
  19. case DIRECTION_RIGHT:
  20. target_x += 1;
  21. break;
  22.  
  23. case DIRECTION_DOWN:
  24. target_y += 1;
  25. break;
  26.  
  27. case DIRECTION_LEFT:
  28. target_x -= 1;
  29. break;
  30. }
  31. if (this->player->character->map->GetSpec(target_x, target_y) != Map_Tile::Gambling || (this->player->character->x != target_x && this->player->character->y != target_y))
  32. {
  33. this->player->character->ServerMsg("You must stand infront of a slotmachine to gamble.");
  34. break;
  35. }
  36. if (bGold >= 1 && bGold < GambleLimit)
  37. {
  38. if (this->player->character->HasItem(1) >= bGold)
  39. {
  40. if (random_win < 50)
  41. {
  42. this->player->character->DelItem(1,bGold);
  43. reply.SetID(PACKET_ITEM, PACKET_JUNK);
  44. reply.AddShort(1);
  45. reply.AddThree(bGold);
  46. reply.AddInt(this->player->character->HasItem(1));
  47. reply.AddChar(this->player->character->weight);
  48. reply.AddChar(this->player->character->maxweight);
  49. CLIENT_SEND(reply);
  50. this->player->character->ServerMsg("You lost "+ util::to_string(bGold) +" gold, Maybe next time..");
  51. break;
  52. }
  53. else if(random_win > 50)
  54. {
  55. this->player->character->AddItem(1,bGold);
  56. reply.SetID(PACKET_ITEM, PACKET_GET);
  57. reply.AddShort(0);
  58. reply.AddShort(1);
  59. reply.AddThree(bGold);
  60. reply.AddChar(this->player->character->weight);
  61. reply.AddChar(this->player->character->maxweight);
  62. CLIENT_SEND(reply);
  63. this->player->character->ServerMsg("You have won "+ util::to_string(bGold) +" gold, Congratulatons!");
  64. break;
  65. }
  66. }
  67. }
  68. else
  69. {
  70. this->player->character->ServerMsg("You must insert between 1 and 50000 gold.");
  71. break;
  72.  
  73. }
  74. }
Add Comment
Please, Sign In to add comment