#How to register a serverscript

22 messages · Page 1 of 1 (latest)

steady pasture
#

Is this correct?

ItemEvents.pickedUp((event) => {
const pickedUpItem = event.itemEntity;
const player = event.player;

if (pickedUpItem.getId === "pocketmoney:copper_coin") {
console.info("1");
}

if (pickedUpItem.getId === "pocketmoney:silver_coin") {
console.info("2");
}

if (pickedUpItem.getId === "pocketmoney:gold_coin") {
console.info("3");
}
});

hallow zincBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

languid wadi
#

almost, iirc it's event.item instead of event.itemEntity and it's pickedUpItem.id instead of getId

steady pasture
#

I'm pretty new to this

languid wadi
#

Probably Not

steady pasture
#

How would I make it run then? I am trying to make a command run when I pick up an item, and then it deletes that item from my inventory. Baby steps I guess

languid wadi
steady pasture
#

Could I ask ow I would then delete the item from my inventory?

languid wadi
#

pickedUpItem.count = 0 should work iirc

steady pasture
# languid wadi `pickedUpItem.count = 0` should work iirc

This doesn't work:

ItemEvents.pickedUp((event) => {
const pickedUpItem = event.item;
const player = event.player;

if (pickedUpItem.id === "pocket_money:copper_coin") {
player.runCommand("/tell @s Yay");
pickedUpItem.count = 0;
}

if (pickedUpItem.id === "pocket_money:silver_coin") {
player.runCommand("/tell @s Yay");
pickedUpItem.count = 0;
}

if (pickedUpItem.id === "pocket_money:gold_coin") {
player.runCommand("/tell @s Yay");
pickedUpItem.count = 0;
}
});

Item does not get deleted

steady pasture
#

@languid wadi

verbal igloo
#

??patience

arctic horizonBOT
# verbal igloo ??patience

Please be patient, we're helping as fast as we can
We volunteer our time and knowledge to help people as we can.
Not everyone here will have your answer the moment you want it.
Time zones, work/life/schedules etc. also change when people are available to help.

TL;DR: Please have patience. IF and WHEN someone knows, they will assist you.

steady pasture
#

Ahem, note taken.

young dirge
#

did you use some ai

steady pasture
young dirge
#

??ai

arctic horizonBOT
# young dirge ??ai

NEVER use any AI to generate KubeJS code. They currently know very little about it, and what they do know is often outdated or false. You can instead look at the KubeJS wiki or ask for help in #1047320998199955458.

young dirge
steady pasture
steady pasture
#

For whoever is reading this, I am sorry if I had constatnly bothered you, was just trying to fix one line of code that wasn't working, so I got frustrated. I did it now, but it still doesn't excuse what I did, but thanks for the help anyways.