Skocz do zawartości
  • 0

Nie działający skrypt na nowy stół do zaklęć.


Pytanie

 

 

Cześć, od kilku dni tworzę serwer dla kilkunastu znajomych. Wczoraj przyszedł mi do głowy pomysł zrobienia enchantu który ma proces progresu, a że akurat pasuje on do zamysłu serwera stwierdziłem, że go stworzę. Niestety po kilku godzinach pisania, naprawiania błędów już nie wiedziałem co mam zrobić, próbowałem nawet pomocy chatugpt który po kilku prostych poleceniach zapominał o małej części skryptu, który zostawał usunięty przez co skrypt "zostawał naprawiany". Potrzebuje pomocy w naprawieniu poniżej wysyłam skrypt przed ingerencją chatugpt oraz błędy które wyskakują w konsoli. Z góry dziękuje.

 

Odnośnik do komentarza
https://skript.pl/temat/58444-nie-dzia%C5%82aj%C4%85cy-skrypt-na-nowy-st%C3%B3%C5%82-do-zakl%C4%99%C4%87/
Udostępnij na innych stronach

11 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

  • 0

Aby zniwelować te błędy wystarczą delikatne poprawki :D 
 

Spoiler
options:
	gui-title: "&1Stół Zaklinania"
	enchant-cost: 5
	level-up-chance: 5 # 5% szansy na wbicie kolejnego poziomu
	lapis-cost: 1 # Koszt 1 Lapis Lazuli

variables:
	{player_status::*} = 0 # Gracz startuje z poziomem 0

on rightclick:
	if clicked block is an enchanting table:
		cancel event
		open chest inventory with 3 rows named {@gui-title} to player
		set slot 13 of event-inventory to lime wool named "&aZaklnij przedmiot"

on inventory click:
	if name of event-inventory is {@gui-title}:
		if clicked slot is 13:
			set {_item} to player's tool
			if {_item} is not set:
				close player's inventory
				send action bar "&cNie trzymasz przedmiotu, który możesz zaklnąć!" to player
				stop
			if player's level >= {@enchant-cost}:
				if {player_status.%player%} >= 1:
					set {_enchantments::*} to "sharpness", "smite", "bane_of_arthropods", "fire_aspect", "knockback", "looting", "efficiency", "unbreaking", "fortune", "silk_touch", "protection", "fire_protection", "blast_protection", "projectile_protection", "thorns", "respiration", "aqua_affinity", "depth_strider", "frost_walker", "soul_speed", "power", "punch", "flame", "infinity", "lure", "luck_of_the_sea", "riptide", "channeling", "impaling", "loyalty", "piercing", "quick_charge", "multishot" and "mending"
					if level of {_item} >= 5:
						close player's inventory
						send action bar "&cTen przedmiot osiągnął już pełnię swojej magii!" to player
						stop
					if player's inventory contains lapis lazuli:
						remove {@lapis-cost} lapis lazuli from player's inventory
						execute console command "/experience add %player% -{@enchant-cost} levels"
						set {_chosen} to random element out of {_enchantments::*}
						set {_max-level} to maxLevelOfEnchant({_chosen})
						set {_level} to random integer between 1 and {_max-level}
						execute console command "/enchant %player% %{_chosen}% %{_level}%"
						set slot 10 of event-inventory to {_item}
						if random integer between 1 and 100 <= {@level-up-chance}:
							add 1 to {player_status.%player%}
							send action bar "&aTwoje umiejętności zaklinania wzrosły do &6{player_status.%player%}&a!" to player
						else:
							send action bar "&aTwój przedmiot został zaklęty, ale Twoje umiejętności pozostają na poziomie &6{player_status.%player%}&a!" to player
					else:
						close player's inventory
						send action bar "&cBrakuje Ci Lapis Lazuli, aby skorzystać z mocy stołu!" to player
				else:
					close player's inventory
					send action bar "&cTwoje umiejętności zaklinania są za niskie, aby użyć tej mocy!" to player
			else:
				close player's inventory
				send action bar "&cPotrzebujesz więcej doświadczenia, by skorzystać z mocy tego stołu!" to player

