Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.
If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!
Now, what are you waiting for? Join the community now!
LOOKING FOR A VERSION OF SKRIPT?
You can always check out skUnity Downloads for downloads and any other information about Skript!
i want to make it so if someone levels up it gets harder to do so. i wanted to do this by adding 5% to te xp you need to level up for every level. i tried using the exponential function to do so, but i could not get that to work. can someone pls help me?
Code:
on block break:
if player is a player:
chance of 15%:
show 30 totem at player
loop all players in radius 20 around player:
play "ENTITY_EXPERIENCE_ORB_PICKUP" to loop-player at volume 2
add 1 to {mining::%player%.exp}
if {mining::%player%.exp} is greater than or equal to 100:
set {mining::%player%.exp} to 0
add 1 to {mining::%player%.level}
wait 1 tick
send player title "" with subtitle "&aNew mining level: &c&l%{mining::%player%.level}%" for 3 seconds
#
on block break:
if player is a player:
chance of 15%:
play resurrection by totem on the player
loop players in radius 20 around player:
play sound "ENTITY_EXPERIENCE_ORB_PICKUP" with volume 100 with pitch 1 at loop-player for loop-player
add 1 to {mining::%player%.exp}
if {mining::%player%.exp} is greater than or equal to 100:
set {mining::%player%.exp} to 0
add 1 to {mining::%player%.level}
wait 1 tick
send title "" with subtitle "&aNew mining level: &c&l%{mining::%player%.level}%" to player for 3 seconds
#
on block break:
if player is a player:
chance of 15%:
play resurrection by totem on the player
loop players in radius 20 around player:
play sound "ENTITY_EXPERIENCE_ORB_PICKUP" with volume 100 with pitch 1 at loop-player for loop-player
add 1 to {mining::%player%.exp}
if {mining::%player%.exp} is greater than or equal to 100:
set {mining::%player%.exp} to 0
add 1 to {mining::%player%.level}
wait 1 tick
send title "" with subtitle "&aNew mining level: &c&l%{mining::%player%.level}%" to player for 3 seconds
I don't think you answered the person's request...
But I'll do it!
HOWEVER... first, we're gonna fix up this code. We're gonna use Ted as our example player.
FIRST (and only) PROBLEM:
The varables {mining::%player%.exp} and {mining::%player%.level} aren't really good, because using the type player only returns the player's name (unless you changed it in configs).
For example, if Ted changed their minecraft name, two things would happen:
1. all of Ted's mining levels and exp is gone. Just like that.
2. Any player that uses Ted's old minecraft name would get Ted's levels and exp.
Now, because I hate using periods in variables, I'm gonna completely rewrite the variables.
SOLUTION:
To fix this, we need to use the type player's uuid. "UUID" stands for "Unique ID", so we're just getting the player's unique ID that is tied to their minecraft account.
Now as for rewriting the variables...
See, because I'm adding corrections based off of MrGametop's code, he fixed the rest of the errors, so... Less work for me!
NOW ONTO THE REQUEST!
Based off of what you are telling me, you just want the exp needed for the player to level up get exponentially larger (by 0.05, or 5%). This is actually graphable. (The equation is [y= 100 * 1.05^x] if you're curious.)
Because it is graphable, we're just gonna use a function to get the max exp needed based off of the level that the player is already at.
The function will look something like this:
Code:
# this function is prolly extra lines of code that I could simplify but I WON'T because it makes it easier to understand the code.
function getExpNeeded(x: number = 0) :: number:
# Returns the experience needed to reach the next level based on the level the player is currently at.
set {_y} to (100 * 1.05^{_x}) # This is graphable; you can graph it if you want what each value of x will return. (it's exponential
return {_y}
And now, all we need to do is replace the 100 in if {mining::%player%.exp} is greater than or equal to 100: with our function.
The line would look like this:
Code:
# using our function to get the exp needed based on the level the player is at
if {mining::exp::%player's uuid%} is greater than or equal to getExpNeeded({mining::level::%player's uuid%}):
# (code here)
And now if we put it all together, our final code should look something like the spoiler. (It's a spoiler in case you want to try and do it yourself.)
Code:
# I added comments to everything :)
# Function to calculate experience needed for next level using exponential growth
function getExpNeeded(x: number = 0) :: number:
# Formula: 100 * 1.05^level
# This creates an exponential curve where each level requires more exp than the last
# Example: Level 1 needs 105 exp, Level 2 needs 110.25 exp, etc.
# (this is a tiny increment, but it's what you asked, so you can change this on your own time, lmao)
set {_y} to (100 * 1.05^{_x})
return {_y}
# Triggers when any block is broken
on block break:
# Check if the breaker is a player (not a piston, explosion, etc.)
if player is a player:
# 15% chance to trigger exp gain
chance of 15%:
# Visual effects
play resurrection by totem on the player # Creates totem animation
# Play sound for nearby players within 20 blocks
loop players in radius 20 around player:
play sound "ENTITY_EXPERIENCE_ORB_PICKUP" with volume 100 with pitch 1 at loop-player for loop-player
# Add mining experience
add 1 to {mining::exp::%player's uuid%}
# Level up system
# Check if the player's mining experience points are greater than or equal to
# the required experience points needed for the next level. This comparison is
# done using the player's UUID to ensure unique data storage per player.
if {mining::exp::%player's uuid%} is greater than or equal to getExpNeeded({mining::level::%player's uuid%}):
set {mining::exp::%player's uuid%} to 0 # Reset exp for next level
add 1 to {mining::level::%player's uuid%} # Increase level
wait 1 tick # Small delay for better message timing
# Show level up message as subtitle
send title "" with subtitle "&aNew mining level: &c&l%{mining::level::%player's uuid%}%" to player for 3 seconds
You're welcome! (and also tell me if the code doesn't work)
I don't think you answered the person's request...
But I'll do it!
HOWEVER... first, we're gonna fix up this code. We're gonna use Ted as our example player.
FIRST (and only) PROBLEM:
The varables {mining::%player%.exp} and {mining::%player%.level} aren't really good, because using the type player only returns the player's name (unless you changed it in configs).
For example, if Ted changed their minecraft name, two things would happen:
1. all of Ted's mining levels and exp is gone. Just like that.
2. Any player that uses Ted's old minecraft name would get Ted's levels and exp.
Now, because I hate using periods in variables, I'm gonna completely rewrite the variables.
SOLUTION:
To fix this, we need to use the type player's uuid. "UUID" stands for "Unique ID", so we're just getting the player's unique ID that is tied to their minecraft account.
Now as for rewriting the variables...
See, because I'm adding corrections based off of MrGametop's code, he fixed the rest of the errors, so... Less work for me!
NOW ONTO THE REQUEST!
Based off of what you are telling me, you just want the exp needed for the player to level up get exponentially larger (by 0.05, or 5%). This is actually graphable. (The equation is [y= 100 * 1.05^x] if you're curious.)
Because it is graphable, we're just gonna use a function to get the max exp needed based off of the level that the player is already at.
The function will look something like this:
Code:
# this function is prolly extra lines of code that I could simplify but I WON'T because it makes it easier to understand the code.
function getExpNeeded(x: number = 0) :: number:
# Returns the experience needed to reach the next level based on the level the player is currently at.
set {_y} to (100 * 1.05^{_x}) # This is graphable; you can graph it if you want what each value of x will return. (it's exponential
return {_y}
And now, all we need to do is replace the 100 in if {mining::%player%.exp} is greater than or equal to 100: with our function.
The line would look like this:
Code:
# using our function to get the exp needed based on the level the player is at
if {mining::exp::%player's uuid%} is greater than or equal to getExpNeeded({mining::level::%player's uuid%}):
# (code here)
And now if we put it all together, our final code should look something like the spoiler. (It's a spoiler in case you want to try and do it yourself.)
Code:
# I added comments to everything :)
# Function to calculate experience needed for next level using exponential growth
function getExpNeeded(x: number = 0) :: number:
# Formula: 100 * 1.05^level
# This creates an exponential curve where each level requires more exp than the last
# Example: Level 1 needs 105 exp, Level 2 needs 110.25 exp, etc.
# (this is a tiny increment, but it's what you asked, so you can change this on your own time, lmao)
set {_y} to (100 * 1.05^{_x})
return {_y}
# Triggers when any block is broken
on block break:
# Check if the breaker is a player (not a piston, explosion, etc.)
if player is a player:
# 15% chance to trigger exp gain
chance of 15%:
# Visual effects
play resurrection by totem on the player # Creates totem animation
# Play sound for nearby players within 20 blocks
loop players in radius 20 around player:
play sound "ENTITY_EXPERIENCE_ORB_PICKUP" with volume 100 with pitch 1 at loop-player for loop-player
# Add mining experience
add 1 to {mining::exp::%player's uuid%}
# Level up system
# Check if the player's mining experience points are greater than or equal to
# the required experience points needed for the next level. This comparison is
# done using the player's UUID to ensure unique data storage per player.
if {mining::exp::%player's uuid%} is greater than or equal to getExpNeeded({mining::level::%player's uuid%}):
set {mining::exp::%player's uuid%} to 0 # Reset exp for next level
add 1 to {mining::level::%player's uuid%} # Increase level
wait 1 tick # Small delay for better message timing
# Show level up message as subtitle
send title "" with subtitle "&aNew mining level: &c&l%{mining::level::%player's uuid%}%" to player for 3 seconds
You're welcome! (and also tell me if the code doesn't work)
Thanks for letting me know and you did extremely well with this comment.
The only thing i did was fix the errors in the skript that showed up according to the XP sound and the totem so the totem and the xp sound would work.
Btw a comment not something that i am 100% sure about. i only think you can use "::" in a variable at the ending.
That you should use "." on everything before the ending "::"
Thanks for letting me know and you did extremely well with this comment.
The only thing i did was fix the errors in the skript that showed up according to the XP sound and the totem so the totem and the xp sound would work.
Btw a comment not something that i am 100% sure about. i only think you can use "::" in a variable at the ending.
That you should use "." on everything before the ending "::"
I don't think you answered the person's request...
But I'll do it!
HOWEVER... first, we're gonna fix up this code. We're gonna use Ted as our example player.
FIRST (and only) PROBLEM:
The varables {mining::%player%.exp} and {mining::%player%.level} aren't really good, because using the type player only returns the player's name (unless you changed it in configs).
For example, if Ted changed their minecraft name, two things would happen:
1. all of Ted's mining levels and exp is gone. Just like that.
2. Any player that uses Ted's old minecraft name would get Ted's levels and exp.
Now, because I hate using periods in variables, I'm gonna completely rewrite the variables.
SOLUTION:
To fix this, we need to use the type player's uuid. "UUID" stands for "Unique ID", so we're just getting the player's unique ID that is tied to their minecraft account.
Now as for rewriting the variables...
See, because I'm adding corrections based off of MrGametop's code, he fixed the rest of the errors, so... Less work for me!
NOW ONTO THE REQUEST!
Based off of what you are telling me, you just want the exp needed for the player to level up get exponentially larger (by 0.05, or 5%). This is actually graphable. (The equation is [y= 100 * 1.05^x] if you're curious.)
Because it is graphable, we're just gonna use a function to get the max exp needed based off of the level that the player is already at.
The function will look something like this:
Code:
# this function is prolly extra lines of code that I could simplify but I WON'T because it makes it easier to understand the code.
function getExpNeeded(x: number = 0) :: number:
# Returns the experience needed to reach the next level based on the level the player is currently at.
set {_y} to (100 * 1.05^{_x}) # This is graphable; you can graph it if you want what each value of x will return. (it's exponential
return {_y}
And now, all we need to do is replace the 100 in if {mining::%player%.exp} is greater than or equal to 100: with our function.
The line would look like this:
Code:
# using our function to get the exp needed based on the level the player is at
if {mining::exp::%player's uuid%} is greater than or equal to getExpNeeded({mining::level::%player's uuid%}):
# (code here)
And now if we put it all together, our final code should look something like the spoiler. (It's a spoiler in case you want to try and do it yourself.)
Code:
# I added comments to everything :)
# Function to calculate experience needed for next level using exponential growth
function getExpNeeded(x: number = 0) :: number:
# Formula: 100 * 1.05^level
# This creates an exponential curve where each level requires more exp than the last
# Example: Level 1 needs 105 exp, Level 2 needs 110.25 exp, etc.
# (this is a tiny increment, but it's what you asked, so you can change this on your own time, lmao)
set {_y} to (100 * 1.05^{_x})
return {_y}
# Triggers when any block is broken
on block break:
# Check if the breaker is a player (not a piston, explosion, etc.)
if player is a player:
# 15% chance to trigger exp gain
chance of 15%:
# Visual effects
play resurrection by totem on the player # Creates totem animation
# Play sound for nearby players within 20 blocks
loop players in radius 20 around player:
play sound "ENTITY_EXPERIENCE_ORB_PICKUP" with volume 100 with pitch 1 at loop-player for loop-player
# Add mining experience
add 1 to {mining::exp::%player's uuid%}
# Level up system
# Check if the player's mining experience points are greater than or equal to
# the required experience points needed for the next level. This comparison is
# done using the player's UUID to ensure unique data storage per player.
if {mining::exp::%player's uuid%} is greater than or equal to getExpNeeded({mining::level::%player's uuid%}):
set {mining::exp::%player's uuid%} to 0 # Reset exp for next level
add 1 to {mining::level::%player's uuid%} # Increase level
wait 1 tick # Small delay for better message timing
# Show level up message as subtitle
send title "" with subtitle "&aNew mining level: &c&l%{mining::level::%player's uuid%}%" to player for 3 seconds
You're welcome! (and also tell me if the code doesn't work)
SO EHM i lost the hole skript so i had to make it again and some things changed and i got the exenetial funcion working myself eventho thankyou for helping. this will also help other people out in this community
SO EHM i lost the hole skript so i had to make it again and some things changed and i got the exenetial funcion working myself eventho thankyou for helping. this will also help other people out in this community
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.