Programm brauche hilfe bei Skript

Dieses Thema im Forum "Programmierung" wurde erstellt von OlliPausW, 3. Juli 2016.

  1. OlliPausW
    Offline

    OlliPausW

    Registriert seit:
    28. April 2014
    Beiträge:
    17
    Ort:
    da wo mein haus wohnt
    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 (Text):
    1. command /change [<text>]:
    2.     permission: skript.invchange
    3.     usage:&c/change <1-2> oder /change
    4.     trigger:
    5.         if {inv.%player%} is not set:
    6.             set {inv.%player%} to "1"
    7.             wait 0.2 seconds
    8.         if {inv.%player%} is "1":
    9.             if argument is "1":
    10.                 message "&cFehler: Du hast bereits Inventar 1!"
    11.                 stop
    12.             if argument is "2":
    13.                 if player's inventory is not empty:
    14.                     set {inventory1.%player%::*} to items in the player's inventory
    15.                 if player's inventory is empty:
    16.                     set {inventory1.%player%::*} to air
    17.                 set {chestplate1.%player%} to chestplate of the player
    18.                 set {helm1.%player%} to helm of the player
    19.                 set {leg1.%player%} to leg of the player
    20.                 set {boot1.%player%} to boot of the player
    21.                 wait 0.2 seconds
    22.                 clear the inventory of the player
    23.                 give {inventory2.%player%::*} to the player
    24.                 set chestplate of the player to {chestplate2.%player%}
    25.                 set helm of the player to {helm2.%player%}
    26.                 set leg of the player to {leg2.%player%}
    27.                 set boot of the player to {boot2.%player%}
    28.                 set {inv.%player%} to "2"
    29.                 message "&6Du hast nun Inventar &32&6."
    30.                 stop
    31.         if {inv.%player%} is "2":
    32.             if argument is "1":
    33.                 if player's inventory is empty:
    34.                     set {inventory2.%player%::*} to air
    35.                     message "test"
    36.                 else:
    37.                     set {inventory2.%player%::*} to items in the player's inventory
    38.                     message "works"
    39.                 wait a second
    40.                 set {chestplate2.%player%} to chestplate of the player
    41.                 set {helm2.%player%} to helm of the player
    42.                 set {leg2.%player%} to leg of the player
    43.                 set {boot2.%player%} to boot of the player
    44.                 wait 0.2 seconds
    45.                 clear the inventory of the player
    46.                 give {inventory1.%player%::*} to the player
    47.                 set chestplate of the player to {chestplate1.%player%}
    48.                 set helm of the player to {helm1.%player%}
    49.                 set leg of the player to {leg1.%player%}
    50.                 set boot of the player to {boot1.%player%}
    51.                 set {inv.%player%} to "1"
    52.                 message "&6Du hast nun Inventar &31&6."
    53.                 stop
    54.             if argument is "2":
    55.                 message "&cFehler: Du hast bereits Inventar 2!"
    56.                 stop
    57.         if argument is not set:
    58.             message "&6Du hast momentan Inventar &3%{inv.%player%}%"
     
    #1
  2. Vazug
    Offline

    Vazug

    Code (Text):
    1. command /change [<text>]:
    2.     permission: skript.invchange
    3.     usage:&c/change <1-2> oder /change
    4.     trigger:
    5.         if {inv.%player%} is not set:
    6.             set {inv.%player%} to "1"
    7.             wait 0.2 seconds
    8.         if {inv.%player%} is "1":
    9.             if argument is "1":
    10.                 message "&cFehler: Du hast bereits Inventar 1!"
    11.                 stop
    12.             if argument is "2":
    13.                 set {inventory1.%player%::*} to items in the player's inventory
    14.                 set {chestplate1.%player%} to chestplate of the player
    15.                 set {helm1.%player%} to helm of the player
    16.                 set {leg1.%player%} to leg of the player
    17.                 set {boot1.%player%} to boot of the player
    18.                 wait 0.2 seconds
    19.                 clear the inventory of the player
    20.                 give {inventory2.%player%::*} to the player
    21.                 set chestplate of the player to {chestplate2.%player%}
    22.                 set helm of the player to {helm2.%player%}
    23.                 set leg of the player to {leg2.%player%}
    24.                 set boot of the player to {boot2.%player%}
    25.                 set {inv.%player%} to "2"
    26.                 message "&6Du hast nun Inventar &32&6."
    27.                 stop
    28.         if {inv.%player%} is "2":
    29.             if argument is "1":
    30.                 set {inventory2.%player%::*} to items in the player's inventory
    31.                 set {chestplate2.%player%} to chestplate of the player
    32.                 set {helm2.%player%} to helm of the player
    33.                 set {leg2.%player%} to leg of the player
    34.                 set {boot2.%player%} to boot of the player
    35.                 wait 0.2 seconds
    36.                 clear the inventory of the player
    37.                 give {inventory1.%player%::*} to the player
    38.                 set chestplate of the player to {chestplate1.%player%}
    39.                 set helm of the player to {helm1.%player%}
    40.                 set leg of the player to {leg1.%player%}
    41.                 set boot of the player to {boot1.%player%}
    42.                 set {inv.%player%} to "1"
    43.                 message "&6Du hast nun Inventar &31&6."
    44.                 stop
    45.             if argument is "2":
    46.                 message "&cFehler: Du hast bereits Inventar 2!"
    47.                 stop
    48.         if argument is not set:
    49.             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.
     
    #2
    jensIO gefällt das.
  3. OlliPausW
    Offline

    OlliPausW

    Registriert seit:
    28. April 2014
    Beiträge:
    17
    Ort:
    da wo mein haus wohnt
    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.
     
    #3
  4. OlliPausW
    Offline

    OlliPausW

    Registriert seit:
    28. April 2014
    Beiträge:
    17
    Ort:
    da wo mein haus wohnt
    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 (Text):
    1. command /change [<text>]:
    2.     permission: skript.invchange
    3.     usage:&c/change <1-2> oder /change
    4.     trigger:
    5.         if {inv.%player%} is not set:
    6.             set {inv.%player%} to "1"
    7.             wait 0.2 seconds
    8.         if {inv.%player%} is "1":
    9.             if argument is "1":
    10.                 message "&cFehler: Du hast bereits Inventar 1!"
    11.                 stop
    12.             if argument is "2":
    13.                 set {test.%player%} to number of nothing in the player's inventory
    14.                 wait 0.2 seconds
    15.                 if {test.%player%} is not 36:
    16.                     set {inventory1.%player%::*} to items in the player's inventory
    17.                 if {test.%player%} is 36:
    18.                     set {inventory1.%player%::*} to air
    19.                 set {chestplate1.%player%} to chestplate of the player
    20.                 set {helm1.%player%} to helm of the player
    21.                 set {leg1.%player%} to leg of the player
    22.                 set {boot1.%player%} to boot of the player
    23.                 wait 0.2 seconds
    24.                 clear the inventory of the player
    25.                 give {inventory2.%player%::*} to the player
    26.                 set chestplate of the player to {chestplate2.%player%}
    27.                 set helm of the player to {helm2.%player%}
    28.                 set leg of the player to {leg2.%player%}
    29.                 set boot of the player to {boot2.%player%}
    30.                 set {inv.%player%} to "2"
    31.                 message "&6Du hast nun Inventar &32&6."
    32.                 stop
    33.         if {inv.%player%} is "2":
    34.             if argument is "1":
    35.                 set {test.%player%} to number of nothing in the player's inventory
    36.                 if {test.%player%} is not 36:
    37.                     set {inventory2.%player%::*} to items in the player's inventory
    38.                 if {test.%player%} is 36:
    39.                     set {inventory2.%player%::*} to air
    40.                 set {chestplate2.%player%} to chestplate of the player
    41.                 set {helm2.%player%} to helm of the player
    42.                 set {leg2.%player%} to leg of the player
    43.                 set {boot2.%player%} to boot of the player
    44.                 wait 0.2 seconds
    45.                 clear the inventory of the player
    46.                 give {inventory1.%player%::*} to the player
    47.                 set chestplate of the player to {chestplate1.%player%}
    48.                 set helm of the player to {helm1.%player%}
    49.                 set leg of the player to {leg1.%player%}
    50.                 set boot of the player to {boot1.%player%}
    51.                 set {inv.%player%} to "1"
    52.                 message "&6Du hast nun Inventar &31&6."
    53.                 stop
    54.             if argument is "2":
    55.                 message "&cFehler: Du hast bereits Inventar 2!"
    56.                 stop
    57.         if argument is not set:
    58.             message "&6Du hast momentan Inventar &3%{inv.%player%}%"
     
    #4