#Is there a way to run a command after 5 in-game days have passed?

11 messages · Page 1 of 1 (latest)

drifting notch
#

I am making a difficult pack that takes some time to adjust to mechanics and I was wanting to have a 5 day "grace period". So I was hoping that I could start a timer from the first time the first player joins the server and when the 5 days are up it would run a command. I already have the config swapper mod and configs all worked out so all I really need is some help with the timer that starts when the first player first joins the world.

wintry lakeBOT
#

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

flat sentinel
#

you can use stats, like timeplayed
ingame days are not precise since you can sleep at night and day if certain mods are present

gaunt raft
#

I know that how many in game days have passed are stored on the f3 screen, so you should be able to access that number somewhere, though I'm unsure of where it would be stored, I'll do some looking and see if I can find it out, but I'm not too experienced at that

gaunt raft
#

Ah, they're looking for a per player one? That should still be possible using that or something like it, one sec

#

Something like this should work (I haven't tested this script though, so probably give it a test first):

PlayerEvents.loggedIn(event => {
if(event.player.persistentData.firstDayInServer == null){
event.player.persistentData.fiveDaysPassed = false
event.player.persistentData.kubejsTimeInServer = event.server.overworld().getDayTime()/24000
}
})
PlayerEvents.tick(event => {
if(!event.player.persistentData.fiveDaysPassed && event.server.overworld().getDayTime()/24000 - event.player.persistentData.firstDayInServer >= 5){
//put whatever you want to run here
}
})```
gaunt raft
flat sentinel
#

I don't get what he meant with mechanics, and looks like he really wants it to be server based, not player like I supposed.
But it doesn't make sense. 5 in-game days is like nothing.

he wants a grace period to not spawn monsters nearby a player? what about people that logins after that timer?

gaunt raft
#

I mean if they want to run a command once the 5 days are over like they said, they could just put event.server.runCommandSilent(their command) after the if statement in player.tick