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.
#Is there a way to run a command after 5 in-game days have passed?
11 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
you can use stats, like timeplayed
ingame days are not precise since you can sleep at night and day if certain mods are present
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
Ok, so someone has asked this before here: https://discord.com/channels/303440391124942858/1117938986430775428, you can test how many in game days have passed using event.level.getDayTime()/24000
Discord
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
this is not per player
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
}
})```
Although, an important question, do you want the five days to pass only when the player is logged in? Because if so you should just use stats like said here
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?
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