Hello, I am a relatively new skripter and would like to optimize my selling script for a mining simulator.
The current code is fine but the game lags due to the script looping 2304 times. I've tried to detect all at once but failed. Is there a way to achieve this? The on ly addon to skript I have is SkBee. Let me know if this is only possible with a certain addon, I will gladly add it and fix it. Thanks!
Code:
command /sell:
trigger:
loop 2304 times:
loop all items in the player's inventory:
if loop-item is coal:
remove 1 coal from player's inventory
add 250 to {amountgive::%player%}
add 250 to {balance::%player%}
if loop-item is cobblestone:
remove 1 cobblestone from player's inventory
add 10 to {amountgive::%player%}
add 10 to {balance::%player%}
if loop-item is raw gold:
remove 1 raw gold from player's inventory
add 1000 to {amountgive::%player%}
add 1000 to {balance::%player%}
if loop-item is diamond:
remove 1 diamond from player's inventory
add 2000 to {amountgive::%player%}
add 2000 to {balance::%player%}
message "&7[&6PeanutSim&7]&6 Sold items for $%{amountgive::%player%}%" to player
subtract {amountgive::%player%} from {amountgive::%player%}
The current code is fine but the game lags due to the script looping 2304 times. I've tried to detect all at once but failed. Is there a way to achieve this? The on ly addon to skript I have is SkBee. Let me know if this is only possible with a certain addon, I will gladly add it and fix it. Thanks!