Aller au contenu
  • 0

[Aide] - Hôtel de Vente


Question

Posté(e)

Version de Minecraft : 1.8.9
Version de Skript : 2.2-dev36 

Addons utilisés: MundoSk, WildSkript, skUtilitites, SkQuery, skript-mirror, Skelett, skript-yaml, skrayfall, tuske

Type du skript : Hôtel de Vente

Description du script :

C'est un script d'hôtel de vente (rien de plus basique), un joueur met en vente un objet un autre joueur peut l'acheter. Si le joueur qui à mit en vente son objet souhaite le récupérer il peut en cliquant sur l'objet.

Sauf que dans un hôtel de vente on n'a des pages (1,2,3 ...) suivant le nombres d'articles mit en vente. Néanmoins dans mon script je peux allé à la page 10 (voir +) or que la page 1 n'est pas complétée à 100%.

 

Comment régler ce soucis ?

 

function guihdv(p: player, page: number):
	set {_startpage} to {_page}*36
	set {_i} to 1
	set {_slot} to 0
	set {_id} to 1
	open virtual chest inventory with size 6 named "&7» &6Hôtel des ventes &e##%{_page}%" to {_p}
	# Blanc
	make a gui slot 36 of {_p} with stained glass pane:0 named " " to do nothing
	make a gui slot 38 of {_p} with stained glass pane:0 named " " to do nothing
	make a gui slot 40 of {_p} with stained glass pane:0 named " " to do nothing
	make a gui slot 42 of {_p} with stained glass pane:0 named " " to do nothing
	make a gui slot 44 of {_p} with stained glass pane:0 named " " to do nothing
	# Cyan
	make a gui slot 37 of {_p} with red stained glass pane named " " to do nothing
	make a gui slot 39 of {_p} with red stained glass pane named " " to do nothing
	make a gui slot 41 of {_p} with red stained glass pane named " " to do nothing
	make a gui slot 43 of {_p} with red stained glass pane named " " to do nothing
	if {_page} = 0:
		make a gui slot 48 of {_p} with paper named "&7<--" to do nothing
	else:
		make a gui slot 48 of {_p} with paper named "&7<--" to run function guihdv({_p}, ({_page} - 1))
	make a gui slot 49 of {_p} with sunflower named "&6Rafraîchir" to run function guihdv({_p}, {_page})
	make a gui slot 50 of {_p} with paper named "&7-->" to run function guihdv({_p}, ({_page} + 1))
	wait 1 ticks
	loop {hdv.item::*}:
		if loop-index parsed as a number > {_startpage}:
			if {hdv.name::%loop-index%} is "%{_p}%":
				make a gui slot {_slot} of {_p} with {hdv.item::%loop-index%} with lore "&7ID: &6%{_id}%||&7Prix: &6%{hdv.prix::%loop-index%}% &eSC||&7Vendeur: &6%{hdv.name::%loop-index%}%||||&aClique ici pour retirer l'objet." to close then run function remove({_p}, loop-index)
				add 1 to {_slot}
				add 1 to {_id}
			else:
				make a gui slot {_slot} of {_p} with {hdv.item::%loop-index%} with lore "&7ID: &6%{_id}%||&7Prix: &6%{hdv.prix::%loop-index%}% &eSC||&7Vendeur: &6%{hdv.name::%loop-index%}%" to close then run function buy({_p}, "%{hdv.name::%loop-index%}%", loop-index)
				add 1 to {_slot}
				add 1 to {_id}
			if {_slot} = (36*{_i}):
				exit loop

 

Voilà la fonction du GUI de l'hôtel de vente.

5 réponses à cette question

Messages recommandés

  • 0
Posté(e) (modifié)
Le 23/02/2020 à 06:07, Nouz a dit :

set {_startpage} to {_page}*36

Hi!

 

Essaye de remplacer TOUS les 36 par la place max d'items en vente dans une page

 

Bonne journée 

Modifié par LeCraftDeOuf
  • J'aime 1
  • 0
Posté(e)
Il y a 5 heures, LeCraftDeOuf a dit :

Hi!

 

Essaye de remplacer TOUS les 36 par la place max d'items en vente dans une page

 

Bonne journée 

Bonjour,

 

Tout d'abord merci de ta réponse, néanmoins le chiffre 36 est de base égale aux maximums d'items en vente dans une page.

  • 0
Posté(e) (modifié)
il y a une heure, Nouz a dit :

Bonjour,

 

Tout d'abord merci de ta réponse, néanmoins le chiffre 36 est de base égale aux maximums d'items en vente dans une page.

Bonsoir ! D'accord, je prend en compte : Essaye ceci :

