Aller au contenu

[Survie]Coffre qui spawn aléatoirement dans une zone choisi


Messages recommandés

Posté(e) (modifié)

Bonjour, aujourd'hui je vous appel à l'aide pour la création d'un skript je pense réalisable 🙂

Version de Minecraft : 1.11.2

Version de Skript : 2.3.6

Type du Skript : Coffre aléatoire

Je vais commencer par vous mettre dans le contexte de réalisation de ce skript :

Nous sommes sur un serveur survie, nous voudrions rajouté des éléments qui permettront de rajouter plus de "fun", nous avons donc pensé qu'un coffre qui spawnerai dans une zone choisi au préalable par nos soins avec un contenu aussi choisi par nos soins serait une bonne idée ! Je voudrais donc que ce skript fasse ceci :

  • Un coffre qui spawn aléatoirement dans une zone choisi ( Par World Edit ou autre à vous de voir comment choisir cette zone)
  • Ce coffre doit spawn au sol et non pas en l'air ou sous terre
  • Il doit spawn tout les "x" temps si et seulement si plus de 2 joueurs sont connecté
  • Son contenu doit pouvoir être choisi par nos soins (Par une commande ou directement changeable dans le skript)
  • Un message doit annoncer les coordonnées du coffre*
  • Une commande pour pouvoir faire spawner de force le coffre (/coffre ou autre avec une permission de préférence, execute.command.coffre ou autre)
  • Si c'est aussi possible j'aimerai que tout les joueurs soit tp a 300 blocks autour du coffre 😃

Voila je crois n'avoir rien oublié je vous remercie d'avoir lu et remercie d'avance à la personne qui voudra bien crée ce skript pour moi ! 😃

Modifié par KacilioE
Posté(e)
options:
	monde: world
	message_sans_permission: Tu n'a pas la permission !
	All: 49
	Common: 35
	Rare: 10
	Rare+: 5
	Rare++: 1
	rayon: 10
	timing: 20
		
