#how do i define data in this function?
1 messages · Page 1 of 1 (latest)
show err than
i think this function works, but i am not sure how data needs to be defined.
the function may not work and i could be really wrong tho.
function firei(player) {
world.scoreboard.getObjective("Money");
const money = world.scoreboard.getObjective("Money");
const moneyScore = money.getScore(player);
const iprice = 750
const fireitem = new ModalFormData
fireitem.title("§4Buring Breath")
fireitem.slider(`§6Money§r: ${moneyScore}\n§eItem Price§r: ${iprice}\n\n\n\n--------------------------------\n§dTotal§r: ${iprice*formValues}\n\naItem Amount`, 1, 64)
fireitem.show(player).then((data) => {
const formValues = data.formValues
if (player.hasTag('hell')) {
if (moneyScore < iprice*formValues) {
player.runCommandAsync(`give @s blaze_powder 0 ${formValues}`)
}
else if (player.hasTag('hell')) {
if (moneyScore >= iprice*formValues) {
player.runCommandAsync(`scoreboard players remove @s Money ${iprice*formValues}`)
player.playSound('random.orb')
player.sendMessage(`§eYou bought §e${formValues}§4 Buring Breath§e!`)
}
}
}
}
)
}
it wont work
ur accesing formValues before show
i just fixed data issue
but logically ur code is dead
ur accesing something before that happens later
what ur aim is
u save last value then use that
last
fprm()
.slider(last)
on show
last = formValue[0]
let map = new WeakMap()
function firei(player) {
const money = world.scoreboard.getObjective("Money");
const moneyScore = money.getScore(player);
const iprice = 750;
const fireitem = new ModalFormData();
fireitem.title("§4Buring Breath");
let lastValue = map.get(player) || 0
fireitem.slider(
`§6Money§r: ${moneyScore}\n§eItem Price§r: ${iprice}\n--------------------------------\n§dTotal§r: §a$${iprice * lastValue }\n\n§rItem Amount`,
1,
64,
1
);
fireitem.show(player).then((data) => {
const formValues = data.formValues;
map.set(player, formValues[0])
if (player.hasTag('hell')) {
if (moneyScore < iprice * formValues) {
player.sendMessage(`§cYou don't have enough money to buy ${formValues} Buring Breath.`);
} else {
player.runCommandAsync(`scoreboard players remove @s Money ${iprice * formValues}`);
player.playSound('random.orb');
player.sendMessage(`§eYou bought §e${formValues}§4 Buring Breath§e!`);
// Run the structure load command multiple times based on formValues
for (let i = 0; i < formValues; i++) {
player.runCommandAsync(`structure load bb ~~1~`);
}
}
}
});
}
@teal pendant