1. Welcome to skUnity!

    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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

{bans::*} loses it's values when server stops or crashes

Discussion in 'Skript' started by KroterPvP, Jun 28, 2017.

Thread Status:
Not open for further replies.
  1. KroterPvP

    KroterPvP Active Member

    Joined:
    Apr 10, 2017
    Messages:
    178
    Likes Received:
    7
    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 :emoji_frowning:

    It's only a part of code. When a player bans another player, it adds the player to {bans::*}.
    Code (Skript):
    1. command /bans [<integer=1>]:
    2.     trigger:
    3.         sender is console:
    4.             send "&8[&cBANS&8] &7This command is only available for players"
    5.         else:
    6.             set {sizeofbans::*} to size of {bans::*}
    7.             set {_page::max} to arg 1 * 45
    8.             set {_page::min} to (arg 1 - 1) * 45
    9.             set {_page::posts} to 0
    10.             set {_page::count} to 0
    11.             set {_page::number} to arg 1
    12.             set {_pages} to size of {bans::*} / 45
    13.             set {_pages} to "%{_pages}%"
    14.             set {_pages::*} to {_pages} split at "."
    15.             set {_page::total} to {_pages::1}
    16.             if {_pages::2} is set:
    17.                 set {_page::total} to {_page::total} parsed as an integer
    18.                 add 1 to {_page::total}
    19.             if inventory name of player's current inventory does not contain "&0List of banned players":
    20.                 open chest with 6 rows named "&0List of banned players %{_page::number}%/%{_page::total}%" to player
    21.             else:
    22.                 loop 54 times:
    23.                     set slot (loop-number - 1) of player's current inventory to air
    24.                 set inventory name of player's current inventory to "&0List of banned players %{_page::number}%/%{_page::total}%"
    25.             if {_page::number} is less than 2:
    26.                 set slot 45 of player's current inventory to black stained glass pane named "&7"
    27.                 set slot 46 of player's current inventory to black stained glass pane named "&7"
    28.                 set slot 47 of player's current inventory to black stained glass pane named "&7"
    29.                 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}%"
    30.                 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."
    31.                 set slot 50 of player's current inventory to barrier named "&eClose GUI"
    32.                 set slot 51 of player's current inventory to black stained glass pane named "&7"
    33.                 set slot 52 of player's current inventory to black stained glass pane named "&7"
    34.                 set slot 53 of player's current inventory to black stained glass pane named "&7"
    35.             else:
    36.                 set slot 45 of player's current inventory to arrow named "&ePrevious Page"
    37.                 set slot 46 of player's current inventory to book named "&eMain Page"
    38.                 set slot 47 of player's current inventory to black stained glass pane named "&7"
    39.                 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}%"
    40.                 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."
    41.                 set slot 50 of player's current inventory to barrier named "&eClose GUI"
    42.                 set slot 51 of player's current inventory to black stained glass pane named "&7"
    43.                 set slot 52 of player's current inventory to black stained glass pane named "&7"
    44.                 set slot 53 of player's current inventory to black stained glass pane named "&7"
    45.             loop {bans::*}:
    46.                 if {_page::posts} is less than {_page::max}:
    47.                     if {_page::count} is greater than or equal to {_page::min}:
    48.                         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%}%||"
    49.                         add 1 to {_page::posts}
    50.                 add 1 to {_page::count}
    51.             if {_page::number} is less than {_page::total}:
    52.                 set slot 53 of player's current inventory to arrow named "&eNext Page"
    53.             if {_page::count} is 0:
    54.                 open chest with 1 row named "&0There are %{_page::count}% banned players" to player
    55.                 set slot 0 of player's current inventory to black stained glass pane named "&7"
    56.                 set slot 1 of player's current inventory to black stained glass pane named "&7"
    57.                 set slot 2 of player's current inventory to black stained glass pane named "&7"
    58.                 set slot 3 of player's current inventory to black stained glass pane named "&7"
    59.                 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!"
    60.                 set slot 5 of player's current inventory to black stained glass pane named "&7"
    61.                 set slot 6 of player's current inventory to black stained glass pane named "&7"
    62.                 set slot 7 of player's current inventory to black stained glass pane named "&7"
    63.                 set slot 8 of player's current inventory to black stained glass pane named "&7"
    64. on inventory click:
    65.     if inventory name of player's current inventory contains "&0There are":
    66.         cancel event
    67.     if inventory name of player's current inventory contains "&0List of banned players":
    68.         cancel event
    69.         set {_page} to "%inventory name of player's current inventory%"
    70.         replace all "&0List of banned players " in {_page} with ""
    71.         set {_pages::*} to {_page} split at "/"
    72.         if clicked slot is less than 45:
    73.             if clicked item is player head:
    74.                 if name of item contains "&7Player":
    75.                     set {_playername} to "%clicked item's name%"
    76.                     replace all "&7Player &8» &c" in {_playername} with ""
    77.                     execute player command "/unban %{_playername}%"
    78.                     execute player command "/bans %{_pages::1} parsed as an integer%"
    79.         if clicked slot is 45:
    80.             if clicked item's name is "&ePrevious Page":
    81.                 if {_pages::1} parsed as an integer is greater than 1:
    82.                     execute player command "/bans %{_pages::1} parsed as an integer - 1%"
    83.                 else:
    84.                     close player's inventory
    85.                     send "You are already on the first page."
    86.         if clicked slot is 46:
    87.             execute player command "/bans"
    88.         if clicked slot is 50:
    89.             close player's inventory
    90.         if clicked slot is 49:
    91.             if clicked item's name is "&eSearch players":
    92.                 close player's inventory
    93.                 set {bans.chat::%player%} to true
    94.                 send "&8[&c&lBANS&8] &7You must write the player's name in chat. Type &ccancel &7to annullate the search."
    95.         if clicked slot is 53:
    96.             if clicked item's name is "&eNext Page":
    97.                 execute player command "/bans %{_pages::1} parsed as an integer + 1%"
    98. on chat:
    99.     if {bans.chat::%player%} is true:
    100.         cancel event
    101.         set {_search} to "%message%" parsed as offline player
    102.         if {_search} is "cancel":
    103.             delete {bans.chat::%player%}
    104.             send "&8[&c&lBANS&8] &7You have succesfully annullated the search."
    105.         else:
    106.             if {sban.banned.%{_search}%} is not set:
    107.                 send "&8[&c&lBANS&8] &a%{_search}% &7is not banned."
    108.                 delete {bans.chat::%player%}
    109.             else:
    110.                 if {sban.banned.%{_search}%} is true:
    111.                     delete {bans.chat::%player%}
    112.                     send "&8[&c&lBANS&8] &a%{_search}% &7is banned."
    113.                     send "&9Obrir GUI per desbanejar a &a%{_search}%&9."
    114.                 else:
    115.                     delete {bans.chat::%player%}
    116.                     send "&8[&c&lBANS&8] &a%{_search}% &7is not banned."

    Thanks,
    @KroterPvP
     
    #1 KroterPvP, Jun 28, 2017
    Last edited: Jun 28, 2017
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Simple fix, if you put an underscore in front of the variable it's a local variable which gets deleted so just get rid of the underscore: {bans::*}
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Oh, that was a silly mistake!
    Thanks!

    EDIT: It still doesn't run. I've edited the thread description. Please, help me!
    --- Double Post Merged, Jun 28, 2017, Original Post Date: Jun 28, 2017 ---
    Anybody can help me?
     
Thread Status:
Not open for further replies.

Share This Page

Loading...