#About running commands on forge server startup

24 messages · Page 1 of 1 (latest)

split karma
#

I'm trying to write a script for my server console to run a command on startup, but continue to get syntax errors. I've tried to check documentation, and still can't find a solution. My code is as follows

    
    event.server.scheduleInTicks(1, event.server, ctx => {

        ctx.data.tell(`/datapack disable "file/Datapack_Survivors_Elegy_alpha_v0.8.4.zip"`)

    })
    
})

please help me i am going to die tomorrow

ashen wharfBOT
#

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

brave depot
#

Use event.server.runCommandSilent("/datapack ...")

split karma
# brave depot Use `event.server.runCommandSilent("/datapack ...")`

i tried it and got this as an error

[23:42:31] [INIT] Loaded plugins:
[23:42:31] [INIT] - dev.latvian.mods.kubejs.forge.BuiltinKubeJSForgePlugin
[23:42:32] [INFO] Loaded script startup_scripts:example.js in 0.144 s
[23:42:32] [INFO] Loaded 1/1 KubeJS startup scripts in 0.707 s with 0 errors and 0 warnings
[23:42:36] [ERROR] ! example.js#9: Error in 'StartupEvents.postInit': TypeError: Cannot call method "runCommandSilent" of undefined

the end is imminent

brave depot
#

Oh you're using a Startup Event? I think you can't Run commands at that Stage yet

#

Use ServerEvents.loaded instead

#

And you probably don't need the scheduleInTicks. Also why do you need to constantly disable a datapack

split karma
young yew
#

??tutorial

limpid schoonerBOT
young yew
#

skip to 13:01 into the second tutorial

brave depot
young yew
#

it also shows how to only run a command once if needed

young yew
young yew
#

??ussr

limpid schoonerBOT
# young yew ??ussr

📜Useful Starter Scripts Repository📜
Looking to get into Kubejs and don't know where to start? Well thankfully there are some Useful Starter Scripts out there to learn from! A.K.A. USSR!

young yew
#

this is what i was thinking of ```js
ServerEvents.loaded(event => {
const {server, server:{persistentData}} = event
if (persistentData.firstLoad) {
persistentData.firstLoad = true
persistentData.timer = 0
//Running code within these curly brackets will only run once upon first world load

}
//Things you want to load every time a server loads goes here outside of the curly brackets
})```

brave depot
young yew
#

yeah i mean that ones on me lul

split karma