function maxLevelOfEnchant(enchant: text) :: number:
	if {_enchant} is "sharpness", "smite", "bane_of_arthropods", "protection", "fire_protection", "blast_protection", "projectile_protection":
		return 5
	if {_enchant} is "efficiency", "unbreaking", "fortune", "looting", "power":
		return 5
	if {_enchant} is "thorns", "depth_strider", "riptide", "quick_charge":
		return 3
	if {_enchant} is "fire_aspect", "punch", "loyalty":
		return 2
	if {_enchant} is "mending", "silk_touch", "flame", "infinity", "aqua_affinity", "channeling", "multishot":
		return 1
	if {_enchant} is "frost_walker", "soul_speed":
		return 2
	return 1

command /setEnchantLevel <player> <number>:
	permission: op
	permission message: "&cNie masz uprawnień do używania tej komendy."
	trigger:
		if arg 2 is not set:
			send "&cPrawidłowe użycie: /setEnchantLevel <gracz> <poziom>" to player
			stop
		set {player_status.%arg 1%} to arg 2
		send "&aPoziom zaklinania gracza &6%arg 1%&a został ustawiony na &6%arg 2%&a!" to player

 

Jednakże nie jestem w 100% pewny czy to będzie działać, gdyż nie sprawdzałem. 
Jeżeli chcesz aby to poprawić aby działało, podaj swoją wersję serwera, wersję skripta i dodatki jakie masz ;)

  • 0

https://github.com/kijl/EnchTab
Jak by coś dodać lub poprawić pisz w prywatnej wiadomości

Edit.

Znalazłem jeden błąd nie wpływający na działanie pluginu. Jutro po pracy postaram się go poprawić

Edytowane przez _MicX_
  • 0
31 minut temu, knugi napisał:

Aby zniwelować te błędy wystarczą delikatne poprawki :D 
 

  Pokaż ukrytą zawartość
options:
	gui-title: "&1Stół Zaklinania"
	enchant-cost: 5
	level-up-chance: 5 # 5% szansy na wbicie kolejnego poziomu
	lapis-cost: 1 # Koszt 1 Lapis Lazuli

variables:
	{player_status::*} = 0 # Gracz startuje z poziomem 0

on rightclick:
	if clicked block is an enchanting table:
		cancel event
		open chest inventory with 3 rows named {@gui-title} to player
		set slot 13 of event-inventory to lime wool named "&aZaklnij przedmiot"

on inventory click:
	if name of event-inventory is {@gui-title}:
		if clicked slot is 13:
			set {_item} to player's tool
			if {_item} is not set:
				close player's inventory
				send action bar "&cNie trzymasz przedmiotu, który możesz zaklnąć!" to player
				stop
			if player's level >= {@enchant-cost}:
				if {player_status.%player%} >= 1:
					set {_enchantments::*} to "sharpness", "smite", "bane_of_arthropods", "fire_aspect", "knockback", "looting", "efficiency", "unbreaking", "fortune", "silk_touch", "protection", "fire_protection", "blast_protection", "projectile_protection", "thorns", "respiration", "aqua_affinity", "depth_strider", "frost_walker", "soul_speed", "power", "punch", "flame", "infinity", "lure", "luck_of_the_sea", "riptide", "channeling", "impaling", "loyalty", "piercing", "quick_charge", "multishot" and "mending"
					if level of {_item} >= 5:
						close player's inventory
						send action bar "&cTen przedmiot osiągnął już pełnię swojej magii!" to player
						stop
					if player's inventory contains lapis lazuli:
						remove {@lapis-cost} lapis lazuli from player's inventory
						execute console command "/experience add %player% -{@enchant-cost} levels"
						set {_chosen} to random element out of {_enchantments::*}
						set {_max-level} to maxLevelOfEnchant({_chosen})
						set {_level} to random integer between 1 and {_max-level}
						execute console command "/enchant %player% %{_chosen}% %{_level}%"
						set slot 10 of event-inventory to {_item}
						if random integer between 1 and 100 <= {@level-up-chance}:
							add 1 to {player_status.%player%}
							send action bar "&aTwoje umiejętności zaklinania wzrosły do &6{player_status.%player%}&a!" to player
						else:
							send action bar "&aTwój przedmiot został zaklęty, ale Twoje umiejętności pozostają na poziomie &6{player_status.%player%}&a!" to player
					else:
						close player's inventory
						send action bar "&cBrakuje Ci Lapis Lazuli, aby skorzystać z mocy stołu!" to player
				else:
					close player's inventory
					send action bar "&cTwoje umiejętności zaklinania są za niskie, aby użyć tej mocy!" to player
			else:
				close player's inventory
				send action bar "&cPotrzebujesz więcej doświadczenia, by skorzystać z mocy tego stołu!" to player