command /coffrealéatoire <string>:
	trigger:
		if arg-1 is "baton":
			if player is op:
				give 1 stick named "&4&lBaton de zone" to player
		if arg-1 is "coffre":	
			if player is op:
				set {_r} to 1
				while {_r} = 1:
					set {_randomx} to a random integer between {xpost1} and {xpost2}
					set {_randomz} to a random integer between {zpost1} and {zpost2}
					set {_y} to 40
					while {_y} is not 100:
						if block at location ({_randomx}, {_y}, {_randomz}) is air or tall grass:
							if block under block at location ({_randomx}, {_y}, {_randomz}) is not air or water or lava or trapped chest:
								if block above block at location ({_randomx}, {_y}, {_randomz}) is air:
									set {_reely} to {_y}
									set {_y} to 99
									set {_r} to 0
						add 1 to {_y}
				set block at location ({_randomx}, {_reely}, {_randomz}) to chest
				add {_randomx} to {xchest::*}
				add {_randomz} to {zchest::*}
				wait 1 tick
				delete {chance::*}
				delete {chance.All::*}
				delete {chance.Common::*}
				delete {chance.Rare::*}
				delete {chance.Rare+::*}
				delete {chance.Rare++::*}
				loop {@All} times:
					add "All" to {chance::*}
				loop {@Common} times:
					add "Common" to {chance::*}
				loop  {@Rare} times:
					add "Rare" to {chance::*}
				loop  {@Rare+} times:
					add "Rare+" to {chance::*}
				loop  {@Rare++} times:
					add "Rare++" to {chance::*}
				add "32 stone:&8Ultra Commun" to {chance.All::*}
				add "32 dirt:&8Ultra Commun" to {chance.All::*}
				add "leather chestplate:&aCommun" to {chance.Common::*}
				add "stone sword:&aCommun" to {chance.Common::*}
				add "iron sword:&bRare" to {chance.Rare::*}
				add "golden chestplate:&bRare" to {chance.Rare::*}
				add "diamond sword of sharpness 2:&5Rare+" to {chance.Rare+::*}
				add "iron chestplate:&5Rare+" to {chance.Rare+::*}
				add "diamond chestplate of protection 2:&6Rare++" to {chance.Rare++::*} 
				delete {slot::*}
				set {n} to 0
				loop 26 times:
					add {n} to {slot::*}
					add 1 to {n}
				set {l} to a random integer between 1 and 6
				loop {l} times:
					set {c} to a random element of {chance::*}
					set {i} to a random element of {chance.%{c}%::*}
					set {_bp::*} to {i} split at ":"
					set {_b} to {_bp::1}
					set {_b} to {_b} parsed as item type
					set {_p} to {_bp::2}
					set {n} to a random element of {slot::*}
					remove {n} from {slot::*}
					set slot {n} of inventory of block at location ({_randomx}, {_reely}, {_randomz}) to {_b} named "%{_p}%"
				broadcast "creation du coffre en x : %{_randomx}% y : %{_reely}% z : %{_randomz}% "
				loop all players:
					if gamemode of loop-player is survival:
						if distance between loop-player's location and location ({_randomx}, {_reely}, {_randomz}) > 10:
							message "-----------------------------------------------------" to loop-player
							message "&6un coffre est apparu &7x : %{_randomx}% y : %{_reely}% z : %{_randomz}%" to loop-player
							message "<tooltip:Téléportation à {@rayon} blocks du coffre><command:/coffrealéatoire tp>&2[Se téléporter]<reset>" to loop-player
							message "-----------------------------------------------------" to loop-player
		if arg-1 is "tp":
			set {_n} to size of {xchest::*}
			set {_randomx} to {xchest::%{_n}%}
			set {_randomz} to {zchest::%{_n}%}
			broadcast "%{_randomx}% %{_randomz}%"
			set {_rc} to {@rayon} * {@rayon}
			broadcast "r = %{_rc}%"
			set {_sqrtrc} to sqrt of {_rc}
			broadcast "r root = %{_sqrtrc}%"
			set {_x} to a random number between {_randomx} - {_sqrtrc} and {_randomx} + {_sqrtrc}
			set {_zc} to {_x} * {_x} - 2 * {_randomx} * {_x} + {_randomx} * {_randomx}
			set {_rc} to {@rayon} * {@rayon}
			set {_z} to {_rc} - {_zc}
			broadcast "%{_z}%"
			set {_z} to sqrt of {_z}
			set {_opp} to a random integer between 0 and 1
			if {_opp} = 0:
				set {_z} to {_randomz} + {_z}
			if {_opp} = 1:
				set {_z} to {_randomz} - {_z}
			set {%player%.nodamagechute} to 1
			teleport player at location ({_x}, 100, {_z})
		if arg-1 is "on":
			set {auto} to 1
		if arg-1 is "off":
			set {auto} to 0
		if arg-1 is "reset":
			delete {xchest::*}
			delete {zchest::*}
	
on damage:
	if {%victim%.nodamagechute} = 1:
		if damage cause is fall:
			cancel event
			set {%victim%.nodamagechute} to 0
			
