Ir para conteúdo

Delay


RatoFino

Posts Recomendados

on enable:
	load yaml "plugins/ComandoDelay/data.yml" as "delay_data"
	load yaml "plugins/ComandoDelay/config.yml" as "delay_config"
	if yaml "delay_config" is empty:
		set yaml value "Delay.Tempo" from "delay_config" to 300
		set yaml value "Delay.Mensagem" from "delay_config" to "Aguarde @tempo para usar esse comando novamente"
		set the comments of yaml node "Delay" from "delay_config" to "por favor no delay dos comandos insira o tempo em segundos."
		save yaml "delay_config"
	send "" to console
	send "&fSrDelay - &aAtivado" to console
	send "&fAutor: &eSrBlecaute" to console
	send "" to console

on disable:
	unload yaml "delay_config"
	unload yaml "delay_data"

on command:
	if player is not console:
		if player does not have permission "cmd.bypass":
			if checkDelay(player) is true:
				cancel event
				stop	
			else:
				set yaml value "Cooldown.%player%" from "delay_data" to now
				save yaml "delay_data"

function checkDelay(p: player) :: boolean:
	if yaml path "Cooldown.%{_p}%" from "delay_data" exists:
		set {_timex} to yaml value "Cooldown.%{_p}%" from "delay_data"
		set {_timex} to "%{_timex}%" parsed as time
		set {_check} to difference between {_timex} and now
		set {_delay} to yaml value "Delay.Tempo" from "delay_config"
		set {_delay} to "%{_delay}% seconds" parsed as timespan
		if {_check} is less than {_delay}:
			set {_remaining} to "%difference between {_check} and {_delay}%"
			set {_formated_time} to ReplaceTime({_remaining})
			set {_erro1} to yaml value "Delay.Mensagem" from "delay_config"
			replace all "@tempo" in {_erro1} with "%{_formated_time}%"
			send colored "%{_erro1}%" to {_p}
			return true
		else:
			return false
	else:
		return false

function ReplaceTime(var: text) :: text:
	replace all "and" in {_var} with "e"
	replace all "seconds" in {_var} with "segundos"
	replace all "second" in {_var} with "segundo"
	replace all "minute" in {_var} with "minuto"
	replace all "minutes" in {_var} with "minutos"
	replace all "hour" in {_var} with "hora"
	replace all "hours" in {_var} with "horas"
	replace all "day" in {_var} with "dia"
	replace all "days" in {_var} with "dias"
	return {_var}
			

bom fiz isso agora usei uma parte do meu código antigo
necessita de skript-yaml e de SkQuery
se der erro add discord SrBlecaute#3731 que eu tento ajudar
 

Editado por SrBlecaute
Link para o comentário
Compartilhar em outros sites

1 hora atrás, SrBlecaute disse:

on enable:
	load yaml "plugins/ComandoDelay/data.yml" as "delay_data"
	load yaml "plugins/ComandoDelay/config.yml" as "delay_config"
	if yaml "delay_config" is empty:
		set yaml value "Delay.Tempo" from "delay_config" to 300
		set yaml value "Delay.Mensagem" from "delay_config" to "Aguarde @tempo para usar esse comando novamente"
		set the comments of yaml node "Delay" from "delay_config" to "por favor no delay dos comandos insira o tempo em segundos."
		save yaml "delay_config"
	send "" to console
	send "&fSrDelay - &aAtivado" to console
	send "&fAutor: &eSrBlecaute" to console
	send "" to console

on disable:
	unload yaml "delay_config"
	unload yaml "delay_data"

on command:
	if player is not console:
		if player does not have permission "cmd.bypass":
			if checkDelay(player) is true:
				cancel event
				stop	
			else:
				set yaml value "Cooldown.%player%" from "delay_data" to now
				save yaml "delay_data"

function checkDelay(p: player) :: boolean:
	if yaml path "Cooldown.%{_p}%" from "delay_data" exists:
		set {_timex} to yaml value "Cooldown.%{_p}%" from "delay_data"
		set {_timex} to "%{_timex}%" parsed as time
		set {_check} to difference between {_timex} and now
		set {_delay} to yaml value "Delay.Tempo" from "delay_config"
		set {_delay} to "%{_delay}% seconds" parsed as timespan
		if {_check} is less than {_delay}:
			set {_remaining} to "%difference between {_check} and {_delay}%"
			set {_formated_time} to ReplaceTime({_remaining})
			set {_erro1} to yaml value "Delay.Mensagem" from "delay_config"
			replace all "@tempo" in {_erro1} with "%{_formated_time}%"
			send colored "%{_erro1}%" to {_p}
			return true
		else:
			return false
	else:
		return false

function ReplaceTime(var: text) :: text:
	replace all "and" in {_var} with "e"
	replace all "seconds" in {_var} with "segundos"
	replace all "second" in {_var} with "segundo"
	replace all "minute" in {_var} with "minuto"
	replace all "minutes" in {_var} with "minutos"
	replace all "hour" in {_var} with "hora"
	replace all "hours" in {_var} with "horas"
	replace all "day" in {_var} with "dia"
	replace all "days" in {_var} with "dias"
	return {_var}
			

bom fiz isso agora usei uma parte do meu código antigo
necessita de skript-yaml e de SkQuery
se der erro add discord SrBlecaute#3731 que eu tento ajudar
 

Quero um mais simples...

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...