Top leaderboard using Arrays.

Howdy, this is a thread regarding top leaderboard. This implemented code is using arrays.

Player event( Join) -> If variable NOT exists( %player%_arrIndex(saved)) -> Increment variable( GlobalIndex(saved)) -> Set variable( %player%_arrIndex(saved) = GlobalIndex) -> Insert element( arr(TopLeaderboard(saved)), index = GlobalIndex, Value = "0, %player%")

Player event( Kill) -> Increment variable( %player%-kills) -> Combine text( "%player%-kills kills by " + "%player%", %player%-combined-text) -> Replace element( TopLeaderboard, %player%_arrIndex, "%player%-combined-text") -> Call function( Leaderboard.Refresh)

Function( Leaderboard.Refresh) -> Sort array( *descending*, TopLeadeboard, TLBsorted(saved)) -> Get element( TLBsorted, 1, Top#1(saved)) -> Get element( TLBsorted, 2, Top#2(saved)) -> Get element( TLBsorted, 3, Top#3(saved)) -> Create hologram( TOPLB, var(Top#1, Top#2, Top#3)

# Player Join Event
Player event(Join) -> If variable NOT exists(%player%_arrIndex(saved))
    -> Increment variable(GlobalIndex(saved))
    -> Set variable(%player%_arrIndex(saved) = GlobalIndex)
    -> Insert element(arr(TopLeaderboard(saved)), index = GlobalIndex, Value = "0, %player%")

# Player Kill Event
Player event(Kill) -> Increment variable(%player%-kills)
    -> Combine text("%player%-kills kills by " + "%player%", %player%-combined-text)
    -> Replace element(TopLeaderboard, %player%_arrIndex, "%player%-combined-text")
    -> Call function(Leaderboard.Refresh)

# Leaderboard Refresh Function
    -> Sort array(*descending*, TopLeaderboard, TLBsorted(saved))
    -> Get element(TLBsorted, 1, Top#1(saved))
    -> Get element(TLBsorted, 2, Top#2(saved))
    -> Get element(TLBsorted, 3, Top#3(saved))
    -> Create hologram(TOPLB, var(Top#1, Top#2, Top#3))

This code isn't fit for a large scaled game due to array size limitations & load. This is my implementation using arrays and can be found working in /ad oshot(hope so). There is another method w/o arrays and involves comparing player kills var to top 1,2,3 if they aren't in top 1,2,3 and set them as top player if there kills are more than them.

Read this far? Consider liking the post <3