every {@timing} seconds:
	set {_r} to 1
	if 1 = {auto}:
		if 3 = 3:
			if 2 = 2: 
				while {_r} = 1:
					set {_randomx} to a random integer between {xpost1} and {xpost2}
					set {_randomz} to a random integer between {zpost1} and {zpost2}
					set {_y} to 40
					while {_y} is not 100:
						if block at location ({_randomx}, {_y}, {_randomz}) in world "{@monde}" is air or tall grass:
							if block under block at location ({_randomx}, {_y}, {_randomz}) in world "{@monde}" is not air or water or lava or chest or trapped chest:
								if block above block at location ({_randomx}, {_y}, {_randomz}) in world "{@monde}" is air:
									set {_reely} to {_y}
									set {_y} to 99
									set {_r} to 0
						add 1 to {_y}
				set block at location ({_randomx}, {_reely}, {_randomz}) in world "{@monde}" to chest
				add {_randomx} to {xchest::*}
				add {_randomz} to {zchest::*}
				wait 1 tick
				delete {chance::*}
				delete {chance.All::*}
				delete {chance.Common::*}
				delete {chance.Rare::*}
				delete {chance.Rare+::*}
				delete {chance.Rare++::*}
				loop {@All} times:
					add "All" to {chance::*}
				loop {@Common} times:
					add "Common" to {chance::*}
				loop  {@Rare} times:
					add "Rare" to {chance::*}
				loop  {@Rare+} times:
					add "Rare+" to {chance::*}
				loop  {@Rare++} times:
					add "Rare++" to {chance::*}
				add "32 stone:&8Ultra Commun" to {chance.All::*}
				add "32 dirt:&8Ultra Commun" to {chance.All::*}
				add "leather chestplate:&aCommun" to {chance.Common::*}
				add "stone sword:&aCommun" to {chance.Common::*}
				add "iron sword:&bRare" to {chance.Rare::*}
				add "golden chestplate:&bRare" to {chance.Rare::*}
				add "diamond sword of sharpness 2:&5Rare+" to {chance.Rare+::*}
				add "iron chestplate:&5Rare+" to {chance.Rare+::*}
				add "diamond chestplate of protection 2:&6Rare++" to {chance.Rare++::*} 
				delete {slot::*}
				set {n} to 0
				loop 26 times:
					add {n} to {slot::*}
					add 1 to {n}
				set {l} to a random integer between 1 and 6
				loop {l} times:
					set {c} to a random element of {chance::*}
					set {i} to a random element of {chance.%{c}%::*}
					set {_bp::*} to {i} split at ":"
					set {_b} to {_bp::1}
					set {_b} to {_b} parsed as item type
					set {_p} to {_bp::2}
					set {n} to a random element of {slot::*}
					remove {n} from {slot::*}
					set slot {n} of inventory of block at location ({_randomx}, {_reely}, {_randomz}) in world "{@monde}" to {_b} named "%{_p}%"
				loop all players:
					if gamemode of loop-player is survival:
						if distance between loop-player's location and location ({_randomx}, {_reely}, {_randomz}) in world "{@monde}" > 10:
							message "-----------------------------------------------------" to loop-player
							message "&6un coffre est apparu &7x : %{_randomx}% y : %{_reely}% z : %{_randomz}%" to loop-player
							message "<tooltip:Téléportation à {@rayon} blocks du coffre><command:/coffrealéatoire tp>&2[Se téléporter]<reset>" to loop-player
							message "-----------------------------------------------------" to loop-player
	
								
				
on break:
	if gamemode of player is creative:
		if player's tool is a stick named "&4&lBaton de zone":
			cancel event
			set {zpost1} to z-coordinate of location of block
			set {xpost1} to x-coordinate of location of block
			broadcast "Les coordonée ont bien été prise en compte"
			
on rightclick:
	if clicked block is set:
		if gamemode of player is creative:
			if player's tool is a stick named "&4&lBaton de zone":
				set {zpost2} to z-coordinate of location of block
				set {xpost2} to x-coordinate of location of block
				broadcast "Les coordonée ont bien été prise en compte"
		

 

  • Merci 1
Posté(e)
Le 19/05/2019 à 16:00, geforce a dit :

options:
	monde: world
	message_sans_permission: Tu n'a pas la permission !
	All: 49
	Common: 35
	Rare: 10
	Rare+: 5
	Rare++: 1
	rayon: 10
	timing: 20
		
