Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: Decode Inventory Token (method GetPlayerItems)

  1. #1
    Basic Member
    Join Date
    Dec 2013
    Posts
    44

    Smile Decode Inventory Token (method GetPlayerItems)

    http://wiki.teamfortress.com/wiki/We...etPlayerItems/

    How decode Inventory Token ?
    I need get item slot number in inventory.

    PHP Code:
                    $inventory_token base_convert($item['inventory'], 322);
                    
    $slot base_convert(substr($inventory_token, -16), 210);
                    echo 
    $slot.' '
    Output big values - more 40200!
    What error?

  2. #2
    Basic Member Netshroud's Avatar
    Join Date
    Dec 2011
    Posts
    166
    It's literally right there on the page you linked: http://wiki.teamfortress.com/wiki/WebAPI/GetPlayerItems (no trailing slash because MediaWiki)

  3. #3
    Basic Member
    Join Date
    Dec 2013
    Posts
    44

    Smile

    I found simple solution for PHP 5.3 (32 bit system)!

    PHP Code:
    if ($item['inventory'] > 2147483649) {
        
    $slot bcsub($item['inventory'], 2147483649);
    } else {
        
    $slot $item['inventory']-1;

    Result is number slot 0...720!

    Enjoy!

  4. #4
    Basic Member Netshroud's Avatar
    Join Date
    Dec 2011
    Posts
    166
    Where did you get 2147483649 from?

  5. #5
    Basic Member Kangaroux's Avatar
    Join Date
    Jan 2013
    Posts
    958
    Quote Originally Posted by Netshroud View Post
    Where did you get 2147483649 from?
    2^31 + 1
    Quote Originally Posted by Hitokiri Battousai View Post
    Firstly hi, i am not a racist but really i hate all of russians....

  6. #6
    Basic Member Netshroud's Avatar
    Join Date
    Dec 2011
    Posts
    166
    So you're including the higher 15 bits which indicate loadout/equip status as slot? And what about an item with a position of 0 or 1?

  7. #7
    Basic Member
    Join Date
    Dec 2013
    Posts
    44
    If you want use start position from 1 - need use 2147483648

  8. #8
    Basic Member Netshroud's Avatar
    Join Date
    Dec 2011
    Posts
    166
    That also wrongly ignores the loadout bits.

  9. #9
    Basic Member
    Join Date
    Dec 2013
    Posts
    44
    Quote Originally Posted by Netshroud View Post
    That also wrongly ignores the loadout bits.
    What your solve?

  10. #10
    Basic Member
    Join Date
    Dec 2013
    Posts
    44
    Maybe somebody share his script to define positions in Inventory ?!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •