#Pickaxe Shop
1 messages · Page 1 of 1 (latest)
I didn't understand what you want
i want it to open a menu when you dont have the tag
that lets you but it
@fickle lion
thats the new one
you mean that if you don't have the tag it opens another menu for you?
.
if(!player.hasTag('taghere') return shop(player)
const shoplist =[
"MINEA",
"MINEB",
]
funtion shop(player){
const form = new ModalFormData()
.title('')
.dropdown('select Mine:',shoplist)
form.show(player).then(r => {
let [selectlist] = r.formValues
world.sendMessage(`Mine : ${selectlist}`)
})
.
how do i make it take the money away and give them a tag?
.
Learn scripting lil dude
bro i know how to
const chain = (player) => {
new ActionFormData()
.title('§fChain Kits§r')
.body('Buy your Chain kits!')
.button(`§cChain Kit I\n§f[Click To See Details]`, `textures/items/chainmail_chestplate`)
.button(`§cChain Kit II\n§f[Click To See Details]`, `textures/items/chainmail_chestplate`)
.button(`§cChain Kit III\n§f[Click To See Details]`, `textures/items/chainmail_chestplate`)
.button(`§cChain Kit IV\n§f[Click To See Details]`, `textures/items/chainmail_chestplate`)
.button(`§cClose Menu`, `textures/ui/realms_red_x`)
.show(player).then((result) => {
if (result.selection == 0) return Buykit(player, 500, `Chain Kit I`, 300, 115, 311)
if (result.selection == 1) return Buykit(player, 1000, `Chain Kit II`, 300, 115, 309)
if (result.selection == 2) return Buykit(player, 2500, `Chain Kit III`, 300, 115, 307)
if (result.selection == 3) return Buykit(player, 5000, `Chain Kit IV`, 300, 115, 305)
});
}```
function BuyItem(player, singleCost, itemDisplay, itemid, idId) {
let BuyItem = new ModalFormData()
.title(`§8Buy ${itemDisplay}`)
.slider(`\n§f1x ${itemDisplay} = ${singleCost}\n\nSelect amount`, 1, 128, 1, 1)
BuyItem.show(player).then(res => {
let TotalCost = singleCost * res.formValues[0]
console.warn(getScore(player, "Money"))
if (getScore(player, `Money`) < TotalCost) {
player.sendMessage(`§7[§c!§7]§7: §cYou cannot afford this! You need §f$${TotalCost}§c.`)
}
if (getScore(player, `Money`) >= TotalCost) {
overworld.runCommandAsync(`give "${player.name}" ${itemid} ${res.formValues[0]} ${idId}`)
overworld.runCommandAsync(`scoreboard players remove "${player.name}" Money ${TotalCost}`)
player.sendMessage(`§7[§a!§7]§7:§a Purchased ${res.formValues[0]} ${itemDisplay} For $${TotalCost}`);
}
}
)
}```
@coral flint
So what are you confused about?
@coral flint
okay
@exotic jetty
ive got this but this shows when i click on any of them
there isnt one
thats for my own anticheat
form just does this
nope
wait i fixed it
my main form had a double close button binded and it wasnt doing anything
"panel_name": {
"type": "panel",
"size": [ 30, 30 ],
"bindings": [
{
"binding_type": "view",
"source_control_name": "image",
"resolve_sibling_scope": true,
"source_property_name": "(not (#texture = ''))",
"target_property_name": "#visible"
}```
lol
i need help with making this a one time thing and not a slider
like make it just 1 time
instead of this
@exotic jetty
.toggle(`TOGGLE`, false)
if i use a toggle
can this be used as a true?
so if it is pressed it will purchase
@exotic jetty
okay
it says undefined
@exotic jetty
You need a getScore function
export function getScore(player, scoreboardValue) {
try {
return world.scoreboard.getObjective(scoreboardValue).getScore(player.scoreboardIdentity)
} catch {
return 0
}
}
its not the best but it works just add this to your code
hmm weird
wait let me check
const getScore = (objective, target = true) => {
try {
const obj = world.scoreboard.getObjective(objective);
if (typeof target == `string`) {
return obj.getScore(obj.getParticipants().find(v => v.displayName == target));
}
return obj.getScore(target.scoreboardIdentity);
} catch (e) {
}
};```
.textfield(`TEXTFIELD`, "test")
```you have here a error
```js
.textField(`TEXTFIELD`, "test")
```change it to this
im not using that anymore and i know
do you mean you don't use this script?
the code working fine
I think your getScore function is broken
I use this code to open the form maybe try with this
world.beforeEvents.playerInteractWithEntity.subscribe((data) => {
let {target} = data
if (target.typeId === "minecraft:npc") {
system.run(() => {
Mine(data.player)
})
data.cancel =true
}
})
bro
let Home = new ActionFormData()
.title(`§1§2§3§r`)
.button(`§bWarps\n§fUseful Warps!`, "textures/uitexture/rules")
.button(`§9Mines\n§fMines Navigation!`, "textures/uitexture/rules")
.button(`§cShop\n§fBuy Some Storage!`, "textures/uitexture/chest")
.show(player).then((result) => {
if (result.selection === 0) Warps(player);
if (result.selection === 1) Mines(player);
if (result.selection === 2) Mine(player);
});
}```
Yeah Ik that you use something else to open the form but It was a info
and I also found some issue with your BuyItem function
what?
for what is the toggle usefull
function BuyItem(player, singleCost, itemDisplay, itemid, idId) {
let BuyItemForm = new ModalFormData()
.title(`§8Buy ${itemDisplay}`)
.toggle(`TOGGLE`, true);
BuyItemForm.show(player).then(res => {
let TotalCost = singleCost
let money = getScore(player, "Money");
if (money < TotalCost) {
player.sendMessage(`§7[§c!§7]§7: §cYou cannot afford this! You need §f$${TotalCost}§c.`);
} else {
player.runCommandAsync(`give @s ${itemid} 1 ${idId}`);
player.runCommandAsync(`scoreboard players remove @s money ${TotalCost}`);
player.sendMessage(`§7[§a!§7]§7:§a Purchased ${itemDisplay} For $${TotalCost}`);
}
});
}
to make sure they want to buy it..
oh ok than wait
function BuyItem(player, singleCost, itemDisplay, itemid, idId) {
let BuyItemForm = new ModalFormData()
.title(`§8Buy ${itemDisplay}`)
.toggle(`TOGGLE, you sure?`, true);
BuyItemForm.show(player).then(res => {
if (res.canceled) return
let TotalCost = singleCost
let money = getScore("Money", player);
if (res.formValues[0] == false) return player.sendMessage("§cPressure canceled!")
if ((money < TotalCost)) {
player.sendMessage(`§7[§c!§7]§7: §cYou cannot afford this! You need §f$${TotalCost}§c.`);
} else {
player.runCommandAsync(`give @s ${itemid} 1 ${idId}`);
player.runCommandAsync(`scoreboard players remove @s money ${TotalCost}`);
player.sendMessage(`§7[§a!§7]§7:§a Purchased ${itemDisplay} For $${TotalCost}`);
}
});
}
here with the toggle
alright
I edit the code again bc there was missing cancel and I had a mistake in the getScore
player.addTag("here the tag")
and if you want remove
player.removeTag("here the tag")
but that would add the same tag for all of them.
do you mean like this?
player.addTag(`${itemDisplay}`)
huh
if (response.selection == 0) return BuyItem(player, 200, `Mine B`, `minecraft:totem_of_undying`, 0)
instead of the minecraft:totem_of_undying can it be a tag?
yes
how?
just write the name of the tag and than in the BuyItem function remove the give item thing and add ```js
player.addTag(${itemDisplay)
i dont understand this tho
like this
function BuyItem(player, singleCost, itemDisplay, tag) {
let BuyItemForm = new ModalFormData()
.title(`§8Buy ${itemDisplay}`)
.toggle(`TOGGLE, you sure?`, true);
BuyItemForm.show(player).then(res => {
if (res.canceled) return
let TotalCost = singleCost
let money = getScore("Money", player);
if (res.formValues[0] == false) return player.sendMessage("§cPressure canceled!")
if (money < TotalCost) {
player.sendMessage(`§7[§c!§7]§7: §cYou cannot afford this! You need §f$${TotalCost}§c.`);
} else {
player.addTag(`${tag}`)
player.runCommandAsync(`scoreboard players remove @s money ${TotalCost}`);
player.sendMessage(`§7[§a!§7]§7:§a Purchased ${itemDisplay} For $${TotalCost}`);
}
});
}
so i remove the totem?
and the usage
BuyItem(player, 200, `Mine B`, "mine_b")
if (response.selection == 0) return BuyItem(player, 200, `Mine B`, `minecraft:totem_of_undying`, 0)
okay
wait so is my ${itemDisplay} mine_b now?
no sorry I had a mistake here
${itemDisplay} is the name Mine B
oh okay
and ${tag} is the tag name
are you sure you use this function?
yws..
wait send the code
this isnt defined
let BuyItemForm = new ModalFormData()
.title(`§8Buy ${itemDisplay}`)
.toggle(`TOGGLE, Are you sure?`, true);
BuyItemForm.show(player).then((res) => {
if (res.canceled) return;
let TotalCost = singleCost;
let Money = getScore("Money", player);
if (res.formValues[0] == false)
return player.sendMessage("§cPressure canceled!");
if (Money < TotalCost) {
player.sendMessage(
`§7[§c!§7]§7: §cYou cannot afford this! You need §f$${TotalCost}§c.`
);
} else {
player.addTag(`${tag}`)
player.runCommandAsync(`scoreboard players remove @s Money ${TotalCost}`);
player.sendMessage(
`§7[§a!§7]§7:§a Purchased ${itemDisplay} For $${TotalCost}`
);
}
});
}```
no you didn't use the function what I send
use this
i did
function BuyItem(player, singleCost, itemDisplay, itemid, idId) its not the same as function BuyItem(player, singleCost, itemDisplay, tag)
Your welcome
hey, sorry to bother you again but if they don't have the tag for the one before can i make it not purchaseable
wym
function BuyItem(player, singleCost, itemDisplay, tag, tag2) {
let BuyItemForm = new ModalFormData()
.title(`§8Buy ${itemDisplay}`)
.toggle(`TOGGLE, Are you sure?`, true);
BuyItemForm.show(player).then(res => {
if (res.canceled) return
let TotalCost = singleCost
let MONEY = getScore("MONEY", player);
if (res.formValues[0] == false) return player.sendMessage("§cPressure canceled!")
if (MONEY < TotalCost) {
player.sendMessage(`§7[§c!§7]§7: §cYou cannot afford this! You need §f$${TotalCost}§c.`);
} else {
player.addTag(`${tag}`)
player.addTag(`${tag2}`)
player.runCommandAsync(`scoreboard players remove @s MONEY ${TotalCost}`);
player.sendMessage(`§7[§a!§7]§7:§a Purchased ${itemDisplay} For $${TotalCost}`);
}
});
}```
I made a list in the Mine function
here check this code
this is what you wanted
okay
@tranquil arrow
this is what i had before tho
so how does the tags work with eachother?
yeah Ik but its not clean
use this and than change the tag
in the list there is a category called tag: and in there change the tags to yours
here with your tags
use this function
and this
function BuyItem(player, singleCost, itemDisplay, tag, requiredMineTag) {
let BuyItemForm = new ModalFormData()
.title(`§8Buy ${itemDisplay}`)
.toggle(`TOGGLE, are you sure?`, true);
BuyItemForm.show(player).then(res => {
if (res.canceled) return;
let TotalCost = singleCost;
let money = getScore("Money", player);
if (res.formValues[0] == false) return player.sendMessage("§7[§c!§7]§c Purchase canceled!");
if (money < TotalCost) {
player.sendMessage(`§7[§c!§7] §cYou cannot afford this! You need §f$${TotalCost}§c.`);
} else {
if (requiredMineTag && !player.hasTag(requiredMineTag)) {
return player.sendMessage(`§7[§c!§7]§c You need to purchase Mine ${requiredMineTag?.substring(1)} first.`);
}
player.addTag(`${tag}`);
player.runCommandAsync(`scoreboard players remove @s money ${TotalCost}`);
player.sendMessage(`§7[§a!§7]§a Purchased ${itemDisplay} for $${TotalCost}`);
}
});
}
did you remove this?
no..
than It should work
let Home = new ActionFormData()
.title(`§1§2§3§r`)
.button(`§bWarps\n§fUseful Warps!`, "textures/uitexture/rules")
.button(`§9Mines\n§fMines Navigation!`, "textures/uitexture/rules")
.button(`§cShop\n§fBuy Your Choice Of Mines Or Pickaxes!`, "textures/uitexture/chest")
.show(player).then((result) => {
if (result.selection === 0) Warps(player);
if (result.selection === 1) Mines(player);
if (result.selection === 2) MineShop(player);
});
}```
bc you use it here
if (result.selection === 2) Mine(player);
i have that
send a ss of your code that you use
Bc you named the function Mines and not Mine
it works
oh nvm wait
no It gives you the tag that you buyed
huh
i want it to give two tags BB & B
oh
why did you not tell me that
i thought it was clear..
no I didn't know
if (response.selection == 24) return BuyItem(player, 20000000, `Mine Z`, `ZZ`, `Z`)
wait
here now
function BuyItem(player, singleCost, itemDisplay, tag, requiredMineTag) {
let BuyItemForm = new ModalFormData()
.title(`§8Buy ${itemDisplay}`)
.toggle(`TOGGLE, are you sure?`, true);
BuyItemForm.show(player).then(res => {
if (res.canceled) return;
let TotalCost = singleCost;
let money = getScore("money", player);
if (res.formValues[0] == false) return player.sendMessage("§7[§c!§7]§c Purchase canceled!");
if (money < TotalCost) {
player.sendMessage(`§7[§c!§7] §cYou cannot afford this! You need §f$${TotalCost}§c.`);
} else {
if (requiredMineTag && !player.hasTag(requiredMineTag)) {
return player.sendMessage(`§7[§c!§7]§c You need to purchase Mine ${requiredMineTag?.substring(1)} first.`);
}
if (player.hasTag(tag)) return player.sendMessage(`§7[§c!§7]§c You already buyed this Mine.`);
player.addTag(`${tag}`);
player.addTag(`${tag.substring(1)}`);
player.runCommandAsync(`scoreboard players remove @s money ${TotalCost}`);
player.sendMessage(`§7[§a!§7]§a Purchased ${itemDisplay} for $${TotalCost}`);
}
});
}
don't use this use the new what I send
this here
i know
💀
this doesnt give me two tags though
this is the function with the logic
bruh Idk what script do you use bc for me its working fine
it gives two tags?
here the full code that I use
its does I made it like it give BB and than its remove one B and give the tag
here like this
player.addTag(`${tag}`); //give BB
player.addTag(`${tag.substring(1)}`); //give B
yeah than It should work
it doesnt
👍🏽
@tranquil arrow
if (result.selection === 1) player.addTag(`BB`)
how do i make it that you have to have a tag to give a tag?
if (player.hasTag("idk") {
player.addTag("idk2")
}
okay thank you
can i also make this a pickaxe shop?
new ChestFormData('9')
.title('§l§bPickaxe Shop')
.button(0, '§l§4Back', ['', '§r§cGo Back A Page!'], 'textures/icons/Back')
.button(2, '§r§dTier I Pickaxe', ['', 'Unbreaking I', 'Efficiency I'], 'minecraft:iron_pickaxe', 1, true)
.button(3, '§r§dTier II Pickaxe', ['', 'Unbreaking I', 'Efficiency II'], 'minecraft:iron_pickaxe', 1, true)
.button(4, '§r§dTier II Pickaxe', ['', 'Unbreaking I', 'Efficiency III'], 'minecraft:iron_pickaxe', 1, true)
.button(5, '§r§dTier IV Pickaxe', ['', 'Unbreaking II', 'Efficiency IV'], 'minecraft:iron_pickaxe', 1, true)
.button(6, '§r§dTier V Pickaxe', ['', 'Unbreaking II', 'Efficiency V'], 'minecraft:iron_pickaxe', 1, true)
.button(8, '§l§bNext', ['', '§r§9Go To The Next Page!'], 'textures/icons/Next')
.show(player).then(response => {
if (response.selection === 0) return (player);
if (response.selection === 2) return (player);
if (response.selection === 3) return (player);
if (response.selection === 4) return (player);
if (response.selection === 5) return (player);
if (response.selection === 6) return (player);
if (response.selection === 8) return (player);
if (response.canceled) return;
world.sendMessage(`${player.name} has chosen item ${response.selection}`);
secondarymenu(player);
})
};```
i have this for my chest form
what do you mean by this?
if you mean the 9 slots then you have modify the json ui
I wonder it was made for images to be dropped it
nope
it does support 9 so idk what you mean by this
Still have no idea what you mean by “is there anyway to do this”
can i make it BUY a pickaxe???
thats from my mine shoip
wym?
okay
okay
doesnt work
yes
i have
no
okay
what should i return?
if (money >= 200 && response.selection === 2) return player.runCommandAsync(`structure load ${pickaxe}`);
how do i make the ${pickaxe} be defined?
learn js
i do know js
no you do not
and im trying to define a structure that loads.
well pickaxe is an argument from the function BuyPick
you pass through the name of the structure
yes
yeah
its when i add this
Itemshop.button(4, `§b${Pick.name}\n§a$${Pick.cost}`, `${Pick.name}`);
the 4,
"i know js"
okay
and why are you talking when im just wondering why i need it?
it works but i only have one button
function BuyPick(player, singleCost, itemDisplay, pickaxe) {
let BuyItemForm = new ModalFormData()
.title(`§f${itemDisplay}`)
.textField(`§fPurchase §a${itemDisplay} §eare you sure§f?\n`, '§oType Confirm...')
.toggle(``, true);
BuyItemForm.show(player).then(res => {
if (res.canceled) return;
let TotalCost = singleCost;
let MONEY = getScore("MONEY", player);
if (res.formValues[0] == false) return player.sendMessage("§7[§c!§7]§c Purchase canceled!");
if (MONEY < TotalCost) {
player.sendMessage(`§7[§c!§7] §cYou cannot afford this! You need §f$${TotalCost}§c.`);
}
player.runCommandAsync(`scoreboard players remove @s MONEY ${TotalCost}`);
player.runCommandAsync(`structure load ${pickaxe} ~ ~ ~`);
player.sendMessage(`§7[§a!§7]§a Purchased ${itemDisplay} for $${TotalCost}`);
}
)};
function PickShop(player) {
let Picks = [
{ name: "§r§dTier I Pickaxe", cost: 200, pickaxe: "tierIpickaxe" },
{ name: "§r§dTier II Pickaxe", cost: 500, pickaxe: "tierIIpickaxe" },
{ name: "§r§dTier III Pickaxe", cost: 1000, pickaxe: "tierIIIpickaxe" },
{ name: "§r§dTier IV Pickaxe", cost: 2500, pickaxe: "tierIVpickaxe" },
{ name: "§r§dTier V Pickaxe", cost: 5000, pickaxe: "tierVpickaxe" },
];
let Itemshop = new ChestFormData('9').title("§bPicks");
Picks.forEach((Pick) => {
Itemshop.button(`§b${Pick.name}\n§a$${Pick.cost}`, `${Pick.name}`);
});
Itemshop.show(player).then(response => {
let selectedPick = Picks[response.selection];
if (selectedPick) {
BuyPick(player, selectedPick.cost, selectedPick.name, selectedPick.pickaxe);
}
});
}```
if you knew js youd know how to do all of this
but this isn't what i learned
is it not?
now when I press that one and only button it does this..
and it workd
no 💀
no minecraft version has chestformdata which is what he asked
there are addons for it but thats not what he asked
yes i know
no he didnt
do you want to check if confirm was typed in the box?
And check and charge a scoreboard and give the item
no
the latter stuff I presume?
i want it to show all five of these { name: "§r§dTier I Pickaxe", cost: 200, pickaxe: "tierIpickaxe" }, { name: "§r§dTier II Pickaxe", cost: 500, pickaxe: "tierIIpickaxe" }, { name: "§r§dTier III Pickaxe", cost: 1000, pickaxe: "tierIIIpickaxe" }, { name: "§r§dTier IV Pickaxe", cost: 2500, pickaxe: "tierIVpickaxe" }, { name: "§r§dTier V Pickaxe", cost: 5000, pickaxe: "tierVpickaxe" },
but instead it shows 1 and its the 5th one
in your forEach at i after the object param then send i as the first parm like form.button(i, name, lore, typeId/texturePath)
i would be the slot
it defaults to first one I think that is why its the last in the array that shows
yeah
for it to look like above i + 2 should do it
.
let Picks = [
{ name: "§r§dTier I Pickaxe", cost: 200, pickaxe: "tierIpickaxe" },
{ name: "§r§dTier II Pickaxe", cost: 500, pickaxe: "tierIIpickaxe" },
{ name: "§r§dTier III Pickaxe", cost: 1000, pickaxe: "tierIIIpickaxe" },
{ name: "§r§dTier IV Pickaxe", cost: 2500, pickaxe: "tierIVpickaxe" },
{ name: "§r§dTier V Pickaxe", cost: 5000, pickaxe: "tierVpickaxe" },
];
Picks.forEach((Pick,i) => {
Itemshop.button(i+2,`§b${Pick.name}\n§a$${Pick.cost}`, `${Pick.name}`, 'minecraft:iron_pickaxe');
});```
let Picks = [
{ name: "§r§dTier I Pickaxe", cost: 200, pickaxe: "tierIpickaxe" },
{ name: "§r§dTier II Pickaxe", cost: 500, pickaxe: "tierIIpickaxe" },
{ name: "§r§dTier III Pickaxe", cost: 1000, pickaxe: "tierIIIpickaxe" },
{ name: "§r§dTier IV Pickaxe", cost: 2500, pickaxe: "tierIVpickaxe" },
{ name: "§r§dTier V Pickaxe", cost: 5000, pickaxe: "tierVpickaxe" },
];
let Itemshop = new ActionFormData().title("§bPicks");
Picks.forEach((Pick, i) => {
Itemshop.button(
i + 2,
`§b${Pick.name}\n§a$${Pick.cost}`,
`${Pick.name}`,
"minecraft:iron_pickaxe"
);
});
Itemshop.show(player).then((response) => {
let selectedPick = Picks[response.selection];
if (selectedPick) {
BuyPick(
player,
selectedPick.cost,
selectedPick.name,
selectedPick.pickaxe
);
}
});
}```
@runic imp
does BuyPick exist?
isn't Itemshop a chest form data
yes
but im trying to see if that would work too
let Picks = [
{ name: "§r§dTier I Pickaxe", cost: 200, pickaxe: "tierIpickaxe" },
{ name: "§r§dTier II Pickaxe", cost: 500, pickaxe: "tierIIpickaxe" },
{ name: "§r§dTier III Pickaxe", cost: 1000, pickaxe: "tierIIIpickaxe" },
{ name: "§r§dTier IV Pickaxe", cost: 2500, pickaxe: "tierIVpickaxe" },
{ name: "§r§dTier V Pickaxe", cost: 5000, pickaxe: "tierVpickaxe" },
];
let Itemshop = new ChestFormData('9').title("§bPicks");
Picks.forEach((Pick,i) => {
Itemshop.button(i+2,`§b${Pick.name}\n§a$${Pick.cost}`, `${Pick.name}`, 'minecraft:iron_pickaxe');
});
Itemshop.show(player).then((response) => {
let selectedPick = Picks[response.selection];
if (selectedPick) {
BuyPick(
player,
selectedPick.cost,
selectedPick.name,
selectedPick.pickaxe
);
}
});
}```
this error
.
yes
function BuyPick(player, singleCost, itemDisplay, pickaxe) {
let BuyItemForm = new ModalFormData()
.title(`§f${itemDisplay}`)
.textField(`§fPurchase §a${itemDisplay} §eare you sure§f?\n`, '§oType Confirm...')
.toggle(``, true);
BuyItemForm.show(player).then(res => {
if (res.canceled) return;
let TotalCost = singleCost;
let MONEY = getScore("MONEY", player);
if (res.formValues[0] == false) return player.sendMessage("§7[§c!§7]§c Purchase canceled!");
if (MONEY < TotalCost) {
player.sendMessage(`§7[§c!§7] §cYou cannot afford this! You need §f$${TotalCost}§c.`);
}
player.runCommandAsync(`scoreboard players remove @s MONEY ${TotalCost}`);
player.runCommandAsync(`structure load ${pickaxe} ~ ~ ~`);
player.sendMessage(`§7[§a!§7]§a Purchased ${itemDisplay} for $${TotalCost}`);
}
)};
function PickShop(player) {
let Picks = [
{ name: "§r§dTier I Pickaxe", cost: 200, pickaxe: "tierIpickaxe" },
{ name: "§r§dTier II Pickaxe", cost: 500, pickaxe: "tierIIpickaxe" },
{ name: "§r§dTier III Pickaxe", cost: 1000, pickaxe: "tierIIIpickaxe" },
{ name: "§r§dTier IV Pickaxe", cost: 2500, pickaxe: "tierIVpickaxe" },
{ name: "§r§dTier V Pickaxe", cost: 5000, pickaxe: "tierVpickaxe" },
];
let Itemshop = new ChestFormData('9').title("§bPicks");
Picks.forEach((Pick,i) => {
Itemshop.button(i+2,`§b${Pick.name}\n§a$${Pick.cost}`, `${Pick.name}`, 'minecraft:iron_pickaxe');
});
Itemshop.show(player).then((response) => {
let selectedPick = Picks[response.selection];
if (selectedPick) {
BuyPick(
player,
selectedPick.cost,
selectedPick.name,
selectedPick.pickaxe
);
}
});
}```
function BuyPick(player, singleCost, itemDisplay, pickaxe) {
let BuyItemForm = new ModalFormData()
.title(`§f${itemDisplay}`)
.textField(`§fPurchase §a${itemDisplay} §eare you sure§f?\n`, '§oType Confirm...')
.toggle(``, true);
BuyItemForm.show(player).then(res => {
if (res.canceled) return;
let TotalCost = singleCost;
let MONEY = getScore("MONEY", player);
if (res.formValues[0] == false) return player.sendMessage("§7[§c!§7]§c Purchase canceled!");
if (MONEY < TotalCost) {
player.sendMessage(`§7[§c!§7] §cYou cannot afford this! You need §f$${TotalCost}§c.`);
}
player.runCommandAsync(`scoreboard players remove @s MONEY ${TotalCost}`);
player.runCommandAsync(`structure load ${pickaxe} ~ ~ ~`);
player.sendMessage(`§7[§a!§7]§a Purchased ${itemDisplay} for $${TotalCost}`);
}).catch(error => console.warn(error, error.stack));
};
function PickShop(player) {
let Picks = [
{ name: "§r§dTier I Pickaxe", cost: 200, pickaxe: "tierIpickaxe" },
{ name: "§r§dTier II Pickaxe", cost: 500, pickaxe: "tierIIpickaxe" },
{ name: "§r§dTier III Pickaxe", cost: 1000, pickaxe: "tierIIIpickaxe" },
{ name: "§r§dTier IV Pickaxe", cost: 2500, pickaxe: "tierIVpickaxe" },
{ name: "§r§dTier V Pickaxe", cost: 5000, pickaxe: "tierVpickaxe" },
];
let Itemshop = new ChestFormData('9').title("§bPicks");
Picks.forEach((Pick, i) => {
Itemshop.button(i + 2, `§b${Pick.name}\n§a$${Pick.cost}`, `${Pick.name}`, 'minecraft:iron_pickaxe');
});
Itemshop.show(player).then((response) => {
let selectedPick = Picks[response.selection];
if (selectedPick) {
BuyPick(
player,
selectedPick.cost,
selectedPick.name,
selectedPick.pickaxe
);
}
}).catch(error => console.warn(error, error.stack));
}```
send the line where the error is
.
did the code I sent produce a stack trace?
no
idjk what that is
no
function BuyPick(player, singleCost, itemDisplay, pickaxe) {
let BuyItemForm = new ModalFormData()
.title(`§f${itemDisplay}`)
.textField(`§fPurchase §a${itemDisplay} §eare you sure§f?\n`, '§oType Confirm...')
.toggle(``, true);
BuyItemForm.show(player).then(res => {
try {
if (res.canceled) return;
let TotalCost = singleCost;
let MONEY = getScore("MONEY", player);
if (res.formValues[0] == false) return player.sendMessage("§7[§c!§7]§c Purchase canceled!");
if (MONEY < TotalCost) {
player.sendMessage(`§7[§c!§7] §cYou cannot afford this! You need §f$${TotalCost}§c.`);
}
player.runCommandAsync(`scoreboard players remove @s MONEY ${TotalCost}`);
player.runCommandAsync(`structure load ${pickaxe} ~ ~ ~`);
player.sendMessage(`§7[§a!§7]§a Purchased ${itemDisplay} for $${TotalCost}`);
} catch (error) {
console.warn(error, error.stack);
}
});
};
function PickShop(player) {
let Picks = [
{ name: "§r§dTier I Pickaxe", cost: 200, pickaxe: "tierIpickaxe" },
{ name: "§r§dTier II Pickaxe", cost: 500, pickaxe: "tierIIpickaxe" },
{ name: "§r§dTier III Pickaxe", cost: 1000, pickaxe: "tierIIIpickaxe" },
{ name: "§r§dTier IV Pickaxe", cost: 2500, pickaxe: "tierIVpickaxe" },
{ name: "§r§dTier V Pickaxe", cost: 5000, pickaxe: "tierVpickaxe" },
];
let Itemshop = new ChestFormData('9').title("§bPicks");
Picks.forEach((Pick, i) => {
Itemshop.button(i + 2, `§b${Pick.name}\n§a$${Pick.cost}`, `${Pick.name}`, 'minecraft:iron_pickaxe');
});
Itemshop.show(player).then((response) => {
try {
let selectedPick = Picks[response.selection];
if (selectedPick) {
BuyPick(
player,
selectedPick.cost,
selectedPick.name,
selectedPick.pickaxe
);
}
} catch (error) {
console.warn(error, error.stack);
}
});
}```
I wish they would stack traces back to errors in promise functions.
try catch all code in .then callbacks and asynchronous functions
if you need help with that send the entire file
.
its should now give a stack trace in all your .thens if you make new ones you should probaly put a try catch in it
There are 20 errors in this [code](#1218227466255077527 message):
message.js(3,23): Cannot find module './extensions/forms.js' or its corresponding type declarations.
message.js(8,3): 'obj' is possibly 'undefined'.
message.js(8,6): Argument of type 'boolean' is not assignable to parameter of type 'string | Entity | ScoreboardIdentity'.
message.js(35,5): 'error' is of type 'unknown'.
message.js(54,5): 'error' is of type 'unknown'.
message.js(71,5): 'error' is of type 'unknown'.
message.js(162,5): 'error' is of type 'unknown'.
message.js(187,5): 'error' is of type 'unknown'.
message.js(194,38): Object is possibly 'undefined'.
message.js(212,12): Cannot find name 'PickaxeShop3'. Did you mean 'PickaxeShop'?
message.js(214,5): 'error' is of type 'unknown'.
message.js(229,14): 'res.formValues' is possibly 'undefined'.
message.js(230,5): 'MONEY' is possibly 'undefined'.
message.js(237,5): 'error' is of type 'unknown'.
message.js(268,5): 'error' is of type 'unknown'.
message.js(285,14): 'res.formValues' is possibly 'undefined'.
message.js(286,5): 'MONEY' is possibly 'undefined'.
message.js(300,5): 'error' is of type 'unknown'.
message.js(343,18): Type 'undefined' cannot be used as an index type.
message.js(348,5): 'error' is of type 'unknown'.
try {
const obj = world.scoreboard.getObjective(objective);
return obj.getScore(target);
} catch (e) {
}
};```
you dont need to search for the identity anymore
its probably PickaxeShop3 not existing
its not
okay
which causes a error if you call a nonexistent function
send line 35
🤔
looks like a issue in the forms.js
(((ID + (ID < 256 ? 0 : number_of_1_16_100_items)) * 65536) + (!!enchanted * 32768)) || texture```
function PickShop(player) {
let Picks = [
{ name: "§r§dTier I Pickaxe", cost: 200, pickaxe: "tierIpickaxe" },
{ name: "§r§dTier II Pickaxe", cost: 500, pickaxe: "tierIIpickaxe" },
{ name: "§r§dTier III Pickaxe", cost: 1000, pickaxe: "tierIIIpickaxe" },
{ name: "§r§dTier IV Pickaxe", cost: 2500, pickaxe: "tierIVpickaxe" },
{ name: "§r§dTier V Pickaxe", cost: 5000, pickaxe: "tierVpickaxe" },
];
let Itemshop = new ChestFormData('9').title("§bPicks");
Picks.forEach((Pick, i) => {
Itemshop.button(i + 2, `§b${Pick.name}`, [`§a$${Pick.cost}`], 'minecraft:iron_pickaxe');
});
Itemshop.show(player).then((response) => {
try {
let selectedPick = Picks[response.selection];
if (selectedPick) {
BuyPick(
player,
selectedPick.cost,
selectedPick.name,
selectedPick.pickaxe
);
}
} catch (error) {
console.warn(error, error.stack);
}
});
}```
item description has to be an array
okay
ill try when i get home
There are 3 errors in this [code](#1218227466255077527 message):
[36m<repl>.js[0m:[33m9[0m:[33m24[0m - [31merror[0m[30m TS2304: [0mCannot find name 'ChestFormData'.
[7m9[0m let Itemshop = new ChestFormData('9').title("§bPicks");
[7m [0m [31m ~~~~~~~~~~~~~[0m
``````ansi
[36m<repl>.js[0m:[33m18[0m:[33m17[0m - [31merror[0m[30m TS2304: [0mCannot find name 'BuyPick'.
[7m18[0m BuyPick(
[7m [0m [31m ~~~~~~~[0m
``````ansi
[36m<repl>.js[0m:[33m26[0m:[33m33[0m - [31merror[0m[30m TS18046: [0m'error' is of type 'unknown'.
[7m26[0m console.warn(error, error.stack);
[7m [0m [31m ~~~~~[0m
yup there is NO ChestFormData from server-ui
even if it is, the item placement is "slot" not button
its a custom thing
https://github.com/Herobrine643928/Chest-UI/blob/main/README.md
its button