Advertisement
Famous1337

Untitled

Jan 23rd, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1.  
  2. local players = {"master39","BombBloke"} -- Fill this table however you like.
  3.  
  4. commands.scoreboard("objectives add Kills totalKillCount") -- Sample objective.
  5. commands.scoreboard("objectives setDisplay sidebar Kills") -- Makes the counter visible to players (once they start).
  6.  
  7. local maxVal = 100 -- Highest value you expect a player to reach.
  8.  
  9. local function getKillCount(playerName)
  10. if not commands.xp("0 "..playerName) then return 0 end -- In case the player is not online.
  11.  
  12. local minGuess, maxGuess, curGuess = 0, maxVal, math.floor(maxVal / 2)
  13.  
  14. while curGuess >= minGuess and curGuess < maxGuess do
  15. if commands.testfor("@a[name="..playerName..",score_Kills="..tostring(curGuess).."]") then
  16. -- Score is equal to or less than curGuess.
  17. maxGuess = curGuess
  18. curGuess = minGuess + math.floor((maxGuess - minGuess) / 2)
  19. else
  20. -- Score is greater than curGuess.
  21. minGuess = curGuess
  22. curGuess = math.max(minGuess + 1, minGuess + math.floor((maxGuess - minGuess) / 2))
  23. end
  24. end
  25.  
  26. return curGuess
  27. end
  28.  
  29. -- A primitive score display loop:
  30. while true do
  31. term.clear()
  32. term.setCursorPos(1,1)
  33. for i = 1, #players do print(players[i]..": "..getKillCount(players[i])) end
  34. sleep(30) -- Or however many seconds you want between updates.
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement