Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else if (command.length() >= 6 && command.compare(0,6,"insert") == 0 && arguments.size() >= 1)
- {
- int GambleLimit = 50000;
- int random_win = util::rand(0, 100);
- int bGold = static_cast<int>(util::variant(arguments[0]));
- PacketBuilder builder;
- PacketBuilder reply;
- int target_x = this->player->character->x;
- int target_y = this->player->character->y;
- switch (this->player->character->direction)
- {
- case DIRECTION_UP:
- target_y -= 1;
- break;
- case DIRECTION_RIGHT:
- target_x += 1;
- break;
- case DIRECTION_DOWN:
- target_y += 1;
- break;
- case DIRECTION_LEFT:
- target_x -= 1;
- break;
- }
- 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))
- {
- this->player->character->ServerMsg("You must stand infront of a slotmachine to gamble.");
- break;
- }
- if (bGold >= 1 && bGold < GambleLimit)
- {
- if (this->player->character->HasItem(1) >= bGold)
- {
- if (random_win < 50)
- {
- this->player->character->DelItem(1,bGold);
- reply.SetID(PACKET_ITEM, PACKET_JUNK);
- reply.AddShort(1);
- reply.AddThree(bGold);
- reply.AddInt(this->player->character->HasItem(1));
- reply.AddChar(this->player->character->weight);
- reply.AddChar(this->player->character->maxweight);
- CLIENT_SEND(reply);
- this->player->character->ServerMsg("You lost "+ util::to_string(bGold) +" gold, Maybe next time..");
- break;
- }
- else if(random_win > 50)
- {
- this->player->character->AddItem(1,bGold);
- reply.SetID(PACKET_ITEM, PACKET_GET);
- reply.AddShort(0);
- reply.AddShort(1);
- reply.AddThree(bGold);
- reply.AddChar(this->player->character->weight);
- reply.AddChar(this->player->character->maxweight);
- CLIENT_SEND(reply);
- this->player->character->ServerMsg("You have won "+ util::to_string(bGold) +" gold, Congratulatons!");
- break;
- }
- }
- }
- else
- {
- this->player->character->ServerMsg("You must insert between 1 and 50000 gold.");
- break;
- }
- }
Add Comment
Please, Sign In to add comment