Jump to content

Recommended Posts

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 by Pix3lPanos
Link to comment
Share on other sites

@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 by ProfCube
Link to comment
Share on other sites

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?

 

 

image.png.bc433d6489d70ad831075fe76809b993.png
 

Owner of Lifestealed, Exploratory, 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

 

Link to comment
Share on other sites

9 minutes ago, ProfCube said:

@AgentGamerPro IDK i just made it for the hell of it

fair enough

 

 

image.png.bc433d6489d70ad831075fe76809b993.png
 

Owner of Lifestealed, Exploratory, 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

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...