command /coffrealéatoire <string>:
	trigger:
		if arg-1 is "baton":
			if player is op:
				give 1 stick named "&4&lBaton de zone" to player
		if arg-1 is "coffre":	
			if player is op:
				set {_r} to 1
				while {_r} = 1:
					set {_randomx} to a random integer between {xpost1} and {xpost2}
					set {_randomz} to a random integer between {zpost1} and {zpost2}
					set {_y} to 40
					while {_y} is not 100:
						if block at location ({_randomx}, {_y}, {_randomz}) is air or tall grass:
							if block under block at location ({_randomx}, {_y}, {_randomz}) is not air or water or lava or trapped chest:
								if block above block at location ({_randomx}, {_y}, {_randomz}) is air:
									set {_reely} to {_y}
									set {_y} to 99
									set {_r} to 0
						add 1 to {_y}
				set block at location ({_randomx}, {_reely}, {_randomz}) to chest
				add {_randomx} to {xchest::*}
				add {_randomz} to {zchest::*}
				wait 1 tick
				delete {chance::*}
				delete {chance.All::*}
				delete {chance.Common::*}
				delete {chance.Rare::*}
				delete {chance.Rare+::*}
				delete {chance.Rare++::*}
				loop {@All} times:
					add "All" to {chance::*}
				loop {@Common} times:
					add "Common" to {chance::*}
				loop  {@Rare} times:
					add "Rare" to {chance::*}
				loop  {@Rare+} times:
					add "Rare+" to {chance::*}
				loop  {@Rare++} times:
					add "Rare++" to {chance::*}
				add "32 stone:&8Ultra Commun" to {chance.All::*}
				add "32 dirt:&8Ultra Commun" to {chance.All::*}
				add "leather chestplate:&aCommun" to {chance.Common::*}
				add "stone sword:&aCommun" to {chance.Common::*}
				add "iron sword:&bRare" to {chance.Rare::*}
				add "golden chestplate:&bRare" to {chance.Rare::*}
				add "diamond sword of sharpness 2:&5Rare+" to {chance.Rare+::*}
				add "iron chestplate:&5Rare+" to {chance.Rare+::*}
				add "diamond chestplate of protection 2:&6Rare++" to {chance.Rare++::*} 
				delete {slot::*}
				set {n} to 0
				loop 26 times:
					add {n} to {slot::*}
					add 1 to {n}
				set {l} to a random integer between 1 and 6
				loop {l} times:
					set {c} to a random element of {chance::*}
					set {i} to a random element of {chance.%{c}%::*}
					set {_bp::*} to {i} split at ":"
					set {_b} to {_bp::1}
					set {_b} to {_b} parsed as item type
					set {_p} to {_bp::2}
					set {n} to a random element of {slot::*}
					remove {n} from {slot::*}
					set slot {n} of inventory of block at location ({_randomx}, {_reely}, {_randomz}) to {_b} named "%{_p}%"
				broadcast "creation du coffre en x : %{_randomx}% y : %{_reely}% z : %{_randomz}% "
				loop all players:
					if gamemode of loop-player is survival:
						if distance between loop-player's location and location ({_randomx}, {_reely}, {_randomz}) > 10:
							message "-----------------------------------------------------" to loop-player
							message "&6un coffre est apparu &7x : %{_randomx}% y : %{_reely}% z : %{_randomz}%" to loop-player
							message "<tooltip:Téléportation à {@rayon} blocks du coffre><command:/coffrealéatoire tp>&2[Se téléporter]<reset>" to loop-player
							message "-----------------------------------------------------" to loop-player
		if arg-1 is "tp":
			set {_n} to size of {xchest::*}
			set {_randomx} to {xchest::%{_n}%}
			set {_randomz} to {zchest::%{_n}%}
			broadcast "%{_randomx}% %{_randomz}%"
			set {_rc} to {@rayon} * {@rayon}
			broadcast "r = %{_rc}%"
			set {_sqrtrc} to sqrt of {_rc}
			broadcast "r root = %{_sqrtrc}%"
			set {_x} to a random number between {_randomx} - {_sqrtrc} and {_randomx} + {_sqrtrc}
			set {_zc} to {_x} * {_x} - 2 * {_randomx} * {_x} + {_randomx} * {_randomx}
			set {_rc} to {@rayon} * {@rayon}
			set {_z} to {_rc} - {_zc}
			broadcast "%{_z}%"
			set {_z} to sqrt of {_z}
			set {_opp} to a random integer between 0 and 1
			if {_opp} = 0:
				set {_z} to {_randomz} + {_z}
			if {_opp} = 1:
				set {_z} to {_randomz} - {_z}
			set {%player%.nodamagechute} to 1
			teleport player at location ({_x}, 100, {_z})
		if arg-1 is "on":
			set {auto} to 1
		if arg-1 is "off":
			set {auto} to 0
		if arg-1 is "reset":
			delete {xchest::*}
			delete {zchest::*}
	
on damage:
	if {%victim%.nodamagechute} = 1:
		if damage cause is fall:
			cancel event
			set {%victim%.nodamagechute} to 0
			
