Buy Inventory: Difference between revisions

From Club Penguin Protocol
Jump to navigation Jump to search
imported>Arthur
No edit summary
imported>Refractor
No edit summary
Line 1: Line 1:
== About ==
{{PacketInfobox
|title=Buy Inventory
|handler=ai
|name=i
}}
 
This packet is sent by the client to the server requesting an item be added to their inventory. In response, the server can either deny the client the item because it doesn't exist, the client doesn't have enough coins, the client is not a member and the item they requested was for members only, or the item requested is patched.
This packet is sent by the client to the server requesting an item be added to their inventory. In response, the server can either deny the client the item because it doesn't exist, the client doesn't have enough coins, the client is not a member and the item they requested was for members only, or the item requested is patched.


Line 23: Line 28:
| align="center"| 413
| align="center"| 413
| align="center"| 0
| align="center"| 0
|}
== Variables ==
{| class="wikitable"
|-
! Variable
! Type
! Used In?
! Example
! Description
|-
| internal_room_id
| integer
| Both
|
| SmartFoxServer uses internal room IDs. However, these cannot be relied on (as they are suggested/generated by the main libraries), which is why Club Penguin usually uses the External Room ID instead.
|-
| item_id
| integer
| Both
|
| All item ids can be found in paper_items.json
|-
| cost
| integer
| Response
| 200
| The amount of coins deducted from the penguin.
|}
|}



Revision as of 00:41, 21 November 2014

Buy Inventory
Handler ai
Name i

This packet is sent by the client to the server requesting an item be added to their inventory. In response, the server can either deny the client the item because it doesn't exist, the client doesn't have enough coins, the client is not a member and the item they requested was for members only, or the item requested is patched.

The requested item's id will always be the second-to-last section of the packet, and the item's cost will be the last. In the following example(s), the item's id is 413, and costs 0 coins.

If the client meets all the requirements to purchase the item, the server will send back the 'buy inventory' packet, this time it has the item's cost, and still contains the item's id. The item's id is sent back to the client to let them know which item they have successfully purchased, so they can look up information (i.e name, sprite file) of the item via crumbs. The item's cost is sent back so the client will know how many coins to deduct from the interface.

Examples

Client-side %xt%s%i#ai%1%413%
Server-side %xt%ai%1%413%0%

Structure

Item ID Cost
413 0

Variables

Variable Type Used In? Example Description
internal_room_id integer Both SmartFoxServer uses internal room IDs. However, these cannot be relied on (as they are suggested/generated by the main libraries), which is why Club Penguin usually uses the External Room ID instead.
item_id integer Both All item ids can be found in paper_items.json
cost integer Response 200 The amount of coins deducted from the penguin.

Possible Errors

ID Description
402 Item not available
400 Already purchased
401 Not enough coins
805 Item with this ID doesn’t exist / membership required

See also