#How to give players a specific book when pressing a button / ingame command?

42 messages · Page 1 of 1 (latest)

gentle shoal
#

So I got an item ID of a Rule Book I made with the help of the /kjs hand command. But how do I give it to players when they press a button for example at spawn. Or how could I turn it into a command perhaps? It's for a ATM8 server if that gives you more tools via other mods

dim sirenBOT
#

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

gentle shoal
#

How to give players a specific book when pressing a button / ingame command?

gentle shoal
#

Would this work? Then just connect a button to a command block with "/kubejs custom_command Rulebook"

ServerEvents.customCommand('Rulebook', event => {
  event.player.give(Item.of('minecraft:written_book', '{author:"_BlueFireFox_",pages:[\'{"text":"Testing KubeJS script"}\'],title:"KubeJS Testing"}')`)
  })
tawny gale
gentle shoal
#

Doesn't work. Item ID name is way too long

tawny gale
#

if you intend to give this book to players, custom_command could work; you could also add a command to the command registry

tawny gale
dusk coralBOT
gentle shoal
gentle shoal
tawny gale
gentle shoal
#

It doesn't give me anything when I press the button

tawny gale
#

ill pull up a wiki page for you

#

also, try /execute as @p run kubejs custom_command Rulebook

#

it needs to be sent from a player, so you need to execute the command as if the player sent it

gentle shoal
tawny gale
gentle shoal
tawny gale
gentle shoal
#

Yeah sure! No hurries! I might be in bed by then but I'll read it tomorrow if that's the case

gentle shoal
tawny gale
#

ya, i just slept as soon as i got home and dont have time to write the command rn

#

if youre confident, you can go on the kubejs legacy wiki and look there, though very few select things are different between that version and 1.19

#

otherwise ill get that done in a few hours after my dentist appt

gentle shoal
tawny gale
#

ill set it up for you after i am home from my dentists appt

gentle shoal
#

Sure ty!

tawny gale
#
ServerEvents.commandRegistry(event => {//command registry event
    const { commands: Commands, arguments: Arguments} = event;
    event.register(//register a new command
        Commands.literal("rulebook")//the command is called myCommand
        .requires(src => src.hasPermission(0))//2 is op. This line is optional, but you can also instead of just one value, wrap it in {}s and use return to write a more complex requirement checks
            .executes(ctx => {//run the command
                ctx.source.player.give(Item.of('minecraft:written_book', '{author:"_BlueFireFox_",pages:[\'{"text":"Testing KubeJS script"}\'],title:"KubeJS Testing"}'))
                return 1
            })
        )
})
#

put this in server scripts, obviously

#

i'd recommend using this so that your players can access the rulebook from anywhere and so they dont have to fight over who's closest to the commandblock in order to recieve a book

gentle shoal
#

Right so with this players should be able to do /rulebook and it'll work

dusk coralBOT
tawny gale
#

glad to hear :)

#

go ahead and close your ticket if you dont mind

#

use /ticket close