User:Ath/WebAPI Examples

From Team Fortress Wiki
< User:Ath
Revision as of 17:49, 5 February 2011 by Ath (talk | contribs) (Preliminary cleanup)
Jump to: navigation, search

This page is intended as a quick reference for working with the WebAPI. As such, it is intended to provide basic examples of how to make use of certain fields, not act as a tutorial.

GetPlayerItems

inventory

The inventory field contains a binary token encoded in denary form. The first 16 least significant bits denote an item's position within the backpack, the following 16 bits indicate which classes an item is currently equipped to. The first two most significant bits are unused.

function is_equipped($inventory_token)
{
  return ($inventory_token & 0x0FFF0000) ? true : false; 
}
function is_equipped_for_class($class, $inventory_token)
{
  return ($inventory_token & 0x80000000) && ($inventory_token & (0x00010000 << $class)); 
}
function extract_backpack_position($inventory_token)
{
  return $inventory_token & 0x0000FFFF;
}

GetSchema

TODO