every {@timing} seconds:
	set {_r} to 1
	if 1 = {auto}:
		if 3 = 3:
			if 2 = 2: 
				while {_r} = 1:
					set {_randomx} to a random integer between {xpost1} and {xpost2}
					set {_randomz} to a random integer between {zpost1} and {zpost2}
					set {_y} to 40
					while {_y} is not 100:
						if block at location ({_randomx}, {_y}, {_randomz}) in world "{@monde}" is air or tall grass:
							if block under block at location ({_randomx}, {_y}, {_randomz}) in world "{@monde}" is not air or water or lava or chest or trapped chest:
								if block above block at location ({_randomx}, {_y}, {_randomz}) in world "{@monde}" is air:
									set {_reely} to {_y}
									set {_y} to 99
									set {_r} to 0
						add 1 to {_y}
				set block at location ({_randomx}, {_reely}, {_randomz}) in world "{@monde}" to chest
				add {_randomx} to {xchest::*}
				add {_randomz} to {zchest::*}
				wait 1 tick
				delete {chance::*}
				delete {chance.All::*}
				delete {chance.Common::*}
				delete {chance.Rare::*}
				delete {chance.Rare+::*}
				delete {chance.Rare++::*}
				loop {@All} times:
					add "All" to {chance::*}
				loop {@Common} times:
					add "Common" to {chance::*}
				loop  {@Rare} times:
					add "Rare" to {chance::*}
				loop  {@Rare+} times:
					add "Rare+" to {chance::*}
				loop  {@Rare++} times:
					add "Rare++" to {chance::*}
				add "32 stone:&8Ultra Commun" to {chance.All::*}
				add "32 dirt:&8Ultra Commun" to {chance.All::*}
				add "leather chestplate:&aCommun" to {chance.Common::*}
				add "stone sword:&aCommun" to {chance.Common::*}
				add "iron sword:&bRare" to {chance.Rare::*}
				add "golden chestplate:&bRare" to {chance.Rare::*}
				add "diamond sword of sharpness 2:&5Rare+" to {chance.Rare+::*}
				add "iron chestplate:&5Rare+" to {chance.Rare+::*}
				add "diamond chestplate of protection 2:&6Rare++" to {chance.Rare++::*} 
				delete {slot::*}
				set {n} to 0
				loop 26 times:
					add {n} to {slot::*}
					add 1 to {n}
				set {l} to a random integer between 1 and 6
				loop {l} times:
					set {c} to a random element of {chance::*}
					set {i} to a random element of {chance.%{c}%::*}
					set {_bp::*} to {i} split at ":"
					set {_b} to {_bp::1}
					set {_b} to {_b} parsed as item type
					set {_p} to {_bp::2}
					set {n} to a random element of {slot::*}
					remove {n} from {slot::*}
					set slot {n} of inventory of block at location ({_randomx}, {_reely}, {_randomz}) in world "{@monde}" to {_b} named "%{_p}%"
				loop all players:
					if gamemode of loop-player is survival:
						if distance between loop-player's location and location ({_randomx}, {_reely}, {_randomz}) in world "{@monde}" > 10:
							message "-----------------------------------------------------" to loop-player
							message "&6un coffre est apparu &7x : %{_randomx}% y : %{_reely}% z : %{_randomz}%" to loop-player
							message "<tooltip:Téléportation à {@rayon} blocks du coffre><command:/coffrealéatoire tp>&2[Se téléporter]<reset>" to loop-player
							message "-----------------------------------------------------" to loop-player
	
								
				
on break:
	if gamemode of player is creative:
		if player's tool is a stick named "&4&lBaton de zone":
			cancel event
			set {zpost1} to z-coordinate of location of block
			set {xpost1} to x-coordinate of location of block
			broadcast "Les coordonée ont bien été prise en compte"
			
on rightclick:
	if clicked block is set:
		if gamemode of player is creative:
			if player's tool is a stick named "&4&lBaton de zone":
				set {zpost2} to z-coordinate of location of block
				set {xpost2} to x-coordinate of location of block
				broadcast "Les coordonée ont bien été prise en compte"
		

 

Voila alors après test j'ai rencontrer 3 erreurs les voici

EWZFRK7.png

Si quelqu'un pourrait me les corriger ça serait vraiment cool, je vois pas trop à quoi elles sont dues ^^ 😃

Posté(e)
il y a 11 minutes, geforce a dit :

