Solved inventory loop

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

privatemethod

New Member
Jul 19, 2019
9
0
0
24
Hi,

I want to make a /staff command that loops all items from my inventory and removes it and adds some tools to my inventory. And after you /staff again (disable staff-mode) you should get all your loop-items back but idk how

My Code:

Code:
command /staff:
    permission: staff
    permission message: &4&lError, &chier heb jij geen permissies voor!
    trigger:
        if {staff.%player%} is not set:
            send "&f%player% &7heeft staff-mode &a&oAANGEZET" to player
            set player's gamemode to creative
            set player's flight state to true
            set {staff.%player%} to true
            hide player from all players
            loop all items in the player's inventory: <--- loop
                remove loop-item from the player <--- loop
        else:
            delete {staff.%player%}
            send "&f%player% &7heeft staff-mode &c&oUITGEZET" to player
            stop
 
I have not tried the code, but try:

code_language.skript:
on command "/staff":
    cancel event
    sender is a player
    player has permission "staff.use":
        if {staff::%player%} isn't set:
            set {staff::%player%} to true
            send "&c[Staff-Mode]&7 State: &a&lON" to player
            hide player from all players
            loop numbers between 0 and 35:
                add 1 to {staff.count} 
                set {staffInventory:%player%::%{staff.count}%} to slot loop-value of player
                set slot loop-value of player to air
            set {staffArmor.helmet::%player%} to player's helmet
            set {staffArmor.chesplate::%player%} to player's chestplate
            set {staffArmor.leggings::%player%} to player's leggings
            set {staffArmor.boots::%player%} to player's boots
            set player's helmet to air
            set player's chestplate to air
            set player's leggings to air
            set player's boots to air
        else:
            delete {staff::%player%}
            send "&c[Staff-Mode]&7 State: &c&lOFF" to player
            reveal player from all players
            set {_staff.slot.count} to 0
            loop {staffInventory:%player%::*}:
                set slot {_staff.slot.count} of player's inventory to loop-value
                add 1 to {_staff.slot.count}
            set player's helmet to {staffArmor.helmet::%player%}
            set player's chestplate to {staffArmor.chestplate::%player%}
            set player's leggings to {staffArmor.leggings::%player%}
            set player's boots to {staffArmor.boots::%player%} 
    sender is not a player:
        send "&cYou can't execute this command by console." to console
    player does not have permission "staff.use":
        send "&cNo permission." to player
 
I have not tried the code, but try:

code_language.skript:
on command "/staff":
    cancel event
    sender is a player
    player has permission "staff.use":
        if {staff::%player%} isn't set:
            set {staff::%player%} to true
            send "&c[Staff-Mode]&7 State: &a&lON" to player
            hide player from all players
            loop numbers between 0 and 35:
                add 1 to {staff.count}
                set {staffInventory:%player%::%{staff.count}%} to slot loop-value of player
                set slot loop-value of player to air
            set {staffArmor.helmet::%player%} to player's helmet
            set {staffArmor.chesplate::%player%} to player's chestplate
            set {staffArmor.leggings::%player%} to player's leggings
            set {staffArmor.boots::%player%} to player's boots
            set player's helmet to air
            set player's chestplate to air
            set player's leggings to air
            set player's boots to air
        else:
            delete {staff::%player%}
            send "&c[Staff-Mode]&7 State: &c&lOFF" to player
            reveal player from all players
            set {_staff.slot.count} to 0
            loop {staffInventory:%player%::*}:
                set slot {_staff.slot.count} of player's inventory to loop-value
                add 1 to {_staff.slot.count}
            set player's helmet to {staffArmor.helmet::%player%}
            set player's chestplate to {staffArmor.chestplate::%player%}
            set player's leggings to {staffArmor.leggings::%player%}
            set player's boots to {staffArmor.boots::%player%}
    sender is not a player:
        send "&cYou can't execute this command by console." to console
    player does not have permission "staff.use":
        send "&cNo permission." to player
I already figured the code out myself, but still Thanks!
 
Status
Not open for further replies.