function maxLevelOfEnchant(enchant: text) :: number:
	if {_enchant} is "sharpness", "smite", "bane_of_arthropods", "protection", "fire_protection", "blast_protection", "projectile_protection":
		return 5
	if {_enchant} is "efficiency", "unbreaking", "fortune", "looting", "power":
		return 5
	if {_enchant} is "thorns", "depth_strider", "riptide", "quick_charge":
		return 3
	if {_enchant} is "fire_aspect", "punch", "loyalty":
		return 2
	if {_enchant} is "mending", "silk_touch", "flame", "infinity", "aqua_affinity", "channeling", "multishot":
		return 1
	if {_enchant} is "frost_walker", "soul_speed":
		return 2
	return 1

command /setEnchantLevel <player> <number>:
	permission: op
	permission message: "&cNie masz uprawnień do używania tej komendy."
	trigger:
		if arg 2 is not set:
			send "&cPrawidłowe użycie: /setEnchantLevel <gracz> <poziom>" to player
			stop
		set {player_status.%arg 1%} to arg 2
		send "&aPoziom zaklinania gracza &6%arg 1%&a został ustawiony na &6%arg 2%&a!" to player

 

Jednakże nie jestem w 100% pewny czy to będzie działać, gdyż nie sprawdzałem. 
Jeżeli chcesz aby to poprawić aby działało, podaj swoją wersję serwera, wersję skripta i dodatki jakie masz ;)

Wersja 1.20.6 skript najnowszy chyba 2.10 czy jakoś tak a dodatków nie posiadam

  • 0
Godzinę temu, knugi napisał:

Aby zniwelować te błędy wystarczą delikatne poprawki :D 
 

  Pokaż ukrytą zawartość
options:
	gui-title: "&1Stół Zaklinania"
	enchant-cost: 5
	level-up-chance: 5 # 5% szansy na wbicie kolejnego poziomu
	lapis-cost: 1 # Koszt 1 Lapis Lazuli

variables:
	{player_status::*} = 0 # Gracz startuje z poziomem 0

on rightclick:
	if clicked block is an enchanting table:
		cancel event
		open chest inventory with 3 rows named {@gui-title} to player
		set slot 13 of event-inventory to lime wool named "&aZaklnij przedmiot"

on inventory click:
	if name of event-inventory is {@gui-title}:
		if clicked slot is 13:
			set {_item} to player's tool
			if {_item} is not set:
				close player's inventory
				send action bar "&cNie trzymasz przedmiotu, który możesz zaklnąć!" to player
				stop
			if player's level >= {@enchant-cost}:
				if {player_status.%player%} >= 1:
					set {_enchantments::*} to "sharpness", "smite", "bane_of_arthropods", "fire_aspect", "knockback", "looting", "efficiency", "unbreaking", "fortune", "silk_touch", "protection", "fire_protection", "blast_protection", "projectile_protection", "thorns", "respiration", "aqua_affinity", "depth_strider", "frost_walker", "soul_speed", "power", "punch", "flame", "infinity", "lure", "luck_of_the_sea", "riptide", "channeling", "impaling", "loyalty", "piercing", "quick_charge", "multishot" and "mending"
					if level of {_item} >= 5:
						close player's inventory
						send action bar "&cTen przedmiot osiągnął już pełnię swojej magii!" to player
						stop
					if player's inventory contains lapis lazuli:
						remove {@lapis-cost} lapis lazuli from player's inventory
						execute console command "/experience add %player% -{@enchant-cost} levels"
						set {_chosen} to random element out of {_enchantments::*}
						set {_max-level} to maxLevelOfEnchant({_chosen})
						set {_level} to random integer between 1 and {_max-level}
						execute console command "/enchant %player% %{_chosen}% %{_level}%"
						set slot 10 of event-inventory to {_item}
						if random integer between 1 and 100 <= {@level-up-chance}:
							add 1 to {player_status.%player%}
							send action bar "&aTwoje umiejętności zaklinania wzrosły do &6{player_status.%player%}&a!" to player
						else:
							send action bar "&aTwój przedmiot został zaklęty, ale Twoje umiejętności pozostają na poziomie &6{player_status.%player%}&a!" to player
					else:
						close player's inventory
						send action bar "&cBrakuje Ci Lapis Lazuli, aby skorzystać z mocy stołu!" to player
				else:
					close player's inventory
					send action bar "&cTwoje umiejętności zaklinania są za niskie, aby użyć tej mocy!" to player
			else:
				close player's inventory
				send action bar "&cPotrzebujesz więcej doświadczenia, by skorzystać z mocy tego stołu!" to player