function guihdv(p: player, page: number):
	set {_startpage} to {_page}*36
	
	set {_i} to 1
	set {_slot} to 0
	set {_id} to 1
	open virtual chest inventory with size 6 named "&7» &6Hôtel des ventes &e##%{_page}%" to {_p}
	# Blanc
	make a gui slot 36 of {_p} with stained glass pane:0 named " " to do nothing
	make a gui slot 38 of {_p} with stained glass pane:0 named " " to do nothing
	make a gui slot 40 of {_p} with stained glass pane:0 named " " to do nothing
	make a gui slot 42 of {_p} with stained glass pane:0 named " " to do nothing
	make a gui slot 44 of {_p} with stained glass pane:0 named " " to do nothing
	# Cyan
	make a gui slot 37 of {_p} with red stained glass pane named " " to do nothing
	make a gui slot 39 of {_p} with red stained glass pane named " " to do nothing
	make a gui slot 41 of {_p} with red stained glass pane named " " to do nothing
	make a gui slot 43 of {_p} with red stained glass pane named " " to do nothing
	if {_page} = 0:
		make a gui slot 48 of {_p} with paper named "&7<--" to do nothing
	else:
		make a gui slot 48 of {_p} with paper named "&7<--" to run function guihdv({_p}, ({_page} - 1))
	make a gui slot 49 of {_p} with sunflower named "&6Rafraîchir" to run function guihdv({_p}, {_page})
	if size of {hdv.item::*} > {_page}*36
		make a gui slot 50 of {_p} with paper named "&7-->" to run function guihdv({_p}, ({_page} + 1))
	else:
		make a gui slot 50 of {_p} with paper named "&7-->" to do nothing
	wait 1 ticks
	loop {hdv.item::*}:
		if loop-index parsed as a number > {_startpage}:
			if {hdv.name::%loop-index%} is "%{_p}%":
				make a gui slot {_slot} of {_p} with {hdv.item::%loop-index%} with lore "&7ID: &6%{_id}%||&7Prix: &6%{hdv.prix::%loop-index%}% &eSC||&7Vendeur: &6%{hdv.name::%loop-index%}%||||&aClique ici pour retirer l'objet." to close then run function remove({_p}, loop-index)
				add 1 to {_slot}
				add 1 to {_id}
			else:
				make a gui slot {_slot} of {_p} with {hdv.item::%loop-index%} with lore "&7ID: &6%{_id}%||&7Prix: &6%{hdv.prix::%loop-index%}% &eSC||&7Vendeur: &6%{hdv.name::%loop-index%}%" to close then run function buy({_p}, "%{hdv.name::%loop-index%}%", loop-index)
				add 1 to {_slot}
				add 1 to {_id}
			if {_slot} = (36*{_i}):
				exit loop

J'ai rajouter une condition pour savoir si le nombre d'item dans l'HDV est supérieur a {_page}*36 tu pourra changer de page, or si c'est pas le cas tu ne pourra pas

Modifié par LeCraftDeOuf
  • 0
Posté(e)
il y a 11 minutes, LeCraftDeOuf a dit :

Bonsoir ! D'accord, je prend en compte : Essaye ceci :


function guihdv(p: player, page: number):
	set {_startpage} to {_page}*36
	
	set {_i} to 1
	set {_slot} to 0
	set {_id} to 1
	open virtual chest inventory with size 6 named "&7» &6Hôtel des ventes &e##%{_page}%" to {_p}
	# Blanc
	make a gui slot 36 of {_p} with stained glass pane:0 named " " to do nothing
	make a gui slot 38 of {_p} with stained glass pane:0 named " " to do nothing
	make a gui slot 40 of {_p} with stained glass pane:0 named " " to do nothing
	make a gui slot 42 of {_p} with stained glass pane:0 named " " to do nothing
	make a gui slot 44 of {_p} with stained glass pane:0 named " " to do nothing
	# Cyan
	make a gui slot 37 of {_p} with red stained glass pane named " " to do nothing
	make a gui slot 39 of {_p} with red stained glass pane named " " to do nothing
	make a gui slot 41 of {_p} with red stained glass pane named " " to do nothing
	make a gui slot 43 of {_p} with red stained glass pane named " " to do nothing
	if {_page} = 0:
		make a gui slot 48 of {_p} with paper named "&7<--" to do nothing
	else:
		make a gui slot 48 of {_p} with paper named "&7<--" to run function guihdv({_p}, ({_page} - 1))
	make a gui slot 49 of {_p} with sunflower named "&6Rafraîchir" to run function guihdv({_p}, {_page})
	if size of {hdv.item::*} > {_page}*36
		make a gui slot 50 of {_p} with paper named "&7-->" to run function guihdv({_p}, ({_page} + 1))
	else:
		make a gui slot 50 of {_p} with paper named "&7-->" to do nothing
	wait 1 ticks
	loop {hdv.item::*}:
		if loop-index parsed as a number > {_startpage}:
			if {hdv.name::%loop-index%} is "%{_p}%":
				make a gui slot {_slot} of {_p} with {hdv.item::%loop-index%} with lore "&7ID: &6%{_id}%||&7Prix: &6%{hdv.prix::%loop-index%}% &eSC||&7Vendeur: &6%{hdv.name::%loop-index%}%||||&aClique ici pour retirer l'objet." to close then run function remove({_p}, loop-index)
				add 1 to {_slot}
				add 1 to {_id}
			else:
				make a gui slot {_slot} of {_p} with {hdv.item::%loop-index%} with lore "&7ID: &6%{_id}%||&7Prix: &6%{hdv.prix::%loop-index%}% &eSC||&7Vendeur: &6%{hdv.name::%loop-index%}%" to close then run function buy({_p}, "%{hdv.name::%loop-index%}%", loop-index)
				add 1 to {_slot}
				add 1 to {_id}
			if {_slot} = (36*{_i}):
				exit loop

J'ai rajouter une condition pour savoir si le nombre d'item dans l'HDV est supérieur a {_page}*36 tu pourra changer de page, or si c'est pas le cas tu ne pourra pas

 

Problème résolu,merci de ton aide!

Invité
Ce sujet ne peut plus recevoir de nouvelles réponses.
×
×
  • Créer...

Information importante

Nous avons placé des cookies sur votre appareil pour aider à améliorer ce site. Vous pouvez choisir d’ajuster vos paramètres de cookie, sinon nous supposerons que vous êtes d’accord pour continuer.