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

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

Skaju

Member
Oct 26, 2019
3
0
0
24
Poland
twitch.tv
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:
if {_p} has 3 gold block in inventory:
                            remove 3 gold block from player's inventory
                            teleport {_p} to player
                            stop

Script:
Code:
command /tpa [<text>]:
    trigger:
        if arg 1 is not set:
            send "&c&lSky&6&lCraft &8&l» &cPodaj nick &6Gracza&c!"
            stop
        set {_arg1} to arg 1
        set {_arg1} to {_arg1} parsed as offlineplayer
        if {_arg1} is online:
            if player has permission "tp.vp":
                send "&c&lSky&6&lCraft &8&l» &7Gracz &6%player% &7chce sie do Ciebie teleportowac!" to {_arg1}
                send "&c&lSky&6&lCraft &8&l» &7Aby zaakceptowac teleportacje wpisz &6/tpaccept" to {_arg1}
                send "&c&lSky&6&lCraft &8&l» &7Aby odrzucic teleportacje wpisz &6/tpdeny" to {_arg1}
                send "&c&lSky&6&lCraft &8&l» &7Wyslales prosbe o teleportacje do gracza &6%{_arg1}%&7"
                set {tpa::%{_arg1}%::sendAsk} to name of player
                set {tpa::%player%::toTeleport} to {_arg1}
            else:
                send "&c&lSky&6&lCraft &8&l» &7Gracz &6%player% &7chce sie do Ciebie teleportowac!" to {_arg1}
                send "&c&lSky&6&lCraft &8&l» &7Aby zaakceptowac teleportacje wpisz &6/tpaccept" to {_arg1}
                send "&c&lSky&6&lCraft &8&l» &7Aby odrzucic teleportacje wpisz &6/tpdeny" to {_arg1}
                send "&c&lSky&6&lCraft &8&l» &7Wyslales prosbe o teleportacje do gracza &6%{_arg1}%&7"
                send "&c&lSky&6&lCraft &8&l» &7Pamietaj o wymaganych &63 blokach zlota&7!"
                set {tpa::%{_arg1}%::sendAsk} to name of player
                set {tpa::%player%::toTeleport} to {_arg1}
        else:
            send "&c&lSky&6&lCraft &8&l» &cGracz &6%{_arg1}% &cjest offline!"

on quit:
    if {tpa::%player%::toTeleport} is set:
        clear {tpa::%{tpa::%player%::toTeleport}%::toTeleport}
        clear {tpa::%player%::toTeleport}
    if {tpa::%player%::sendAsk} is set:
        clear {tpa::%{tpa::%player%::sendAsk}%::sendAsk}
        clear {tpa::%player%::sendAsk}
command /tpaccept:
    trigger:
        if {tpa::%player%::sendAsk} is set:
            set {_p} to {tpa::%player%::sendAsk}
            set {_p} to {_p} parsed as offlineplayer
            if {_p} is online:
                if {_p} has permission "tp.vip":
                    send "&c&lSky&6&lCraft &8&l» &7Gracz &6%player% &7zaakceptowal Twoja prosbe o teleportacje!" to {_p}
                    send "&c&lSky&6&lCraft &8&l» &7Nie ruszaj sie &c5 sekund&7!" to {_p}
                    send "&c&lSky&6&lCraft &8&l» &7Przyjales prosbe o teleportacja od gracza &6%{_p}%&7!"
                    clear {tpa::%{_p}%::toTeleport}
                    clear {tpa::%player%::toTeleport}
                    clear {tpa::%{_p}%::sendAsk}
                    clear {tpa::%player%::sendAsk}
                    set {_x} to x-location of {_p}
                    set {_y} to y-location of {_p}
                    set {_z} to z-location of {_p}
                    loop 5 times:
                        if difference between x-location of {_p} and {_x} is larger than 0.5:
                            send "&c&lSky&6&lCraft &8&l» &cPoruszyles sie, teleportacja zostala &6anulowana&c!" to {_p}
                            stop
                        if difference between y-location of {_p} and {_y} is larger than 0.5:
                            send "&c&lSky&6&lCraft &8&l» &cPoruszyles sie, teleportacja zostala &6anulowana&c!" to {_p}
                            stop
                        if difference between z-location of {_p} and {_z} is larger than 0.5:
                            send "&c&lSky&6&lCraft &8&l» &cPoruszyles sie, teleportacja zostala &6anulowana&c!" to {_p}
                            stop
                        wait 1 second
                    teleport {_p} to player
                    stop
                else:
                    if {_p} has 3 gold block in inventory:
                        send "&c&lSky&6&lCraft &8&l» &7Gracz &6%player% &7zaakceptowal Twoja prosbe o teleportacje!" to {_p}
                        send "&c&lSky&6&lCraft &8&l» &7Nie ruszaj sie &c5 sekund&7!" to {_p}
                        send "&c&lSky&6&lCraft &8&l» &7Przyjales prosbe o teleportacja od gracza &6%{_p}%&7!"
                        clear {tpa::%{_p}%::toTeleport}
                        clear {tpa::%player%::toTeleport}
                        clear {tpa::%{_p}%::sendAsk}
                        clear {tpa::%player%::sendAsk}
                        set {_x} to x-location of {_p}
                        set {_y} to y-location of {_p}
                        set {_z} to z-location of {_p}
                        loop 5 times:
                            if difference between x-location of {_p} and {_x} is larger than 0.5:
                                send "&c&lSky&6&lCraft &8&l» &cPoruszyles sie, teleportacja zostala &6anulowana&c!" to {_p}
                                stop
                            if difference between y-location of {_p} and {_y} is larger than 0.5:
                                send "&c&lSky&6&lCraft &8&l» &cPoruszyles sie, teleportacja zostala &6anulowana&c!" to {_p}
                                stop
                            if difference between z-location of {_p} and {_z} is larger than 0.5:
                                send "&c&lSky&6&lCraft &8&l» &cPoruszyles sie, teleportacja zostala &6anulowana&c!" to {_p}
                                stop
                            wait 1 second
                        if {_p} has 3 gold block in inventory:
                            remove 3 gold block from player's inventory
                            teleport {_p} to player
                            stop
                        else:
                            send "&c&lSky&6&lCraft &8&l» &cNie kombinuj &6:)" to {_p}
                            stop
                    else:
                        send "&c&lSky&6&lCraft &8&l» &cDo teleportacji wymagane sa &63 bloki zlota&c!" to {_p}
                        send "&c&lSky&6&lCraft &8&l» &cGracz &6%{_p}% &cnie posiada &63 blokow zlota&c!"
                        stop
            else:
                clear {tpa::%{_p}%::toTeleport}
                clear {tpa::%player%::toTeleport}
                clear {tpa::%{_p}%::sendAsk}
                clear {tpa::%player%::sendAsk}
                send "&c&lSky&6&lCraft &8&l» &cNie masz od kogo zaakceptowac teleportacji!"
                stop
        else:
            send "&c&lSky&6&lCraft &8&l» &cNie dostales prosby o teleportacje!"
            stop

Sorry for my bad english, but i from Poland.
I translate my post in Google Translate, lmao :emoji_sweat_smile:
 
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.
 
Status
Not open for further replies.