function maxLevelOfEnchant(enchant: text) :: number:
	if {_enchant} is "sharpness", "smite", "bane_of_arthropods", "protection", "fire_protection", "blast_protection", "projectile_protection":
		return 5
	if {_enchant} is "efficiency", "unbreaking", "fortune", "looting", "power":
		return 5
	if {_enchant} is "thorns", "depth_strider", "riptide", "quick_charge":
		return 3
	if {_enchant} is "fire_aspect", "punch", "loyalty":
		return 2
	if {_enchant} is "mending", "silk_touch", "flame", "infinity", "aqua_affinity", "channeling", "multishot":
		return 1
	if {_enchant} is "frost_walker", "soul_speed":
		return 2
	return 1

command /setEnchantLevel <player> <number>:
	permission: op
	permission message: "&cNie masz uprawnień do używania tej komendy."
	trigger:
		if arg 2 is not set:
			send "&cPrawidłowe użycie: /setEnchantLevel <gracz> <poziom>" to player
			stop
		set {player_status.%arg 1%} to arg 2
		send "&aPoziom zaklinania gracza &6%arg 1%&a został ustawiony na &6%arg 2%&a!" to player

 

Jednakże nie jestem w 100% pewny czy to będzie działać, gdyż nie sprawdzałem. 
Jeżeli chcesz aby to poprawić aby działało, podaj swoją wersję serwera, wersję skripta i dodatki jakie masz ;)

1. Skrypt nie sprawdza czy gracz ma cos w rece co mozna enchantowac

2. nie enchantuje przedmiotu

3. Nie ma nawet na 13 slocie bloku ktory sie powinno klikać ale enchant wyłapuje jak sie kliknie w ten slot

Jedyny plus tego skryptu to ze w koncu nie ma czerwonych błędów ale jest kilka żółtych xd

  • 0
22 minuty temu, Dam1S napisał:

Także zapomniałem dodać że przedmiot jakby kopiuje się czyli w ręce zostaje ale też dodaje się on w gui 

Jedynie poprawiłem błędy które występują w konsoli które wpisałeś w temacie. Teraz mając większe spektrum nie działania skryptu możemy przejść do kolejnych działań. Powiedz mi co chciałeś uzyskać tworząc ten skrypt. O jaki "proces progresu" Ci chodzi? Jak to ma wyglądać?

  • 0
3 minuty temu, knugi napisał:

Jedynie poprawiłem błędy które występują w konsoli które wpisałeś w temacie. Teraz mając większe spektrum nie działania skryptu możemy przejść do kolejnych działań. Powiedz mi co chciałeś uzyskać tworząc ten skrypt. O jaki "proces progresu" Ci chodzi? Jak to ma wyglądać?

Miało to wyglądać w następujący sposób każdy gracz miał posiadać poziom umiejętności zaklinania na samym starcie mail on być 0 jeżeli gracz z 0 lvl kliknął w enchant pojawiała mu się informacja że musi się on dowiedzieć jak się z tego korzysta od wiedźmy (npc z citizens) która za kilka zadań nadaje graczowi 1 poziom teraz gracz mógł enchantowac przedmioty na 1lvl czyli ostrość 1, unbreaking 1 itp. wraz z enchantowaniem gracz miał 5% szans na zwiększenie poziomu jeżeli gracz posiadał 2 poziom mógł on już enchantować na naprzykład ostrość 2, lecz poziom 2 zaklina się dopiero po tym jak na przedmiocie jest już poziom 1 enchanty czyli jak będzie ostrość 1 to może wylecieć 2 ale jeżeli nie będzie ostrości to wylatuje dopiero 1 z każdym poziomem miały się także zwiększać poziomy enchantow analogicznie do poprzednich lecz po wbiciu 5 (maksymalnego poziomu chociaż nie musi on być zablokowany że tylko 5 da się wbić) nie tylko gracz uzyskuje możliwość enchantowania na 5 poziom a także ma szansę na wylosowanie mendingu lecz szansa na mending miał być zmiejszony o 5x czyli w stosunku do innych enchantow miało tam być tylko 20% zamiast 100%

  • 0

