Skript help with Scoreboards [Skellett]

Discussion in 'Skript' started by fakepixel, May 19, 2018.

  1. Hey.

    Thanks for clicking on my post. I have a very cool idea, but don't know how to create it. I use StylishBoards made by Skellett (Limeglass) and i was wondering If there is a way to make a System where someone gets money, and it'll show for everyone on the Scoreboard in a List.

    If they had low amount, they'd be at the bottom, if they had a lot of money, they'd be at the top. And if someone received money, it would change the scoreboard for everyone, and the player who got more money, would move up in the scoreboard. If someone would leave the server, the player would dissapear from the Scoreboard (same with joining, they'd appear on scoreboard with the amount of points)

    Thank you for reading, and I hope I can make something like this. Currently have no clue how to start!
     
  2. you need to make top15 money sorting I guess(because only 15 lines can be written in scoreboards) and then just put the sorted data into slots
     
  3. Right, I can sort them (to lowest to highest) money. But how do i make it so when someone gets more money than someone else, they get moved up, while the other person moves down ?

    @Govindas
     
  4. Two

    Two

    To make this efficiently you need to give the money to players trough some skript function, this way skript can know when a player gets money. You would also need to save the amount of money each player has into a variable.

    An example
    Code (Text):
    function addMoney(p: player, i: integer):
        add {_i} to {_p}'s balance
        set {money::%{_p}'s uuid%} to {_p}'s balance

    function removeMoney(p: player, i: integer):
        subtract {_i} from {_p}'s balance
        set {money::%{_p}'s uuid%} to {_p}'s balance
    After that you can update the scoreboard with sorted version of {money::*} (used in above example) every time a player gets money, or in certain intervals
    For example: (Using RandomSk sorting)
    Code (Text):
    function update(b: boolean):
        set {_list::*} to {money::*} sorted from highest to lowest
        set {_limit} to 10 #How many of the top you want
        loop {_list::*}:
            add 1 to {_i}
            set {top::%{_i}%::name} to loop-index
            set {top::%{_i}%::money} to loop-value
            {_i} >= {_limit}
            exit 1 section
    Didn't have time to test this bit of code

    After the update function has been ran, variables {top::1-10::name} and {top::1-10::money} will have info about the richest players.

    And if someone left the server just
    Code (Text):
    on disconnect:
        delete {money::%player%}
        update(true)


    Edit: After posting I realized that I missed one thing from your post and that this have could been made easier. Still should work.
     
    #4 Two, May 22, 2018
    Last edited: May 22, 2018
    • Like Like x 1
  5. Hi, i've made a scoreboard skript. Much easier, try it :)
    Hope this idea was good :)