- Joined
- May 29, 2023
- Messages
- 41
there are a few methods to making the leaderboard hologram
long story short you make an array or maybe 2 one containing scores and one containing the names fill it with empty data
then when the player gains a point or money or something you loop through the array checking if his name already exists in the array containing the names if not skip to the next part, if it does get the index of that name push up the data starting from the index we have selected until the last position of the array for example our player is at the position #2 we take the data from #3 and put it into #2, then #4 -> #3, #5 -> #4 and so on long story short this part removes the player's data from the leaderboard while keeping all of the other data in order now you might be asking why not just push down the data that is above the player's old position and replace the data at the new position with the players data well u can do this if the player score can only increase but decrease if the player's score were to decrease the player would have a lower position and you would find that the at player's old position the data is not being overwritten. for the next part we loop through the array containing the scores and compare the player's score to the score in the array from top to bottom if it is more get the index of it i will name this indextoreplace next we push down the data starting from the bottom up until the indextoreplace like #4 -> #5, #3 -> #4 and so on lastly we replace the data at the indextoreplace position with the player's data
instead of using a loop or recursive function with array to check the score and name and to push the data u can instead use a ton of if variables and elses and set variables this will make your code exponentially longer but there is not delay! unless ofcourse you reach the java depth limit error and now u have to put the wait block
the following logic is demonstrated as follows:
we start with an array with empty data:
name score
1. null1 0
2. null2 0
3. null3 0
4. null4 0
5. null5 0
player1 earns a score
his score will replace the score at #1
push down the data
name score
1. null1 0
2. null1 0
3. null2 0
4. null3 0
5. null4 0
replace the data
name score
1. Player1 1
2. null1 0
3. null2 0
4. null3 0
5. null4 0
player2 earns a score
his score will replace #2
push down the data
name score
1. Player1 1
2. null1 0
3. null1 0
4. null2 0
5. null3 0
replace the data
name score
1. Player1 1
2. Player2 1
3. null1 0
4. null2 0
5. null3 0
player 2 earns another score
push up the data
name score
1. Player1 1
2. null1 0
3. null2 0
4. null3 0
5. null4 0
push down the data
name score
1. Player1 1
2. Player1 1
3. null1 0
4. null2 0
5. null3 0
replace the data
name score
1. Player2 2
2. Player1 1
3. null1 0
4. null2 0
5. null3 0
player 2 point loses 1 point
push up the data
name score
1. Player1 1
2. null1 0
3. null2 0
4. null3 0
5. null4 0
push down the data
1. Player1 1
2. null1 0
3. null1 0
4. null2 0
5. null3 0
replace
1. Player1 1
2. Player2 1
3. null1 0
4. null2 0
5. null3 0
congratulashins you have created a fool proof leaderboard hologram even a fool can code it and when i mean fool i dont mean aalus
msg proximus0 if u have easier way
long story short you make an array or maybe 2 one containing scores and one containing the names fill it with empty data
then when the player gains a point or money or something you loop through the array checking if his name already exists in the array containing the names if not skip to the next part, if it does get the index of that name push up the data starting from the index we have selected until the last position of the array for example our player is at the position #2 we take the data from #3 and put it into #2, then #4 -> #3, #5 -> #4 and so on long story short this part removes the player's data from the leaderboard while keeping all of the other data in order now you might be asking why not just push down the data that is above the player's old position and replace the data at the new position with the players data well u can do this if the player score can only increase but decrease if the player's score were to decrease the player would have a lower position and you would find that the at player's old position the data is not being overwritten. for the next part we loop through the array containing the scores and compare the player's score to the score in the array from top to bottom if it is more get the index of it i will name this indextoreplace next we push down the data starting from the bottom up until the indextoreplace like #4 -> #5, #3 -> #4 and so on lastly we replace the data at the indextoreplace position with the player's data
instead of using a loop or recursive function with array to check the score and name and to push the data u can instead use a ton of if variables and elses and set variables this will make your code exponentially longer but there is not delay! unless ofcourse you reach the java depth limit error and now u have to put the wait block
the following logic is demonstrated as follows:
we start with an array with empty data:
name score
1. null1 0
2. null2 0
3. null3 0
4. null4 0
5. null5 0
player1 earns a score
his score will replace the score at #1
push down the data
name score
1. null1 0
2. null1 0
3. null2 0
4. null3 0
5. null4 0
replace the data
name score
1. Player1 1
2. null1 0
3. null2 0
4. null3 0
5. null4 0
player2 earns a score
his score will replace #2
push down the data
name score
1. Player1 1
2. null1 0
3. null1 0
4. null2 0
5. null3 0
replace the data
name score
1. Player1 1
2. Player2 1
3. null1 0
4. null2 0
5. null3 0
player 2 earns another score
push up the data
name score
1. Player1 1
2. null1 0
3. null2 0
4. null3 0
5. null4 0
push down the data
name score
1. Player1 1
2. Player1 1
3. null1 0
4. null2 0
5. null3 0
replace the data
name score
1. Player2 2
2. Player1 1
3. null1 0
4. null2 0
5. null3 0
player 2 point loses 1 point
push up the data
name score
1. Player1 1
2. null1 0
3. null2 0
4. null3 0
5. null4 0
push down the data
1. Player1 1
2. null1 0
3. null1 0
4. null2 0
5. null3 0
replace
1. Player1 1
2. Player2 1
3. null1 0
4. null2 0
5. null3 0
congratulashins you have created a fool proof leaderboard hologram even a fool can code it and when i mean fool i dont mean aalus
msg proximus0 if u have easier way