Pix3lPanos Posted May 16, 2022 Posted May 16, 2022 (edited) i want to make an npc witch if you sneak and press right click it opens an gui witch i can buy a potion of speed and remove 10 diamonds from my inventory else it says "you dont have enough diamonds" in the chat Thanks- Edited May 16, 2022 by Pix3lPanos
ProfCube Posted May 19, 2022 Posted May 19, 2022 (edited) @Pix3lPanos here is the code, you will need the following plugins: Skript Skript-gui Hopefully this suffice the need that you wanted I tested this in 1.18.2 I was not able to do the sneak, but was able to do the right click. options: GUI: &c&lSHOP # Avariables: # {item_amount} = 10 command /setnpc: permission: npc.create trigger: spawn 1 villager at location of player set name of last spawned entity to "{@GUI}" apply slowness 255 to last spawned entity for 999 days set {npc} to location of player command /kill: permission: npc.kill trigger: loop all entities: name of loop-entity contains "{@GUI}" kill loop-entity every second: loop all entities: name of loop-entity contains "{@GUI}" teleport loop-entity to {npc} on damage: name of victim contains "{@GUI}" cancel event on right click on entity: name of clicked entity contains "{@GUI}" if {spam::%player%} is true: send "&cPlease dont spam the npc" to player else: set {spam::%player%} to true mShop(player, "shop") wait 1 second set {spam::%player%} to false on death: set {spam::%victim%} to false on join: set {spam::%player%} to false function mShop(p: player, m: text): if {_m} is "shop": create a gui with virtual chest inventory with 3 rows named "&c&lHermes Speed Shop": make gui slot 13 with speed potion named "&b&lHermes": set {_d} to amount of diamonds in player's inventory if {_d} >= 10: remove 10 diamonds from {_p}'s inventory give 1 potions of swiftness named "&b&lHermes" to {_p} else: if {_d} <= 10: send "&cYou don't have enought Diamonds" open last gui to {_p} Edited May 19, 2022 by ProfCube
Pryzmm Posted May 19, 2022 Posted May 19, 2022 18 hours ago, ProfCube said: @Pix3lPanos here is the code, you will need the following plugins: Skript Skript-gui Hopefully this suffice the need that you wanted I tested this in 1.18.2 I was not able to do the sneak, but was able to do the right click. options: GUI: &c&lSHOP # Avariables: # {item_amount} = 10 command /setnpc: permission: npc.create trigger: spawn 1 villager at location of player set name of last spawned entity to "{@GUI}" apply slowness 255 to last spawned entity for 999 days set {npc} to location of player command /kill: permission: npc.kill trigger: loop all entities: name of loop-entity contains "{@GUI}" kill loop-entity every second: loop all entities: name of loop-entity contains "{@GUI}" teleport loop-entity to {npc} on damage: name of victim contains "{@GUI}" cancel event on right click on entity: name of clicked entity contains "{@GUI}" if {spam::%player%} is true: send "&cPlease dont spam the npc" to player else: set {spam::%player%} to true mShop(player, "shop") wait 1 second set {spam::%player%} to false on death: set {spam::%victim%} to false on join: set {spam::%player%} to false function mShop(p: player, m: text): if {_m} is "shop": create a gui with virtual chest inventory with 3 rows named "&c&lHermes Speed Shop": make gui slot 13 with speed potion named "&b&lHermes": set {_d} to amount of diamonds in player's inventory if {_d} >= 10: remove 10 diamonds from {_p}'s inventory give 1 potions of swiftness named "&b&lHermes" to {_p} else: if {_d} <= 10: send "&cYou don't have enought Diamonds" open last gui to {_p} isnt normal skript metadata tag effects better than skript-gui addon? Owner of Lifestealed, Labs, Encore, UNOfficially and Observed OG [VIP] 12/26/20 - 10/27/2021 OG [PRO] 12/27/21 - 11/18/2022 OG [LEGEND] 11/18/2022 - 3/14/2023 [DEFAULT] 3/14/2023 - 5/8/2024 [MOD] 5/8/2024 - Present
ProfCube Posted May 20, 2022 Posted May 20, 2022 @AgentGamerPro IDK i just made it for the hell of it
Pryzmm Posted May 20, 2022 Posted May 20, 2022 9 minutes ago, ProfCube said: @AgentGamerPro IDK i just made it for the hell of it fair enough Owner of Lifestealed, Labs, Encore, UNOfficially and Observed OG [VIP] 12/26/20 - 10/27/2021 OG [PRO] 12/27/21 - 11/18/2022 OG [LEGEND] 11/18/2022 - 3/14/2023 [DEFAULT] 3/14/2023 - 5/8/2024 [MOD] 5/8/2024 - Present
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now