Aller au contenu

Messages recommandés

Posté(e)

Version de Minecraft : 1.8.8
Version de Skript : 2.6.4

Type du skript : Goulag

Description du script :

Un goulag comme sur warzone, quelqu'un meurt ça le téléporte dans {spawn.goulag} en attente d'un autre joueur à combattre, une fois la il se battent avec un batton sharpness 2 le vainqueur récupere 50% de son stuff avant la mort et le perdant repart bredouille

function goulagHelp(p: player):
	send "" to {_p}
	send "{@prefix} &fPage d'&eaide" to {_p}
	send "&8| &f/goulag &7[&fon&7/&foff&7|&fsetspawn&7|&fhelp&7] &7(&f1&7|&f2&7|&fglobal&7)" to {_p}
	send "" to {_p}

function goulagStart():
	loop all players:
		if {in.goulag.%loop-player%} is true:
			if {ingoulag::*} does not contain loop-player:	
				add loop-player to {ingoulag::*}
	if size of {ingoulag::*} > 1:
		set {_player1} to a random element out of {ingoulag::*}
		remove {_player1} from {ingoulag::*}
		set {_player2} to a random element out of {ingoulag::*}
		remove {_player2} from {ingoulag::*}
		teleport {_player1} to {g.spawn.1}
		teleport {_player2} to {g.spawn.2}
		set {_baton} to stick
		enchant {_baton} with sharpness 1
		give {_player1} 1 of {_baton}
		give {_player2} 1 of {_baton}

command /goulag [<text>] [<text>]:
	permission: h.goulag
	permission message: {@nopermmsg}
	trigger:
		if arg 1 is set:
			if arg 1 is "help":
				goulagHelp(player)
			else:
				if arg 1 is "on":
					if {goulag.enable} is true:
						send "{@prefix} &7Le mode &egoulag &7est déjà &eactivé&7. &e&n/goulag off &7pour le désactiver." to player
					else:
						send "{@prefix} &7Le mode &egoulag&7 a été &eactivé&7." to player
						set {goulag.enable} to true
				else:
					if arg 1 is "off":
						if {goulag.enable} is false:
							send "{@prefix} &7Le mode &egoulag &7est déjà &edésactivé&7. &e&n/goulag on&r &7pour le réactiver." to player
						else:
							send "{@prefix} &7Le mode &egoulag&7 a été &edésactivé&7." to player
							set {goulag.enable} to false
					else:
						if arg 1 is "setspawn":
							if arg 2 is set:
								if arg 2 is "1":
									set {g.spawn.1} to player's location 
									send "{@prefix} &7Le spawn &e1 &7a été &einitialisé&7." to player
								else: 
									if arg 2 is "2":
										set {g.spawn.2} to player's location
										send "{@prefix} &7Le spawn &e2 &7a été &einitialisé&7." to player
									else:
										if arg 2 is "global":
											set {g.spawn.global} to player's location
											send "{@prefix} &7Le spawn &eglobal &7a été &einitialisé&7." to player
										else:	
											send "{@errormsg}" to player
							else:	
								send "{@errormsg}" to player
						else:
							send "{@errormsg}" to player
		else:
			goulagHelp(player)

