Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Function returns decimal player slot for $player_slot returned by DOTA2 WebAPI. $player_slot∈(0, 4)∪(128, 132) result∈(0, 9)
function determine_playerslot($player_slot)
$binary = sprintf('%08b', $player_slot);
$team = substr($binary, 0, 1);
$slot = bindec(substr($binary, 1));
return $team * 5 + $slot;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.