il te faut l'addon skquery car la fonction racine carrée n'existe pas sur le skript de base.

D'ac merci et la troisième c'étais juste les espaces tout en bas du skript x) Merci bcp !

Posté(e) (modifié)
Il y a 11 heures, Acenox a dit :

Bonjour,

Merci de mettre le topic en "Résolu" si tu n'as pas d'autres problèmes.

Cordialement,

Malheureusement pour moi j'ai encore un problème c'est que le skript ne marche pas.

 

Il y a 13 heures, geforce a dit :

il te faut l'addon skquery car la fonction racine carrée n'existe pas sur le skript de base.

Comme je l'ai dit et j'en suis désolé ton skript ne fonctionne pas j'ai beau faire les commandes /coffrealéatoire coffre/tp/on/off/baton à apart le "tp" qui me tp en 1000 100 ou un truc dans le genre les autres commandes ne font absolument rien j'ai essayé de me débrouillé tout seul pour ne plus t’embêter mais rien à faire je n'y arrive pas ^^

Alors si tu sais quoi faire, ça serait cool que tu puisse réglé cela.

Merci d'avance Kacilio.

Modifié par KacilioE
Oubli du merci ^^
Posté(e) (modifié)

Malheureusement, j'aurais du mal à discerner ton problème car sur mon serveur minecraft, le skript fonctionne correctement. D'après ce que j'ai compris dans les messages précédents, tu as réussi à enlever les erreurs dans le skript reload. Donc, à priori, l'erreur ne vient pas du skript. En sachant, cela, deux choses sont à faire dans un premier lire attentivement le mode d'emploie du skript (assez succin).

D'abord, soit sûre que tu es bien "op" sur le serveur où tu as mis le skript. La seule commande qui fonctionne d'après tes dires "le /coffrealéatoire tp" ne nécessite pas d'être op

1) fait /coffrealétoire baton. Un baton va être donné ton inventaire. Celui-ci permet de définir une zone dans laquelle les coffres vont apparaître. La définition de la zone fonctionne de la même manière que worledit (il faut donc être en gamemode 1). Clique droit un bloc à l'angle de la zone, puis clique gauche sur un bloc à l'angle opposé de la zone.

2) fait /coffrealéatoire coffre. Il fait spawn un coffre aléatoirement dans la zone établie précédemment. Attention bien vérifier dans les options que le nom monde est bien celui du monde de ton serveur.

3) fait /coffrealéatoire tp pour te rendre aux alentours du coffre qui est apparu (plus précisément à longueur défini dans les options sous le nom de rayon). Une autre méthode pour se téléporter consiste à être en mode survival lorsque la command "/coffrealétoire coffre" est tapée. Un message avec les coordonnée exacte du coffre et un message json pour s'y téléporter. Il suffit donc juste de cliquer sur [se téléporter].

4) fait /coffrealéatoire on pour lancer l’apparition automatique de coffres à intervalle (à définir dans les options sous le nom de timing).

5) fait /coffrealétoire off pour arrêter l’apparition automatique de coffres à intervalle.

Si jamais l'erreur persiste ajoute moi sur discord geforce07#7453

  

Modifié par geforce
Posté(e)
il y a 3 minutes, KacilioE a dit :

Ok bah j'ai testé sur mon serveur le skript fait crash dès que je le m'ai, j'ai donc tenter sur un serveur vierge juste avec le plugin skript et l'addon et pareil ça crash, je t'ai rajouté sur discord pour voir ça.

Merci, Kacilio.

Bon enfaîte c'est bon tout marche niquel c'est moi qui devait faire un truc pas bien parce que j'ai copié collé le fichier dans un exemple de skript fait pas le plugin lors

de l'installation initiale et j'ai enlever le tiret pour qu'il soit actif et ton skript marchait ! 

Par contre du-coup je suis pas doué je vois pas pourquoi quand c'est moi qui crée le fichier ça ne marchait pas.

Merci de ton aide !

Posté(e)

Bonsoir,

Le problème étant résolu, Je lock.

Si tu souhaites rouvrir le topic, n'hésite pas à me contacter en message privé.

Bonne soirée !

  • Joriis a verrouillé ce sujet
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.