• Es freut uns dass du in unser Minecraft Forum gefunden hast. Hier kannst du mit über 130.000 Minecraft Fans über Minecraft diskutieren, Fragen stellen und anderen helfen. In diesem Minecraft Forum kannst du auch nach Teammitgliedern, Administratoren, Moderatoren , Supporter oder Sponsoren suchen. Gerne kannst du im Offtopic Bereich unseres Minecraft Forums auch über nicht Minecraft spezifische Themen reden. Wir hoffen dir gefällt es in unserem Minecraft Forum!

brauche hilfe bei Skript

O

OlliPausW

Guest
Hallo, ich habe vor ein Plugin zu schreiben, mit dem man sein Inventar wechseln kann.
Doch leider gibt es da ein Problem:Skript kann zwar alles speichern was ich im Inventar habe, doch es weiß nicht was es tun soll wenn mein Inventar Leer ist und ich es speichern willl. Wenn mein Inventar leer ist und ich versuche es zu speichern überschreibt es die Variable nicht sondern lässt sie einfach so. Hier mit Skript code.


Code:
command /change [<text>]:
    permission: skript.invchange
    usage:&c/change <1-2> oder /change
    trigger:
        if {inv.%player%} is not set:
            set {inv.%player%} to "1"
            wait 0.2 seconds
        if {inv.%player%} is "1":
            if argument is "1":
                message "&cFehler: Du hast bereits Inventar 1!"
                stop
            if argument is "2":
                if player's inventory is not empty:
                    set {inventory1.%player%::*} to items in the player's inventory
                if player's inventory is empty:
                    set {inventory1.%player%::*} to air
                set {chestplate1.%player%} to chestplate of the player
                set {helm1.%player%} to helm of the player
                set {leg1.%player%} to leg of the player
                set {boot1.%player%} to boot of the player
                wait 0.2 seconds
                clear the inventory of the player
                give {inventory2.%player%::*} to the player
                set chestplate of the player to {chestplate2.%player%}
                set helm of the player to {helm2.%player%}
                set leg of the player to {leg2.%player%}
                set boot of the player to {boot2.%player%}
                set {inv.%player%} to "2"
                message "&6Du hast nun Inventar &32&6."
                stop
        if {inv.%player%} is "2":
            if argument is "1":
                if player's inventory is empty:
                    set {inventory2.%player%::*} to air
                    message "test"
                else:
                    set {inventory2.%player%::*} to items in the player's inventory
                    message "works"
                wait a second
                set {chestplate2.%player%} to chestplate of the player
                set {helm2.%player%} to helm of the player
                set {leg2.%player%} to leg of the player
                set {boot2.%player%} to boot of the player
                wait 0.2 seconds
                clear the inventory of the player
                give {inventory1.%player%::*} to the player
                set chestplate of the player to {chestplate1.%player%}
                set helm of the player to {helm1.%player%}
                set leg of the player to {leg1.%player%}
                set boot of the player to {boot1.%player%}
                set {inv.%player%} to "1"
                message "&6Du hast nun Inventar &31&6."
                stop
            if argument is "2":
                message "&cFehler: Du hast bereits Inventar 2!"
                stop
        if argument is not set:
            message "&6Du hast momentan Inventar &3%{inv.%player%}%"
 
V

Vazug

Guest
Code:
command /change [<text>]:
    permission: skript.invchange
    usage:&c/change <1-2> oder /change
    trigger:
        if {inv.%player%} is not set:
            set {inv.%player%} to "1"
            wait 0.2 seconds
        if {inv.%player%} is "1":
            if argument is "1":
                message "&cFehler: Du hast bereits Inventar 1!"
                stop
            if argument is "2":
                set {inventory1.%player%::*} to items in the player's inventory
                set {chestplate1.%player%} to chestplate of the player
                set {helm1.%player%} to helm of the player
                set {leg1.%player%} to leg of the player
                set {boot1.%player%} to boot of the player
                wait 0.2 seconds
                clear the inventory of the player
                give {inventory2.%player%::*} to the player
                set chestplate of the player to {chestplate2.%player%}
                set helm of the player to {helm2.%player%}
                set leg of the player to {leg2.%player%}
                set boot of the player to {boot2.%player%}
                set {inv.%player%} to "2"
                message "&6Du hast nun Inventar &32&6."
                stop
        if {inv.%player%} is "2":
            if argument is "1":
                set {inventory2.%player%::*} to items in the player's inventory
                set {chestplate2.%player%} to chestplate of the player
                set {helm2.%player%} to helm of the player
                set {leg2.%player%} to leg of the player
                set {boot2.%player%} to boot of the player
                wait 0.2 seconds
                clear the inventory of the player
                give {inventory1.%player%::*} to the player
                set chestplate of the player to {chestplate1.%player%}
                set helm of the player to {helm1.%player%}
                set leg of the player to {leg1.%player%}
                set boot of the player to {boot1.%player%}
                set {inv.%player%} to "1"
                message "&6Du hast nun Inventar &31&6."
                stop
            if argument is "2":
                message "&cFehler: Du hast bereits Inventar 2!"
                stop
        if argument is not set:
            message "&6Du hast momentan Inventar &3%{inv.%player%}%"