No i wiadomo bo jak zawsze o czymś zapomnialem dopisać miało też być wykluczone dostawania enchantow które są niemożliwe do zrobienia na zwykłym survivalu czyli np. Ostrość 6, niezniszczalność 4, infinity razem z flame, mending 2

  • 0

Proszę bardzo:
 

Spoiler
options:
	gui-title: "&1Stół Zaklinania"
	enchant-cost: 5
	level-up-chance: 5 # 5% szansy na wbicie kolejnego poziomu
	lapis-cost: 1 # Koszt 1 Lapis Lazuli

variables:
	{player_status::*} = 0 # Gracz startuje z poziomem 0
#Losowy enchant.
#Mending od 5 poziomu
function enchantmentsOfItem(i: item, x: boolean=true) :: enchantments:
	if {_i} is any helmet:
		return (unbreaking, protection, fire protection, blast protection, projectile protection, respiration, aqua affinity, thorns and mending)
	if {_i} is any chestplate:
		return unbreaking, protection, fire protection, blast protection, projectile protection, thorns and mending
	if {_i} is any leggings:
		return unbreaking, protection, fire protection, blast protection, projectile protection, thorns, mending and swift sneak
	if {_i} is any boots:
		return unbreaking, protection, fire protection, blast protection, projectile protection, thorns, mending, feather falling, depth strider, frost walker and soul speed
	if {_i} is any pickaxe:
		return efficiency, silk touch, unbreaking, fortune and mending
	if {_i} is any shovel:
		
	if {_i} is any hoe:
	
	if {_i} is any sword:
	
	if {_i} is bow:
	
	if {_i} is book:
		return fortune #Wypisz wszystkie mozliwe enchanty.
	if {_i} is crossbow:
	
	if {_i} is trident:
	
	if {_i} is fishing rod:

function zakazaneEnchanty(i: item) :: enchantments:
	loop enchantments of {_i}:
		set {_ench} to first (length of "%loop-value%") - 2 characters of "%loop-value%"
		set {_ench} to {_ench} parsed as enchantment
		
		if {_ench} is silk touch:
			add fortune to {_ret::*}
		if {_ench} is fortune:
			add silk touch to {_ret::*}
			
		if {_ench} is blast protection:
			add projectile protection to {_ret::*}
		if {_ench} is projection protection:
			add blast protection to {_ret::*}
			
		#... itd
	return {_ret::*}
on rightclick:
	if clicked block is an enchanting table:
		cancel event 
		if {player_status::%player%} is smaller than 1:
			send "Nie masz wymaganego poziomu do obslugi tego ustrojstwa." to player
			stop
		#if canEnchant(player's tool, fortune) is true:
		if player's tool is any helmet, chestplate, leggings, boots, axe, pickaxe, shovel, hoe, sword, bow, book, crossbow, trident or fishing rod:
			set {_x} to chest inventory with 3 rows named {@gui-title}
			set slot 10 of {_x} to player's tool
			set slot 13 of {_x} to lime wool named "&aZaklnij przedmiot"
			open {_x} to player
			stop
		send "Zaloz kurwa spodnie" to player
		stop