on damage of player:
	if (victim's health - damage) < 0.1:
		if {goulag.enable} is true:
			if {in.goulag.%victim%} is false:
				cancel event
				set {_SlotNo} to 0
				while {_SlotNo} is less than 40:
					set {Inventaire.%victim%::%{_SlotNo}%} to slot {_SlotNo} of victim
					add 1 to {_SlotNo}
				clear victim's inventory
				send "&8| &fVous avez été envoyé au &egoulag&f." to victim
				send title "&cGoulag" with subtitle "&c&oBonne chance" to victim for 4 seconds 
				send action bar "&cVous êtes au goulag !" to victim
				heal victim
				teleport victim to {g.spawn.global}
				set {in.goulag.%victim%} to true
				goulagStart()
			else:
				teleport victim to {spawn}
				send "&cVous avez perdu le goulag !" to victim
				set {in.goulag.%victim%} to false
				teleport attacker to {spawn}
				send "&8| &fVous avez &eremporté &fle duel." to attacker
				set {in.goulag.%attacker%} to false
				clear attacker's inventory
				while {_SlotNo} is less than 40:
					set {_random} to a random integer between 1 and 2
					if {_random} = 1:
						set slot {_SlotNo} of attacker to {Inventaire.%attacker%::%{_SlotNo}%}
					add 1 to {_SlotNo}
				goulagStart()

on death of player:
	if {in.goulag.%victim%} is true:
		cancel drops of items

on player move:
	if player is in "goulag":
		if {%player%::freezed} is true:
			teleport {_player1} to {g.spawn.1}
			teleport {_player2} to {g.spawn.2}

J'ai déjà commencer ce code mais il bug, des que je met le goulag en on, a la mort dun joueur sa le fais gagner directement, si il prend 1 degats sa clear sont inventaire en gros n'importe quoi il  y a 0 erreur et je n'arrive pas à trouver les causes des problème

Posté(e) (modifié)
Citation

 


command /goulag [<text>] [<text>]:
	permission: h.goulag
	permission message: {@nopermmsg}
	trigger:
		if arg 1 is "help":
			send "&8| &f/goulag &7[&fon&7/&foff&7|&fsetspawn&7|&fhelp&7] &7(&f1&7|&f2&7|&fglobal&7)"
		else if arg 1 is not "on" or "off" or "setspawn" or "global":
			make player execute command "/goulag help"

		if arg 1 is "on":
			if {goulag::enable} is true:
				send "{@prefix} &7Le mode &egoulag &7est déjà &eactivé&7. &e&n/goulag off &7pour le désactiver."
			else:
				send "{@prefix} &7Le mode &egoulag&7 a été &eactivé&7." to player
				set {goulag::enable} to true
		
		if arg 1 is "off":
			if {goulag::enable} is not set:
				send "{@prefix} &7Le mode &egoulag &7est déjà &edésactivé&7. &e&n/goulag on&r &7pour le réactiver." to player
			else:
				send "{@prefix} &7Le mode &egoulag&7 a été &edésactivé&7." to player
				clear {goulag::enable}
		if arg 1 is "setspawn":
			if arg 2 is "1" or "2" or "global":
				send "{@prefix} &7Le spawn &e%arg 2% &7a été &einitialisé&7." to player
				set {goulag::spawn::%arg 2%} to player's location
			else:
				send "{@errormsg}"
			


on damage of player:
	if final damage >= victim's health:
		if {goulag::enable} is true:
			cancel event
			if {goulag::player::%victim%::in_goulag} is not set:
				set {_SlotNo} to 0
				loop all items in the inventory of victim: 
					if loop-item is not air:
						add loop-item to {goulag::player::%victim%::inventaire::*}
				clear victim's inventory
				send "&8| &fVous avez été envoyé au &egoulag&f." to victim
				send title "&cGoulag" with subtitle "&c&oBonne chance" to victim for 4 seconds 
				send action bar "&cVous êtes au goulag !" to victim
				heal victim
				teleport victim to {goulag::spawn::global}
				set {goulag::player::%victim%::in_goulag} to true
				set {_baton} to stick
				enchant {_baton} with sharpness 2
				add victim to {goulag::ingoulag::*}
				if size of {goulag::ingoulag::*} > 1:
					loop 2 times:
						set {_player%loop-value%} to random element of {goulag::ingoulag::*}
						remove {_player%loop-value%} from {goulag::ingoulag::*}
						teleport {_player%loop-value%} to {goulag::spawn::%loop-value%}
						give {_baton} to {_player%loop-value%}
			else:
				teleport victim to {spawn}
				send "&cVous avez perdu le goulag !" to victim
				clear {goulag::player::%victim%::in_goulag}
				teleport attacker to {spawn}
				send "&8| &fVous avez &eremporté &fle duel." to attacker
				clear {goulag::player::%attacker%::in_goulag}
				clear attacker's inventory
				clear victim's inventory
				set {_SlotNo} to 0
				loop {goulag::player::%victim%::inventaire::*}:
					give loop-value to attacker
				clear {goulag::player::%victim%::inventaire::*}

 

Salut, je me permet de corriger ton code et te donner des astuces pour mieux écrire ton code.

Tout d'abord, au lieu d'utiliser les variables avec des points, utilise des listes, ça évite de surcharger tes variables et de mieux optimiser ton code.
Ensuite, les if..else dans ta commande /goulag ne sont pas nécessaire. Un if...so suffit amplement.
Enfin, si ton code ne marchait pas c'est parce que la condition

if {in.goulag.%victim%} is false:

ne marchait pas, en gros la variable {in.goulag.%victim%} était <none> donc il peut pas vérifier si c'est false. Donc je te conseille d'effacer leur valeur après que tu en n'aie plus besoin pour éviter ce genre de problème.

Si tu as d'autres questions, n'hésite pas à me les poser 🙂

 

Modifié par LOUDO
  • 1 mois après...
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.