[SK/Soru] Envanteri Looplama

Thraenkost

Lapis Toplayıcısı
Mesajlar
936
En iyi cevaplar
1
Beğeniler
400
Puanları
1,080
Ruh hali
Beyler şimdi biz envanterindeki eşyaları ve giydiği zırhları nasıl bir list variableye kaydedebiliriz ?
 


ensiha

Bratackk <3
Mesajlar
541
En iyi cevaplar
0
Beğeniler
250
Puanları
750
SsFightsS Sendemi Araştırmayı Bıraktın :D [Kötü Anlamda Anlama Sadece Espriydi]

Storing the inventory (prt.1)
From here on out it becomes a bit more complicated. You will need a different variable for each slot of the inventory, even if they are empty, so you can preserve the placement of items in the inventory. In these examples I will be using public variables so you can access the variables from anywhere in your skript if you wish.
PHP:
command /inv:
    trigger:
        set {_count} to 0
        loop 36 times:
            set {inv.%player%.%{_count}%.main} to slot {_count} of player's inventory
            message "{inv.%player%.%{_count}%.main} is %{inv.%player%.%{_count}%.main}%"
            add 1 to {_count}

Storing the inventory (prt.2)
Now that you have the main inventory slots set, you will now need to get the armor slots. This part is pretty straightforward, all you have to do is create four variables that store the player's armor. I just replaced the {_count} with the type of armor.
PHP:
command /inv:
    trigger:
        set {_count} to 0
        loop 36 times:
            set {inv.%player%.%{_count}%.main} to slot {_count} of player's inventory
            message "{inv.%player%.%{_count}%.main} is %{inv.%player%.%{_count}%.main}%"
            add 1 to {_count}
        set {inv.%player%.helmet.main} to player's helmet
        set {inv.%player%.chest.main} to player's chestplate
        set {inv.%player%.legs.main} to player's leggings
        set {inv.%player%.feet.main} to player's boots

Clearing and Restoring (prt.1)
Before we can restore an inventory, the inventory needs to have been changed, or we won't know if it worked! This can be solved by clearing the player's inventory then waiting 3 seconds to restore it.

PHP:
command /inv:
    trigger:
        set {_count} to 0
        loop 36 times:
            set {inv.%player%.%{_count}%.main} to slot {_count} of player's inventory
            message "{inv.%player%.%{_count}%.main} is %{inv.%player%.%{_count}%.main}%"
            add 1 to {_count}
        set {inv.%player%.helmet.main} to player's helmet
        set {inv.%player%.chest.main} to player's chestplate
        set {inv.%player%.legs.main} to player's leggings
        set {inv.%player%.feet.main} to player's boots
        clear player's inventory
        wait 3 seconds

Clearing and Restoring (prt.2)
Now we are just going to do the reverse of what we did earlier, instead of setting a variable to a slot, we will set a slot to a variable.
PHP:
command /inv:
    trigger:
        set {_count} to 0
        loop 36 times:
            set {inv.%player%.%{_count}%.main} to slot {_count} of player's inventory
            message "{inv.%player%.%{_count}%.main} is %{inv.%player%.%{_count}%.main}%"
            add 1 to {_count}
        set {inv.%player%.helmet.main} to player's helmet
        set {inv.%player%.chest.main} to player's chestplate
        set {inv.%player%.legs.main} to player's leggings
        set {inv.%player%.feet.main} to player's boots
        clear player's inventory
        wait 3 seconds
        set {_count} to 0    #Setting count back to 0 so we can re-use it for the next counter
        loop 36 times:
            set slot {_count} of player's inventory to {inv.%player%.%{_count}%.main}
            add 1 to {_count}

Not : Alıntıdır

Linkide Atayım Belki Yardımcı Olur
:
https://dev.bukkit.org/bukkit-plugi...s/71969-how-to-save-an-inventory-of-a-player/
 
Son düzenleme:

Thraenkost

Lapis Toplayıcısı
Mesajlar
936
En iyi cevaplar
1
Beğeniler
400
Puanları
1,080
Ruh hali
SsFightsS Sendemi Araştırmayı Bıraktın :D [Kötü Anlamda Anlama Sadece Espriydi]

Storing the inventory (prt.1)
From here on out it becomes a bit more complicated. You will need a different variable for each slot of the inventory, even if they are empty, so you can preserve the placement of items in the inventory. In these examples I will be using public variables so you can access the variables from anywhere in your skript if you wish.
PHP:
command /inv:
    trigger:
        set {_count} to 0
        loop 36 times:
            set {inv.%player%.%{_count}%.main} to slot {_count} of player's inventory
            message "{inv.%player%.%{_count}%.main} is %{inv.%player%.%{_count}%.main}%"
            add 1 to {_count}

Storing the inventory (prt.2)
Now that you have the main inventory slots set, you will now need to get the armor slots. This part is pretty straightforward, all you have to do is create four variables that store the player's armor. I just replaced the {_count} with the type of armor.
PHP:
command /inv:[/B][/B][/B]
[B][B][B]    trigger:[/B][/B][/B]
[B][B][B]        set {_count} to 0[/B][/B][/B]
[B][B][B]        loop 36 times:[/B][/B][/B]
[B][B][B]            set {inv.%player%.%{_count}%.main} to slot {_count} of player's inventory[/B][/B][/B]
[B][B][B]            message "{inv.%player%.%{_count}%.main} is %{inv.%player%.%{_count}%.main}%"[/B][/B][/B]
[B][B][B]            add 1 to {_count}[/B][/B][/B]
[B][B][B]        set {inv.%player%.helmet.main} to player's helmet[/B][/B][/B]
[B][B][B]        set {inv.%player%.chest.main} to player's chestplate[/B][/B][/B]
[B][B][B]        set {inv.%player%.legs.main} to player's leggings[/B][/B][/B]
[B][B][B]        set {inv.%player%.feet.main} to player's boots







Not : Alıntıdır

Linkide Atayım Belki Yardımcı Olur
:
https://dev.bukkit.org/bukkit-plugi...s/71969-how-to-save-an-inventory-of-a-player/
Tamam saolasın :D
 

Üst