#is it possible to add cooldown to buttons in actionforms?
1 messages · Page 1 of 1 (latest)
explain more
I think what they mean is that they want it so that in a ui form that you can press a button like only one every 12 hours or something
hmm
@proper bobcat im working on something rn
Yes it's possible
@proper bobcat here is a script, it had a cool down of 10 mins, if you want to change it use a tick calculator, if you want to reset your cooldown do /scoreboard players set @s CoolDown 11999
import { ActionFormData } from "@minecraft/server-ui"
import { world, system } from "@minecraft/server"
class CoolCooldown {
CoolDownForm(player) {
const form = new ActionFormData()
.button("CoolButton To Cool Thing")
form.show(player).then((data) => {
if (data.selection === 0) {
if (!player.hasTag("CoolDown")) {
this.AwesomeThing(player)
system.runTimeout(() => {
player.addTag("CoolDown")
}, 5)
} else if (player.hasTag("CoolDown")) {
return this.CoolDownWarning(player)
}
}
})
}
CoolDownWarning(player) {
const form = new ActionFormData()
.body("You Have Used This Button, You Can Use It Again In 10 Mins From When You Clicked The Button\n\n\n\n\n\n")
.button("Return")
form.show(player).then((data) => {
if (data.selection === 0) {
return this.CoolDownForm(player)
}
})
}
AwesomeThing(player) {
const form = new ActionFormData()
.button("CoolTest")
.button("back")
form.show(player).then((data) => {
if (data.selection === 1)
return this.CoolDownForm(player)
})
}
}
export const CoolDown = new CoolCooldown
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
if (player.hasTag("CoolDown")) {
const Score = world.scoreboard.getObjective("CoolDown")
player.runCommandAsync("scoreboard players add @s CoolDown 1")
if (Score.getScore(player) == 12000) {
Score.setScore(player, 0)
player.removeTag("CoolDown")
}
}
}
}, 1)
if you want to edit the time use this
https://mapmaking.fr/tick/
Thanks!
I appreciate that
Got it solved by Dead
Np, remeber you can make help post in the library to! I almost didn't see this XD
Ahahah got ya
Now I'll go combine the scripts ;-;
Thanks and cya
@brave frigate does it work if player is offline?
Also this question ^
should i combine my into yours or yours into mine as im new at scripting
@brave frigate
Also how does your form open with custom commands
Cuz I don't do much of scripting
Sorry I was asleep
Can you plz tell the above answers
Ty
import { ActionFormData } from "@minecraft/server-ui"
import { world, system } from "@minecraft/server"
class CoolCooldown {
CoolDownForm(player) {
const form = new ActionFormData()
.button("CoolButton To Cool Thing")
form.show(player).then((data) => {
if (data.selection === 0) {
if (!player.hasTag("CoolDown")) {
this.AwesomeThing(player)
system.runTimeout(() => {
player.addTag("CoolDown")
}, 5)
} else if (player.hasTag("CoolDown")) {
return this.CoolDownWarning(player)
}
}
})
}
CoolDownWarning(player) {
const form = new ActionFormData()
.body("You Have Used This Button, You Can Use It Again In 10 Mins From When You Clicked The Button\n\n\n\n\n\n")
.button("Return")
form.show(player).then((data) => {
if (data.selection === 0) {
return this.CoolDownForm(player)
}
})
}
AwesomeThing(player) {
const form = new ActionFormData()
.button("CoolTest")
.button("back")
form.show(player).then((data) => {
if (data.selection === 1)
return this.CoolDownForm(player)
})
}
}
export const CoolDown = new CoolCooldown
world.beforeEvents.chatSend.subscribe((eventData) => {
const player = eventData.sender;
if (eventData.message === "-test") {
eventData.cancel = true;
system.run(() => {
CoolDown.CoolDownForm(player);
})
}
})
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
if (player.hasTag("CoolDown")) {
const Score = world.scoreboard.getObjective("CoolDown")
player.runCommandAsync("scoreboard players add @s CoolDown 1")
if (Score.getScore(player) == 12000) {
Score.setScore(player, 0)
player.removeTag("CoolDown")
}
}
}
}, 1)```