Einfach die Abfrage löschen, die prüft, ob das Inventar leer ist oder nicht.

Edit: Dein Code funktioniert nicht richtig, somit kann meiner auch nicht funktionieren, da ich deinen nur minimal bearbeitet habe.
 
Zuletzt bearbeitet von einem Moderator:
O

OlliPausW

Guest
Danke für die hilfe, aber es ist immernoch das selbe problem:
wenn ich inventar 2 bin, alles aus meinem inventar lösche, zu inventar 1 und wieder zurück wechsle habe ich wieder das zeug in meinem inventar das ich hatte befor ich alles weggeworfen habe.
was ich meine ist: skript überschreibt die variable nicht wenn ich ein leeres inventar habe.
 
O

OlliPausW

Guest
habe das Problem selbst behoben. "if player's inventory is empty:" hällt leere slots (luft) auch für items und sagt dann das inventar ist nicht leer
ich habe stattdessen jetzt etwas anderes benutzt. Ich habe jetzt gecheckt ob der Spieler 36 luft slots (36 freie slots) in seinem inventar hat:
set {test.text} to number of nothing in the player's inventory
if {test.text} is 36:

hier ist mein jetziger Skript code =)

Code:
command /change [<text>]:
    permission: skript.invchange
    usage:&c/change <1-2> oder /change
    trigger:
        if {inv.%player%} is not set:
            set {inv.%player%} to "1"
            wait 0.2 seconds
        if {inv.%player%} is "1":
            if argument is "1":
                message "&cFehler: Du hast bereits Inventar 1!"
                stop
            if argument is "2":
                set {test.%player%} to number of nothing in the player's inventory
                wait 0.2 seconds
                if {test.%player%} is not 36:
                    set {inventory1.%player%::*} to items in the player's inventory
                if {test.%player%} is 36:
                    set {inventory1.%player%::*} to air
                set {chestplate1.%player%} to chestplate of the player
                set {helm1.%player%} to helm of the player
                set {leg1.%player%} to leg of the player
                set {boot1.%player%} to boot of the player
                wait 0.2 seconds
                clear the inventory of the player
                give {inventory2.%player%::*} to the player
                set chestplate of the player to {chestplate2.%player%}
                set helm of the player to {helm2.%player%}
                set leg of the player to {leg2.%player%}
                set boot of the player to {boot2.%player%}
                set {inv.%player%} to "2"
                message "&6Du hast nun Inventar &32&6."
                stop
        if {inv.%player%} is "2":
            if argument is "1":
                set {test.%player%} to number of nothing in the player's inventory
                if {test.%player%} is not 36:
                    set {inventory2.%player%::*} to items in the player's inventory
                if {test.%player%} is 36:
                    set {inventory2.%player%::*} to air
                set {chestplate2.%player%} to chestplate of the player
                set {helm2.%player%} to helm of the player
                set {leg2.%player%} to leg of the player
                set {boot2.%player%} to boot of the player
                wait 0.2 seconds
                clear the inventory of the player
                give {inventory1.%player%::*} to the player
                set chestplate of the player to {chestplate1.%player%}
                set helm of the player to {helm1.%player%}
                set leg of the player to {leg1.%player%}
                set boot of the player to {boot1.%player%}
                set {inv.%player%} to "1"
                message "&6Du hast nun Inventar &31&6."
                stop
            if argument is "2":
                message "&cFehler: Du hast bereits Inventar 2!"
                stop
        if argument is not set:
            message "&6Du hast momentan Inventar &3%{inv.%player%}%"
 
Oben