Hello, I'm having an issue with loop values.
When a player is banned, is added to the variable {bans::*}. I've done a GUI where all the bans are displayed. If I stop the server, and start it again, or the server suffers a crash, the variable {bans::*} loses all the values. If it didn't contain any value, the variable is still empty when I start the server again, but if it contained a value or more than one, the values are erased and they apear like "null" and "<none>" in the GUI and in the chat if I send the variable to a player.
I have created another skript which adds "1, 2, 3 and 4" to "{hello::*}". I stop the server and start it again, and the variable is saved. Why is saved here and not in my other part of code? I checked it all, and I found nothing
It's only a part of code. When a player bans another player, it adds the player to {bans::*}.
Thanks,
@KroterPvP
When a player is banned, is added to the variable {bans::*}. I've done a GUI where all the bans are displayed. If I stop the server, and start it again, or the server suffers a crash, the variable {bans::*} loses all the values. If it didn't contain any value, the variable is still empty when I start the server again, but if it contained a value or more than one, the values are erased and they apear like "null" and "<none>" in the GUI and in the chat if I send the variable to a player.
I have created another skript which adds "1, 2, 3 and 4" to "{hello::*}". I stop the server and start it again, and the variable is saved. Why is saved here and not in my other part of code? I checked it all, and I found nothing
It's only a part of code. When a player bans another player, it adds the player to {bans::*}.
code_language.skript:
command /bans [<integer=1>]:
trigger:
sender is console:
send "&8[&cBANS&8] &7This command is only available for players"
else:
set {sizeofbans::*} to size of {bans::*}
set {_page::max} to arg 1 * 45
set {_page::min} to (arg 1 - 1) * 45
set {_page::posts} to 0
set {_page::count} to 0
set {_page::number} to arg 1
set {_pages} to size of {bans::*} / 45
set {_pages} to "%{_pages}%"
set {_pages::*} to {_pages} split at "."
set {_page::total} to {_pages::1}
if {_pages::2} is set:
set {_page::total} to {_page::total} parsed as an integer
add 1 to {_page::total}
if inventory name of player's current inventory does not contain "&0List of banned players":
open chest with 6 rows named "&0List of banned players %{_page::number}%/%{_page::total}%" to player
else:
loop 54 times:
set slot (loop-number - 1) of player's current inventory to air
set inventory name of player's current inventory to "&0List of banned players %{_page::number}%/%{_page::total}%"
if {_page::number} is less than 2:
set slot 45 of player's current inventory to black stained glass pane named "&7"
set slot 46 of player's current inventory to black stained glass pane named "&7"
set slot 47 of player's current inventory to black stained glass pane named "&7"
set slot 48 of player's current inventory to book and quill named "&eBasic information" with lore "||&7Banned users &8» &c%{sizeofbans::*}%||||&7You are viewing page &c%{_page::number}% &7out of &c%{_page::total}%"
set slot 49 of player's current inventory to anvil named "&eSearch players" with lore "||&7Click here to &csearch &7banned players.||&7You will need to type it's name in chat."
set slot 50 of player's current inventory to barrier named "&eClose GUI"
set slot 51 of player's current inventory to black stained glass pane named "&7"
set slot 52 of player's current inventory to black stained glass pane named "&7"
set slot 53 of player's current inventory to black stained glass pane named "&7"
else:
set slot 45 of player's current inventory to arrow named "&ePrevious Page"
set slot 46 of player's current inventory to book named "&eMain Page"
set slot 47 of player's current inventory to black stained glass pane named "&7"
set slot 48 of player's current inventory to book and quill named "&eBasic information" with lore "||&7Banned users &8» &c%{sizeofbans::*}%||||&7You are viewing page &c%{_page::number}% &7out of &c%{_page::total}%"
set slot 49 of player's current inventory to anvil named "&eSearch players" with lore "||&7Click here to &csearch &7banned players.||&7You will need to type it's name in chat."
set slot 50 of player's current inventory to barrier named "&eClose GUI"
set slot 51 of player's current inventory to black stained glass pane named "&7"
set slot 52 of player's current inventory to black stained glass pane named "&7"
set slot 53 of player's current inventory to black stained glass pane named "&7"
loop {bans::*}:
if {_page::posts} is less than {_page::max}:
if {_page::count} is greater than or equal to {_page::min}:
set slot {_page::posts} of player's current inventory to loop-value's skull named "&7Player &8» &c%loop-value%" with lore "||&7Ban ID &8» &7(&c##%loop-index%&7)||||&7Is Banned &8» &c%{sban.banned.%loop-value%}%||&7Banned by &8» &c%{sban.bannedby.%loop-value%}%||&7Banned on &8» &c%{sban.time.%loop-value%}%||"
add 1 to {_page::posts}
add 1 to {_page::count}
if {_page::number} is less than {_page::total}:
set slot 53 of player's current inventory to arrow named "&eNext Page"
if {_page::count} is 0:
open chest with 1 row named "&0There are %{_page::count}% banned players" to player
set slot 0 of player's current inventory to black stained glass pane named "&7"
set slot 1 of player's current inventory to black stained glass pane named "&7"
set slot 2 of player's current inventory to black stained glass pane named "&7"
set slot 3 of player's current inventory to black stained glass pane named "&7"
set slot 4 of player's current inventory to book named "&eThere aren't banned players" with lore "||&7Banned players will apear in this||&7gui. You will be able to manage||&7SuperBan's commands from here!"
set slot 5 of player's current inventory to black stained glass pane named "&7"
set slot 6 of player's current inventory to black stained glass pane named "&7"
set slot 7 of player's current inventory to black stained glass pane named "&7"
set slot 8 of player's current inventory to black stained glass pane named "&7"
on inventory click:
if inventory name of player's current inventory contains "&0There are":
cancel event
if inventory name of player's current inventory contains "&0List of banned players":
cancel event
set {_page} to "%inventory name of player's current inventory%"
replace all "&0List of banned players " in {_page} with ""
set {_pages::*} to {_page} split at "/"
if clicked slot is less than 45:
if clicked item is player head:
if name of item contains "&7Player":
set {_playername} to "%clicked item's name%"
replace all "&7Player &8» &c" in {_playername} with ""
execute player command "/unban %{_playername}%"
execute player command "/bans %{_pages::1} parsed as an integer%"
if clicked slot is 45:
if clicked item's name is "&ePrevious Page":
if {_pages::1} parsed as an integer is greater than 1:
execute player command "/bans %{_pages::1} parsed as an integer - 1%"
else:
close player's inventory
send "You are already on the first page."
if clicked slot is 46:
execute player command "/bans"
if clicked slot is 50:
close player's inventory
if clicked slot is 49:
if clicked item's name is "&eSearch players":
close player's inventory
set {bans.chat::%player%} to true
send "&8[&c&lBANS&8] &7You must write the player's name in chat. Type &ccancel &7to annullate the search."
if clicked slot is 53:
if clicked item's name is "&eNext Page":
execute player command "/bans %{_pages::1} parsed as an integer + 1%"
on chat:
if {bans.chat::%player%} is true:
cancel event
set {_search} to "%message%" parsed as offline player
if {_search} is "cancel":
delete {bans.chat::%player%}
send "&8[&c&lBANS&8] &7You have succesfully annullated the search."
else:
if {sban.banned.%{_search}%} is not set:
send "&8[&c&lBANS&8] &a%{_search}% &7is not banned."
delete {bans.chat::%player%}
else:
if {sban.banned.%{_search}%} is true:
delete {bans.chat::%player%}
send "&8[&c&lBANS&8] &a%{_search}% &7is banned."
send "&9Obrir GUI per desbanejar a &a%{_search}%&9."
else:
delete {bans.chat::%player%}
send "&8[&c&lBANS&8] &a%{_search}% &7is not banned."
Thanks,
@KroterPvP
Last edited: