• 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Fridious

Member
Jun 23, 2017
33
0
0
47
Hey,
how can I set an item on the first free slot of a chest gui and how can i sort a gui for the alphabeticfor example a to z?

Thank you :emoji_slight_smile:
 
Last edited:
A way to achieve the first part could be to loop through the slots until you find an empty slot.

As for the second part, I don't believe Skript has a built in alphabetical sorting, so you'd have to code and implement your own algorithm.
 
for alphabet


code_language.skript:
loop alphabetical order of {_var::*}: # TuSKe  addon needed
    send "%loop-object%"


code_language.skript:
command /hats2: 
    trigger:
        open chest with 6 rows named "&bHats 2" to player
        wait 3 ticks
        format slot 0 of player with blue stained glass pane named "&9Sup" to be unstealable
        format slot 9 of player with blue stained glass pane named "&9Sup" to be unstealable
        format slot 18 of player with blue stained glass pane named "&9JrSup" to be unstealable
        format slot 27 of player with yellow stained glass pane named "&eH-Build" to be unstealable
        format slot 36 of player with yellow stained glass pane named "&eBuild" to be unstealable
        format slot 49 of player with emerald named "&fSeite 2/3" to be unstealable
        format slot 45 of player with slimeball named "&cZurück" to run [execute player command "/extras"]
        format slot 52 of player with arrow named "&7Vorherige Seite" to run [execute player command "/hats"]
        format slot 53 of player with arrow named "&7Nächste Seite" to run [execute player command "/hats3"]

How can I sort this alphabetic?
[doublepost=1498826166,1498825935][/doublepost]
A way to achieve the first part could be to loop through the slots until you find an empty slot.

As for the second part, I don't believe Skript has a built in alphabetical sorting, so you'd have to code and implement your own algorithm.


Can you give me an example pls? :emoji_slight_smile:
 
Can you give me an example pls? :emoji_slight_smile:

code_language.skript:
open chest with 6 rows named "Double Chest" to player
# looping all slots; assuming double chest ^
loop integers between 0 and 53:
    # is the item in this slot is air
    if "%slot loop-integer of player's current inventory%" is "air":
        # do stuff
        message "test" to player
 
code_language.skript:
open chest with 6 rows named "Double Chest" to player
# looping all slots; assuming double chest ^
loop integers between 0 and 53:
    # is the item in this slot is air
    if "%slot loop-integer of player's current inventory%" is "air":
        # do stuff
        message "test" to player



code_language.skript:
command /hatstest2:
    trigger:
        open chest with 6 rows named "Double Chest" to player
        # looping all slots; assuming double chest ^
        loop integers between 0 and 53:
            # is the item in this slot is air
            if "%slot loop-integer of player's current inventory%" is "air":
                if player has permission "lobby.head.fridioushd":
                    wait 3 ticks
                    format slot %slot loop-integer of player's current inventory% of player with arrow named "&7Nächste Seite" to run [execute player command "/hats"]

Can you say what is wrong, because if i execute this command there is a Error:
code_language.skript:
[15:17:04 INFO]: [Skript] Reloading lobby.sk...
[15:17:04 INFO]: Lobby wurde deaktiviert
[15:17:04 INFO]: Lobby wurde aktiviert
[15:17:06 ERROR]: '"/hats"]' is not a text (lobby.sk, line 315: format slot %slot loop-integer of player's current inventory% of player with arrow named "&7Nõchste Seite" to run [execute player command "/hats"]')
[15:17:06 INFO]: [Skript] Encountered 1 error while reloading lobby.sk!
And if I open the gui with the command there is no item in it.
 
code_language.skript:
command /hatstest2:
    trigger:
        open chest with 6 rows named "Double Chest" to player
        # looping all slots; assuming double chest ^
        loop integers between 0 and 53:
            # is the item in this slot is air
            if "%slot loop-integer of player's current inventory%" is "air":
                if player has permission "lobby.head.fridioushd":
                    wait 3 ticks
                    format slot %slot loop-integer of player's current inventory% of player with arrow named "&7Nächste Seite" to run [execute player command "/hats"]

Can you say what is wrong, because if i execute this command there is a Error:
code_language.skript:
[15:17:04 INFO]: [Skript] Reloading lobby.sk...
[15:17:04 INFO]: Lobby wurde deaktiviert
[15:17:04 INFO]: Lobby wurde aktiviert
[15:17:06 ERROR]: '"/hats"]' is not a text (lobby.sk, line 315: format slot %slot loop-integer of player's current inventory% of player with arrow named "&7Nõchste Seite" to run [execute player command "/hats"]')
[15:17:06 INFO]: [Skript] Encountered 1 error while reloading lobby.sk!
And if I open the gui with the command there is no item in it.

The code
code_language.skript:
%slot loop-integer of player's current inventory%
produces the name of the item of that slot. Replace that with just "loop-integer"
 
The code
code_language.skript:
%slot loop-integer of player's current inventory%
produces the name of the item of that slot. Replace that with just "loop-integer"

Can you send me the code with that because i don't understand it
I am from Germany and i am not the best in english sorry :emoji_frowning:
 
Can you send me the code with that because i don't understand it
I am from Germany and i am not the best in english sorry :emoji_frowning:

code_language.skript:
command /hatstest2:
    trigger:
        open chest with 6 rows named "Double Chest" to player
        # looping all slots; assuming double chest ^
        loop integers between 0 and 53:
            # is the item in this slot is air
            if "%slot loop-integer of player's current inventory%" is "air":
                if player has permission "lobby.head.fridioushd":
                    wait 3 ticks
                    format slot loop-integer of player with arrow named "&7Nächste Seite" to run [execute player command "/hats"]
 
code_language.skript:
command /hatstest2:
    trigger:
        open chest with 6 rows named "Double Chest" to player
        # looping all slots; assuming double chest ^
        loop integers between 0 and 53:
            # is the item in this slot is air
            if "%slot loop-integer of player's current inventory%" is "air":
                if player has permission "lobby.head.fridioushd":
                    wait 3 ticks
                    format slot loop-integer of player with arrow named "&7Nächste Seite" to run [execute player command "/hats"]


Thank you but this item is not in the inventory
 
Hmm; perhaps try replacing the formate line with this:
code_language.skript:
set slot loop-integer of player's current inventory to arrow named "&7Nächste Seite" to run [execute player command "/hats"]


No this didn't work error:
code_language.skript:
[Skript] Reloading lobby.sk...
[15:49:18 INFO]: Lobby wurde deaktiviert
[15:49:18 INFO]: Lobby wurde aktiviert
[15:49:20 ERROR]: 'player with arrow named "&7Nõchste Seite"' is not an entity type (lobby.sk, line 314: set slot loop-integer of player with arrow named "&7Nõchste Seite" to run [execute player command "/hats"]')
[15:49:20 INFO]: [Skript] Encountered 1 error while reloading lobby.sk!
 
You need to replace "with arrow" to "to arrow".

And in german
Mache aus dem "with arrow" ein "to arrow" dann sollte es gehen.

code_language.skript:
command /hatstest2:
    trigger:
        open chest with 6 rows named "Double Chest" to player
        # looping all slots; assuming double chest ^
        loop integers between 0 and 53:
            # is the item in this slot is air
            if "%slot loop-integer of player's current inventory%" is "air":
                wait 10 ticks
                set slot loop-integer of player to arrow named "&7Nächste Seite" to run [execute player command "/hats"]
Funktioniert trotzdem nicht kannst du mir helfen?

Error:
code_language.skript:
[16:02:54 INFO]: [Skript] Reloading lobby.sk...
[16:02:54 INFO]: Lobby wurde deaktiviert
[16:02:54 INFO]: Lobby wurde aktiviert
[16:02:56 ERROR]: '[execute player command "/hats"]' is not a text (lobby.sk, line 314: set slot loop-integer of player to arrow named "&7Nõchste Seite" to run [execute player command "/hats"]')
[16:02:56 INFO]: [Skript] Encountered 1 error while reloading lobby.sk!
 
Natürlich habs gerade gesehen

Ändere die "set slot" Zeile zu dieser

code_language.skript:
format slot loop-integer of player's current inventory to arrow named "&7Nächste Seite" to run [execute player command "/hats"]

Denn so etwas wie "run" gehört/funktioniert hinter
set slot nicht.
 
Trotzdem Er
Natürlich habs gerade gesehen

Ändere die "set slot" Zeile zu dieser

code_language.skript:
format slot loop-integer of player's current inventory to arrow named "&7Nächste Seite" to run [execute player command "/hats"]

Denn so etwas wie "run" gehört/funktioniert hinter
set slot nicht.


Trotzdem Error:
code_language.skript:
[16:11:26 INFO]: [Skript] Reloading lobby.sk...
[16:11:26 INFO]: Lobby wurde deaktiviert
[16:11:26 INFO]: Lobby wurde aktiviert
[16:11:29 ERROR]: '"/hats"]' is not a text (lobby.sk, line 314: format slot loop-integer of player's current inventory to arrow named "&7Nõchste Seite" to run [execute player command "/hats"]')
[16:11:29 INFO]: [Skript] Encountered 1 error while reloading lobby.sk!

Code:
code_language.skript:
command /hatstest2:
    trigger:
        open chest with 6 rows named "Double Chest" to player
        # looping all slots; assuming double chest ^
        loop integers between 0 and 53:
            # is the item in this slot is air
            if "%slot loop-integer of player's current inventory%" is "air":
                wait 10 ticks
                format slot loop-integer of player's current inventory to arrow named "&7Nächste Seite" to run [execute player command "/hats"]
 
Ich schaue mal kurz
Nutze kein format slot somit werde ich mal schauen

code_language.skript:
format slot loop-integer of player's current inventory with arrow named "&7Nächste Seite" to run [make player execute command "/hats"]
 
Last edited by a moderator:
Geht auch nicht :
Error:
code_language.skript:
[16:22:14 INFO]: [Skript] Reloading lobby.sk...
[16:22:14 INFO]: Lobby wurde deaktiviert
[16:22:14 INFO]: Lobby wurde aktiviert
[16:22:16 ERROR]: '"&7Nõchste Seite" to run [make player execute [SIZE=16px]command "/hats"]' is not a text (lobby.sk, line 314: format slot loop-integer of player's current inventory with arrow named "&7Nõchste Seite" to run [make player execute [SIZE=16px]command "/hats"]')
[16:22:16 INFO]: [Skript] Encountered 1 error while reloading lobby.sk!
 
Status
Not open for further replies.