Hello, im trying to make a contest that will show the top 10 biggest fish caught in the contest. I have this here and it works with no errors. But it will show the most recent caught fish size and not the biggest size. Im not sure how to fix the problem thats going on with it. If anyone knows how to fix it, please let me know ASAP.
Thanks!
~Matt
Code:
Thanks!
~Matt
Code:
Code:
command /mf [<text>] [<int>]:
trigger:
if player has permission "fishing.help":
if arg-1 is "help":
send "&aMore Fish commands."
send ""
send "&aUse /mf start <time> to start a contest"
send "&aUse /mf stop to stop all the contests"
if player has permission "fishing.stop":
if arg-1 is "stop":
set {contest::started} to 0
send "&8[&bFishing&8] &7You stopped the contest"
broadcast "&8[&bFishing&8] &7The fishing contest has been stopped!"
set {contest::started} to false
if player has permission "fishing.start":
if arg-1 is "start":
if arg-2 is set:
set {size::fish::*} to 0
send "&8[&bFishing&8] &7Starting a contest for %arg-2% seconds"
set {contest::counter} to arg-2
broadcast "&8[&bFishing&8] &7A fishing contest will be starting in 3..."
wait 1 seconds
broadcast "&8[&bFishing&8] &7A fishing contest will be starting in 2.."
wait 1 seconds
broadcast "&8[&bFishing&8] &7A fishing contest will be starting in 1."
wait 1 seconds
set {contest::started} to true
broadcast "&8[&bFishing&8] &7A fishing contest has started. Come to /spawn to participate"
wait "%{contest::counter}% seconds" parsed as time span
broadcast "&8[&bFishing&8] &7The contest has ended!"
set {contest::counter} to 0
set {contest::started} to false
make player execute command "/contestcaughtfishtop"
wait 1 seconds
set {contest::cought::*} to 0
set {size::fish::*} to 0
else:
send "&7You must have a time set also. Use /mf start <time>"
on fishing:
if player is in world "spawn":
if fish state is CAUGHT_FISH:
if {contest::started} is true:
clear caught item
add 1 to {contest::cought::%player%}
set {fish::ran} to random integer between 1 and 1
set {_var} to random number between 1 and 32.99
if {_var} > ({size::fish::%player%} ? 0):
set {size::fish::%player%} to {_var}
set {size::fish::%player%} to random number between 1 and 32.99
if {fish::ran} = 1:
set {cod::%player%} to 1
if {size::fish::%player%} is less than 30:
give player a cod named "&b%player%'s fish" with lore "&8* &aSize: %{size::fish::%player%}%cm" and "&b* &7Common"
send "&8[&bFishing&8] &7You cought a &7Common &asnapper"
if {size::fish1} is more than 29:
send "&8[&bFishing&8] &7You cought a &dRare &asnapper"
give player a cod named "&b%player%'s fish" with lore "&8* &aSize: %{size::fish::%player%}%" and "&b* &dRare"
broadcast "&8[&bFishing&8] &7%player% cought a &dRare &aSnapper thats %{size::fish::%player%}%cm!"
function pigeonhole(indices: objects, values: numbers, ascending: boolean = false) :: objects:
loop {_indices::*}:
set {_v} to "%(loop-index parsed as integer)th element out of {_values::*}%"
set {_split::*} to {_v} split at "."
add length of {_split::2} ? 0 to {_p::*}
add loop-value to {_temp::%{_v}%::*}
set {_prec} to 10^(max({_p::*})+1)
loop all integers from min({_values::*})*{_prec} to (max({_values::*})+1)*{_prec}:
set {_v} to loop-value / {_prec}
if {_temp::%{_v}%::*} is set:
loop {_temp::%{_v}%::*}:
add loop-value-2 to {_sorted::*}
return ({_sorted::*}) if {_ascending} is true, otherwise (reversed {_sorted::*})
command /contestcaughtfishtop:
trigger:
set {_indices::*} to indices of {size::fish::*}
set {_sorted-fish::*} to pigeonhole({_indices::*}, {size::fish::*})
set {_topfisher} to first element out of {_sorted-fish::*}
send "top fish man: %{_topfisher}% with %{size::fish::%{_topfisher}%}%cm"