on inventory click:
	if name of event-inventory is {@gui-title}:
		cancel event
		if clicked slot is 13:
			set {_item} to player's tool
			if {_item} is not set:
				close player's inventory
				send action bar "&cNie trzymasz przedmiotu, który możesz zaklnąć!" to player
				stop
			if player's level >= {@enchant-cost}:
				if player's inventory contains {@lapis-cost} of lapis lazuli:
					set {_e1::*} to enchantmentsOfItem(player's tool)
					if {player_status::%player%} < 5:
						remove mending from {_e1::*}
					loop zakazaneEnchanty(player's tool):
						remove loop-value from {_e1::*}
					loop {_e1::*}:
						evaluate "set {_lvl} to level of %loop-value% of player's tool"
						if "%{_lvl}%" is "<none>":
							set {_lvl} to 0
						#broadcast "%{_lvl}% %loop-value% : %maxLevelOfEnchant(loop-value)%"
						set {_lvl} to "%{_lvl}%" parsed as integer
						if {_lvl} is larger than or equal to maxLevelOfEnchant(loop-value):
							remove loop-value from {_e1::*}
							#send "Cos sie nie powiodlo. Sprobuj jeszcze raz :/"
							#stop
					if size of {_e1::*} is 0:
						send "Nie mozna zenchantowac tego przedmiotu."
						stop
					set {_enchant} to random element out of {_e1::*}
					#broadcast "%{_enchant}%" #wykrywa
					evaluate "set {_lvlEnch} to level of %{_enchant}% of player's tool"
					add 1 to {_lvlEnch}
					#set {_lvlEnch} to (enchantment level of {_enchant} of player's tool) + 1
					set {_enchant} to "%{_enchant}% %{_lvlEnch}%" parsed as enchantment type
					#broadcast "%{_enchant}% %{_lvlEnch}%" #nie wykrywa
					remove {@lapis-cost} of lapis lazuli from player's inventory
					execute console command "/experience add %player% -{@enchant-cost} levels"
					enchant player's tool with {_enchant}
					wait 1 tick
					set slot 10 of event-inventory to player's tool
					if random integer between 1 and 100 <= {@level-up-chance}%:
						add 1 to {player_status::%player%}
						send action bar "&aTwoje umiejętności zaklinania wzrosły do &6%{player_status::%player%}%&a!" to player
					else:
						send action bar "&aTwój przedmiot został zaklęty, ale Twoje umiejętności pozostają na poziomie &6%{player_status::%player%}%&a!" to player
					#
					stop
				send action bar "&cBrakuje Ci Lapis Lazuli, aby skorzystać z mocy stołu!" to player
				stop
			send action bar "&cBrakuje poziomu doswiadczenia!" to player
			stop
		send "Inny blad."
		stop

function maxLevelOfEnchant(enchant: enchantment) :: integer:
	if {_enchant} is sharpness, smite, bane of arthropods, protection, fire protection, blast protection or projectile protection:
		return 5
	if {_enchant} is efficiency, fortune, looting or power:
		return 5
	if {_enchant} is thorns, depth strider, riptide, unbreaking or quick charge:
		return 3
	if {_enchant} is fire aspect, punch or loyalty:
		return 2
	if {_enchant} is mending, silk touch, flame, infinity, aqua affinity, channeling or multishot:
		return 1
	if {_enchant} is frost walker or soul speed:
		return 2
	return 1

command /setEnchantLevel [<player>] [<integer>]:
	permission: op
	permission message: "&cNie masz uprawnień do używania tej komendy."
	trigger:
		if arg 2 is set:
			set {player_status::%arg 1%} to arg 2
			send "&aPoziom zaklinania gracza &6%arg 1%&a został ustawiony na &6%arg 2%&a!" to player
			stop
		if arg 1 is set:
			if {player_status::%arg 1%} is set:
				send "Poziom %arg 1%: %{player_status::%arg 1%}%"
				stop
			stop
		if arg 2 is not set:
			send "&cPrawidłowe użycie: /setEnchantLevel <gracz> <poziom>" to player
			stop

 

 

Dołącz do dyskusji

Możesz dodać zawartość już teraz a zarejestrować się później. Jeśli posiadasz już konto, zaloguj się aby dodać zawartość za jego pomocą.

Nieaktywny
Odpowiedz na pytanie...

×   Wklejono zawartość z formatowaniem.   Usuń formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Odnośnik został automatycznie osadzony.   Przywróć wyświetlanie jako odnośnik

×   Przywrócono poprzednią zawartość.   Wyczyść edytor

×   Nie możesz bezpośrednio wkleić grafiki. Dodaj lub załącz grafiki z adresu URL.

  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...