1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT??:

    You can always check our our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

if {_p} has (item) in inventory, doesn't work

Discussion in 'Skript' started by Skaju, Oct 26, 2019.

Tags:
  1. Skaju

    Skaju Member

    Joined:
    Oct 26, 2019
    Messages:
    3
    Likes Received:
    0
    Hello.
    I edited script for tpa, but one fragment doesn't work.
    When script requires 3 gold block from player, shows that player doesn't have it, even though he has them.
    Apparently it's a script bug.

    Broken moment:
    Code (Text):
    1. if {_p} has 3 gold block in inventory:
    2.                             remove 3 gold block from player's inventory
    3.                             teleport {_p} to player
    4.                             stop
    5.  

    Script:
    Code (Text):
    1.  
    2. command /tpa [<text>]:
    3.     trigger:
    4.         if arg 1 is not set:
    5.             send "&c&lSky&6&lCraft &8&l» &cPodaj nick &6Gracza&c!"
    6.             stop
    7.         set {_arg1} to arg 1
    8.         set {_arg1} to {_arg1} parsed as offlineplayer
    9.         if {_arg1} is online:
    10.             if player has permission "tp.vp":
    11.                 send "&c&lSky&6&lCraft &8&l» &7Gracz &6%player% &7chce sie do Ciebie teleportowac!" to {_arg1}
    12.                 send "&c&lSky&6&lCraft &8&l» &7Aby zaakceptowac teleportacje wpisz &6/tpaccept" to {_arg1}
    13.                 send "&c&lSky&6&lCraft &8&l» &7Aby odrzucic teleportacje wpisz &6/tpdeny" to {_arg1}
    14.                 send "&c&lSky&6&lCraft &8&l» &7Wyslales prosbe o teleportacje do gracza &6%{_arg1}%&7"
    15.                 set {tpa::%{_arg1}%::sendAsk} to name of player
    16.                 set {tpa::%player%::toTeleport} to {_arg1}
    17.             else:
    18.                 send "&c&lSky&6&lCraft &8&l» &7Gracz &6%player% &7chce sie do Ciebie teleportowac!" to {_arg1}
    19.                 send "&c&lSky&6&lCraft &8&l» &7Aby zaakceptowac teleportacje wpisz &6/tpaccept" to {_arg1}
    20.                 send "&c&lSky&6&lCraft &8&l» &7Aby odrzucic teleportacje wpisz &6/tpdeny" to {_arg1}
    21.                 send "&c&lSky&6&lCraft &8&l» &7Wyslales prosbe o teleportacje do gracza &6%{_arg1}%&7"
    22.                 send "&c&lSky&6&lCraft &8&l» &7Pamietaj o wymaganych &63 blokach zlota&7!"
    23.                 set {tpa::%{_arg1}%::sendAsk} to name of player
    24.                 set {tpa::%player%::toTeleport} to {_arg1}
    25.         else:
    26.             send "&c&lSky&6&lCraft &8&l» &cGracz &6%{_arg1}% &cjest offline!"
    27.  
    28. on quit:
    29.     if {tpa::%player%::toTeleport} is set:
    30.         clear {tpa::%{tpa::%player%::toTeleport}%::toTeleport}
    31.         clear {tpa::%player%::toTeleport}
    32.     if {tpa::%player%::sendAsk} is set:
    33.         clear {tpa::%{tpa::%player%::sendAsk}%::sendAsk}
    34.         clear {tpa::%player%::sendAsk}
    35. command /tpaccept:
    36.     trigger:
    37.         if {tpa::%player%::sendAsk} is set:
    38.             set {_p} to {tpa::%player%::sendAsk}
    39.             set {_p} to {_p} parsed as offlineplayer
    40.             if {_p} is online:
    41.                 if {_p} has permission "tp.vip":
    42.                     send "&c&lSky&6&lCraft &8&l» &7Gracz &6%player% &7zaakceptowal Twoja prosbe o teleportacje!" to {_p}
    43.                     send "&c&lSky&6&lCraft &8&l» &7Nie ruszaj sie &c5 sekund&7!" to {_p}
    44.                     send "&c&lSky&6&lCraft &8&l» &7Przyjales prosbe o teleportacja od gracza &6%{_p}%&7!"
    45.                     clear {tpa::%{_p}%::toTeleport}
    46.                     clear {tpa::%player%::toTeleport}
    47.                     clear {tpa::%{_p}%::sendAsk}
    48.                     clear {tpa::%player%::sendAsk}
    49.                     set {_x} to x-location of {_p}
    50.                     set {_y} to y-location of {_p}
    51.                     set {_z} to z-location of {_p}
    52.                     loop 5 times:
    53.                         if difference between x-location of {_p} and {_x} is larger than 0.5:
    54.                             send "&c&lSky&6&lCraft &8&l» &cPoruszyles sie, teleportacja zostala &6anulowana&c!" to {_p}
    55.                             stop
    56.                         if difference between y-location of {_p} and {_y} is larger than 0.5:
    57.                             send "&c&lSky&6&lCraft &8&l» &cPoruszyles sie, teleportacja zostala &6anulowana&c!" to {_p}
    58.                             stop
    59.                         if difference between z-location of {_p} and {_z} is larger than 0.5:
    60.                             send "&c&lSky&6&lCraft &8&l» &cPoruszyles sie, teleportacja zostala &6anulowana&c!" to {_p}
    61.                             stop
    62.                         wait 1 second
    63.                     teleport {_p} to player
    64.                     stop
    65.                 else:
    66.                     if {_p} has 3 gold block in inventory:
    67.                         send "&c&lSky&6&lCraft &8&l» &7Gracz &6%player% &7zaakceptowal Twoja prosbe o teleportacje!" to {_p}
    68.                         send "&c&lSky&6&lCraft &8&l» &7Nie ruszaj sie &c5 sekund&7!" to {_p}
    69.                         send "&c&lSky&6&lCraft &8&l» &7Przyjales prosbe o teleportacja od gracza &6%{_p}%&7!"
    70.                         clear {tpa::%{_p}%::toTeleport}
    71.                         clear {tpa::%player%::toTeleport}
    72.                         clear {tpa::%{_p}%::sendAsk}
    73.                         clear {tpa::%player%::sendAsk}
    74.                         set {_x} to x-location of {_p}
    75.                         set {_y} to y-location of {_p}
    76.                         set {_z} to z-location of {_p}
    77.                         loop 5 times:
    78.                             if difference between x-location of {_p} and {_x} is larger than 0.5:
    79.                                 send "&c&lSky&6&lCraft &8&l» &cPoruszyles sie, teleportacja zostala &6anulowana&c!" to {_p}
    80.                                 stop
    81.                             if difference between y-location of {_p} and {_y} is larger than 0.5:
    82.                                 send "&c&lSky&6&lCraft &8&l» &cPoruszyles sie, teleportacja zostala &6anulowana&c!" to {_p}
    83.                                 stop
    84.                             if difference between z-location of {_p} and {_z} is larger than 0.5:
    85.                                 send "&c&lSky&6&lCraft &8&l» &cPoruszyles sie, teleportacja zostala &6anulowana&c!" to {_p}
    86.                                 stop
    87.                             wait 1 second
    88.                         if {_p} has 3 gold block in inventory:
    89.                             remove 3 gold block from player's inventory
    90.                             teleport {_p} to player
    91.                             stop
    92.                         else:
    93.                             send "&c&lSky&6&lCraft &8&l» &cNie kombinuj &6:)" to {_p}
    94.                             stop
    95.                     else:
    96.                         send "&c&lSky&6&lCraft &8&l» &cDo teleportacji wymagane sa &63 bloki zlota&c!" to {_p}
    97.                         send "&c&lSky&6&lCraft &8&l» &cGracz &6%{_p}% &cnie posiada &63 blokow zlota&c!"
    98.                         stop
    99.             else:
    100.                 clear {tpa::%{_p}%::toTeleport}
    101.                 clear {tpa::%player%::toTeleport}
    102.                 clear {tpa::%{_p}%::sendAsk}
    103.                 clear {tpa::%player%::sendAsk}
    104.                 send "&c&lSky&6&lCraft &8&l» &cNie masz od kogo zaakceptowac teleportacji!"
    105.                 stop
    106.         else:
    107.             send "&c&lSky&6&lCraft &8&l» &cNie dostales prosby o teleportacje!"
    108.             stop
    109.  

    Sorry for my bad english, but i from Poland.
    I translate my post in Google Translate, lmao :emoji_sweat_smile:
     
  2. Nikola

    Nikola Member

    Joined:
    Jul 10, 2019
    Messages:
    12
    Likes Received:
    1
    Install Lime's fork to SkQuery addon, and use string "if player has <ITEM>:" to check if player has specified item in inventory.
    Not tested, but should work.
     
  3. Skaju

    Skaju Member

    Joined:
    Oct 26, 2019
    Messages:
    3
    Likes Received:
    0
    I have WildSkript and SkQuery, but still doesn't work :/
     
  4. novastosha

    novastosha Well-Known Member

    Joined:
    Jan 11, 2019
    Messages:
    187
    Likes Received:
    9
    Yo check resources i made what you want
     
  5. Skaju

    Skaju Member

    Joined:
    Oct 26, 2019
    Messages:
    3
    Likes Received:
    0
    what?
     
  6. notblueblob67

    notblueblob67 Active Member

    Joined:
    Sep 13, 2019
    Messages:
    31
    Likes Received:
    0
    Go onto his profile and check the resources he has created, he said he has made what you are trying to create previously.
     
Loading...