Skocz do zawartości
  • 0

On inventory click


Kozaczekk

Pytanie

Witam, chciałbym, by po kliknięciu na Item zamieniało go na lepszy.

Np. żelazny hełm, po kliknięciu diamentowy hełm, nazwa i enchanty bez zmian

on inventory click:
    set {_cb} to index of clicked slot
    set {_i} to clicked slot
    broadcast "%{_cb}%, %{_i}%"
    lepsze(player, {_cb}, {_i})
function lepsze(p:player, nr:number, i:item):
    wait 1 tick
    broadcast "p = %{_p}%, nr: %{_nr}%, i: %{_i}%"
    set {_a::*} to "%{_i}%" split at " "
    
    if {_a::1} is "iron":
        set {_a::1} to "diamond"
    
    else if {_a::1} is "diamond":
        set {_a::1} to "netherite"
    set {_i} to join {_a::*} with " "
    set {_i} to ({_i} parsed as item)
    broadcast "&3%{_i}%"
    set slot {_nr} of {_p}'s inventory to {_i}

Jest dobrze, do momentu, gdy Item posiada enchant, nazwę bądź cokolwiek. Ktoś potrafi to naprawić?

Odnośnik do komentarza
https://skript.pl/temat/54319-on-inventory-click/
Udostępnij na innych stronach

3 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

  • 1

Coś takiego u mnie działa:

on script load:
	set {kozak::replace::1} to "leather"
	set {kozak::replace::2} to "iron"
	set {kozak::replace::3} to "diamond"
	set {kozak::replace::4} to "gold"
	set {kozak::replace::5} to "netherite"
on inventory click:
	set {_cb} to index of clicked slot
	set {_i} to clicked slot
	lepsze(player, {_cb}, {_i})
function lepsze(p:player, nr:number, i:item):
	if {_i} is any helmet or any chestplate or any leggings or any boots:
		loop {kozak::replace::*}:
			if "%{_i}%" contains loop-value:
				set {_add} to (loop-index parsed as integer) + 1
				if {kozak::replace::%{_add}%} is not set:
					stop
				exit loop
		if {_add} is not set:
			stop
		set {_type} to "%type of {_i}%"
		replace all {kozak::replace::%{_add}-1%} with {kozak::replace::%{_add}%} in {_type}
		set {_type} to {_type} parsed as item type
		set {_ench::*} to {_i}'s enchantments
		broadcast "%{_ench::*}%"
		set {_name} to {_i}'s name
		set {_lore::*} to {_i}'s lore
		if {_name} is set:
			set name of {_type} to {_name}
		if {_ench::*} is set:
			enchant {_type} with {_ench::*}
		if {_lore::*} is set:
			add {_lore::*} to lore of {_type}
		set slot {_nr} of {_p}'s inventory to {_type}

 

Odnośnik do komentarza
https://skript.pl/temat/54319-on-inventory-click/#findComment-329713
Udostępnij na innych stronach

  • 0

 

7 godzin temu, knugi napisał:

Coś takiego u mnie działa:

on script load:
	set {kozak::replace::1} to "leather"
	set {kozak::replace::2} to "iron"
	set {kozak::replace::3} to "diamond"
	set {kozak::replace::4} to "gold"
	set {kozak::replace::5} to "netherite"
on inventory click:
	set {_cb} to index of clicked slot
	set {_i} to clicked slot
	lepsze(player, {_cb}, {_i})
function lepsze(p:player, nr:number, i:item):
	if {_i} is any helmet or any chestplate or any leggings or any boots:
		loop {kozak::replace::*}:
			if "%{_i}%" contains loop-value:
				set {_add} to (loop-index parsed as integer) + 1
				if {kozak::replace::%{_add}%} is not set:
					stop
				exit loop
		if {_add} is not set:
			stop
		set {_type} to "%type of {_i}%"
		replace all {kozak::replace::%{_add}-1%} with {kozak::replace::%{_add}%} in {_type}
		set {_type} to {_type} parsed as item type
		set {_ench::*} to {_i}'s enchantments
		broadcast "%{_ench::*}%"
		set {_name} to {_i}'s name
		set {_lore::*} to {_i}'s lore
		if {_name} is set:
			set name of {_type} to {_name}
		if {_ench::*} is set:
			enchant {_type} with {_ench::*}
		if {_lore::*} is set:
			add {_lore::*} to lore of {_type}
		set slot {_nr} of {_p}'s inventory to {_type}

 

Dzięki 💪🏼

Odnośnik do komentarza
https://skript.pl/temat/54319-on-inventory-click/#findComment-329727
Udostępnij na innych stronach

Nieaktywny
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

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