This is what I have so far. It is taking the payment correctly, but for some reason it is not upgrading the rank of the player at all. The player's rank just stays constant.
command /upgradehomes:
description: Upgrade your home level for a high fee.
permission: skript.upgradehomes
permission message: &cYou do not have permission to use this command!
trigger:
# Define ranks
clear {_ranks::*}
add "default" to {_ranks::*}
add "level1" to {_ranks::*}
add "level2" to {_ranks::*}
add "level3" to {_ranks::*}
add "level4" to {_ranks::*}
add "level5" to {_ranks::*}
add "level6" to {_ranks::*}
add "level7" to {_ranks::*}
add "level8" to {_ranks::*}
add "level9" to {_ranks::*}
# Define costs
clear {_costs::*}
add 80000 to {_costs::*}
add 200000 to {_costs::*}
add 400000 to {_costs::*}
add 600000 to {_costs::*}
add 850000 to {_costs::*}
add 1100000 to {_costs::*}
add 1400000 to {_costs::*}
add 1800000 to {_costs::*}
add 2500000 to {_costs::*}
# Determine current rank
set {_currentRank} to "default" # Default to "default" if no rank is found
loop {_ranks::*}:
if player has permission "essentials.sethome.multiple.%loop-value%":
set {_currentRank} to "%loop-value%"
stop loop
# Debugging message for current rank
send "&7[DEBUG] Found current rank: %{_currentRank}%."
# Find the current rank's index in the rank list
set {_nextRankIndex} to -1 # Initialize to -1, so the first valid rank is 0
set {_index} to 0 # Start from index 0
loop {_ranks::*}:
if loop-value is {_currentRank}:
set {_nextRankIndex} to {_index}
stop loop
set {_index} to {_index} + 1 # Manually increment the index
# Debugging message for next rank index
send "&7[DEBUG] Next rank index: %{_index}%."
# Check if current rank is the last one
if {_nextRankIndex} >= size of {_ranks::*} - 1:
send "&aYou already have the maximum home rank (Level 9, 20 homes)!"
stop
# Get the next rank
set {_nextRankIndex} to {_nextRankIndex} + 1
set {_nextRank} to {_ranks::%{_nextRankIndex}%}
# Debugging message for next rank
send "&7[DEBUG] Next rank: %{_nextRank}%."
# Get cost for the next rank
set {_cost} to {_costs::%{_nextRankIndex}%}
# Check if the player has enough money
if player's balance is greater than or equal to {_cost}:
remove {_cost} from player's balance
execute console command "lp user %player% permission set essentials.sethome.multiple.%{_nextRank}% true"
execute console command "lp user %player% permission unset essentials.sethome.multiple.%{_currentRank}%"
execute console command "lp user %player% permission reload" # Reload permissions
# Get the new home limit
set {_nextHomes} to {_nextRankIndex + 2}
send "&aCongratulations! You've upgraded to home %{_nextRank}% for $%{_cost}%."
send "&eYou can now set up to %{_nextHomes}% homes!"
else:
send "&cYou do not have enough money to upgrade! You need $%{_cost}%. Please try again later."
I don't think that {_index} is being found correctly but I don't know how to fix it
command /upgradehomes:
description: Upgrade your home level for a high fee.
permission: skript.upgradehomes
permission message: &cYou do not have permission to use this command!
trigger:
# Define ranks
clear {_ranks::*}
add "default" to {_ranks::*}
add "level1" to {_ranks::*}
add "level2" to {_ranks::*}
add "level3" to {_ranks::*}
add "level4" to {_ranks::*}
add "level5" to {_ranks::*}
add "level6" to {_ranks::*}
add "level7" to {_ranks::*}
add "level8" to {_ranks::*}
add "level9" to {_ranks::*}
# Define costs
clear {_costs::*}
add 80000 to {_costs::*}
add 200000 to {_costs::*}
add 400000 to {_costs::*}
add 600000 to {_costs::*}
add 850000 to {_costs::*}
add 1100000 to {_costs::*}
add 1400000 to {_costs::*}
add 1800000 to {_costs::*}
add 2500000 to {_costs::*}
# Determine current rank
set {_currentRank} to "default" # Default to "default" if no rank is found
loop {_ranks::*}:
if player has permission "essentials.sethome.multiple.%loop-value%":
set {_currentRank} to "%loop-value%"
stop loop
# Debugging message for current rank
send "&7[DEBUG] Found current rank: %{_currentRank}%."
# Find the current rank's index in the rank list
set {_nextRankIndex} to -1 # Initialize to -1, so the first valid rank is 0
set {_index} to 0 # Start from index 0
loop {_ranks::*}:
if loop-value is {_currentRank}:
set {_nextRankIndex} to {_index}
stop loop
set {_index} to {_index} + 1 # Manually increment the index
# Debugging message for next rank index
send "&7[DEBUG] Next rank index: %{_index}%."
# Check if current rank is the last one
if {_nextRankIndex} >= size of {_ranks::*} - 1:
send "&aYou already have the maximum home rank (Level 9, 20 homes)!"
stop
# Get the next rank
set {_nextRankIndex} to {_nextRankIndex} + 1
set {_nextRank} to {_ranks::%{_nextRankIndex}%}
# Debugging message for next rank
send "&7[DEBUG] Next rank: %{_nextRank}%."
# Get cost for the next rank
set {_cost} to {_costs::%{_nextRankIndex}%}
# Check if the player has enough money
if player's balance is greater than or equal to {_cost}:
remove {_cost} from player's balance
execute console command "lp user %player% permission set essentials.sethome.multiple.%{_nextRank}% true"
execute console command "lp user %player% permission unset essentials.sethome.multiple.%{_currentRank}%"
execute console command "lp user %player% permission reload" # Reload permissions
# Get the new home limit
set {_nextHomes} to {_nextRankIndex + 2}
send "&aCongratulations! You've upgraded to home %{_nextRank}% for $%{_cost}%."
send "&eYou can now set up to %{_nextHomes}% homes!"
else:
send "&cYou do not have enough money to upgrade! You need $%{_cost}%. Please try again later."
I don't think that {_index} is being found correctly but I don't know how to fix it