Reason: Duplicated text
#Dont know where to put this...
166 messages ยท Page 1 of 1 (latest)
@static light what were you needing help with? the bot killed whatever you tried to post.
I need help with finding out where to put this to make it work. Its ftb quests and kubejs
Reason: Duplicated text
its a script i tryig to paste
problem, i only have it saved to my clipboard :/
now give me some words to explain what the issue is
because code without context means nothing and I can see a MOD chiming in that they don't help with coding.
I'm not a MOD, so I'm willing to help, but I need to know which mod pack, and what issues you are having.
Its my custom modpack, im just confused on making it work.
explain to me what you are trying to make kubejs to do
i wanna get it to work on ftb quests so the quests resets every 12 hour
so you don't want a standard repeatable quest, but one that is onlyl repeatable once every 12 hours per player, 12 hours from when the player last completed the quest.
yea
or when the player hae completet the quests it will reset everyday at the same time
which version of ftb quests are you using, include minecraft version and mod loader version
did someone write t his quest for you? because i see a variable placeholder QUEST_ID_HERE
you have to put the id of the quest you are resetting in that spot
ye someone wrote me this
probably a geek with no social skills because they didn't explain it to you
i also don't see a time offset in it
yea
get me the full version of ftbquests you are using, it's in the filename
send me the quest id
32ACF80E24F7AD9C
right click on the quest and find the id, likely under quest properties
ok
this is gonna take a bit, but i should have something for you in about 30 minutes or so.
you are an angle! Take the time you need
and you'll be able to copy this one for any number of quests, all the modifiable variables will be at the top for easy modification, you won't learn anything that way, but I'm cool with that. I prefer the masses to not know the dark arts of programming. ๐
haha thanks
give this script a shot
// KubeJS server_script (e.g., in kubejs/server_scripts/quest_reset.js)
// === Configurable Settings ===
const QUEST_ID = "32ACF80E24F7AD9C"; // Quest ID to reset (use the quest's unique ID)
const RESET_INTERVAL_HOURS = 12; // Interval after which the quest resets
const RESET_INTERVAL_TICKS = RESET_INTERVAL_HOURS * 60 * 60 * 20; // 12 hours in game ticks (20 ticks = 1 second)
const RESET_INTERVAL_MS = RESET_INTERVAL_HOURS * 60 * 60 * 1000; // 12 hours in milliseconds (for offline check)
// Key for storing last completion time in player persistent data
const LAST_COMPLETE_KEY = `questLastComplete_${QUEST_ID}`;
// Event: When the specified quest is completed by a player
FTBQuestsEvents.completed(QUEST_ID, event => {
const player = event.player;
const server = event.server;
// Record the current time (timestamp) in the player's persistent data
player.persistentData[LAST_COMPLETE_KEY] = Date.now().toString();
// Schedule a quest reset after 12 hours (in ticks) for this player
const playerName = player.username;
server.scheduleInTicks(RESET_INTERVAL_TICKS, server, ctx => {
// Reset the quest progress for the player after 12 hours
ctx.data.runCommandSilent(`/ftbquests change_progress ${playerName} reset ${QUEST_ID}`);
// (No need to run as player; this admin command will reset the quest:contentReference[oaicite:5]{index=5})
});
});
// Event: When a player logs in, check if the quest should be reset due to time elapsed
PlayerEvents.loggedIn(event => {
const player = event.player;
const server = event.server;
const lastCompleteStr = player.persistentData[LAST_COMPLETE_KEY];
if (lastCompleteStr) {
const lastCompleteTime = parseInt(lastCompleteStr);
const elapsed = Date.now() - lastCompleteTime;
if (elapsed >= RESET_INTERVAL_MS) {
// More than 12 hours since last completion: reset the quest for this player
server.runCommandSilent(`/ftbquests change_progress ${player.username} reset ${QUEST_ID}`);
// Clear the stored timestamp so it won't reset again until quest is completed next time
player.persistentData[LAST_COMPLETE_KEY] = "";
}
}
});
Imma try it, you are the best!
all the CONST vars at the top are t he ones you change
however only the first 2 are the most relevant
so if you wanted a creeper kill quest at 30 hours, then naturaly the quest id for that, and interval would be 30
just copy paste and rename, then edit
you can always feed the script to ai and say "eli5"
explain like i'm 5
however i think this script reads better than the original one
It does, thanks
btw if you need to test it, set the interval to something like 5 minutes
was about to ask
xD
what number would it be if its 5 minutes? Sorry im really bad a this xD
// 5 minutes expressed in hours
const RESET_INTERVAL_HOURS = 5 / 60;
since 60 is the numerator here.
meaning if you wanted 1 minute, you can also use 1/60
not need to fully rationalize the number. let the computer math it out.
hmm, i think i did something wrong, its not resetting
are there errors in the kubejs log?
i did
is the quest on both sides as is also the script?
I just copied and pasted what you worte into my kubejs folder
Do i need to fill in the quest ids thats just called quest id?
typically scripts go on both the client and server side.
send your latest log after try to do the quest again
did you remember to reset your quest progress? it probably won't work on an already existing quest.
that was completed.
Please send some logs over so we can help resolve your issue. To access logs on your Minecraft server, please navigate to your server panel's File Manager and take the following path:
1. Open the Server's File Manager
2. Navigate inside the 'logs' folder
3. Click on "latest.log" to download it and send the file over Discord to this channel.
thats not it sorry
that doens't work, that's not how you get me the log. download the log, then upload it. you can download it via the 3 dots menu to the right of it
here is another versin of the script that checks to see if the player data is null. try it and see what you get.
// quest_reset.js โย put in kubejs/server_scripts
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
// โโโโโ EASYโTOโTWEAK SETTINGS โโโโโ
const QUEST_ID = '32ACF80E24F7AD9C' // Quest to reset
const RESET_INTERVAL_HRS = 12 // Coolโdown length
const MS = RESET_INTERVAL_HRS * 60 * 60 * 1000 // โ milliseconds
const TICKS = RESET_INTERVAL_HRS * 60 * 60 * 20 // โ game ticks
const LAST_KEY = `questLast_${QUEST_ID}` // NBT key
// Helper โ silent quest reset
function reset(server, name) {
server.runCommandSilent(`/ftbquests change_progress ${name} reset ${QUEST_ID}`) // official reset cmd :contentReference[oaicite:1]{index=1}
}
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
// 1๏ธโฃย Store a timestamp every time the quest is really completed
FTBQuestsEvents.completed(QUEST_ID, e => { // event docs :contentReference[oaicite:2]{index=2}
if (!e.player) return // protect against null player
e.player.persistentData[LAST_KEY] = Date.now().toString() // perโplayer NBT storage :contentReference[oaicite:3]{index=3}
// Schedule an onโline reset after 12ย h
e.server.scheduleInTicks(TICKS, e.server, ctx => {
if (ctx.data.playerList.getPlayerByName(e.player.username)) {
reset(ctx.data, e.player.username)
}
})
})
// 2๏ธโฃย Kickโoff checker every minute for players that stay onโline
ServerEvents.high_tick(ev => { // high_tickย = 20โฏtโฏ*โฏ~1โฏs
if ((ev.server.tickCount % 1200) !== 0) return // run once per min
ev.server.players.forEach(p => {
const ts = parseInt(p.persistentData[LAST_KEY] || 0)
if (ts && (Date.now() - ts) >= MS) {
reset(ev.server, p.username)
p.persistentData[LAST_KEY] = '' // clear flag
}
})
})
// 3๏ธโฃย Catch people who logged out before the timer elapsed
PlayerEvents.loggedIn(ev => {
const ts = parseInt(ev.player.persistentData[LAST_KEY] || 0)
if (ts && (Date.now() - ts) >= MS) {
reset(ev.server, ev.player.username)
ev.player.persistentData[LAST_KEY] = ''
}
})
you'll have to use 5/60; for the 5 minutes test again
so it looks like kubejs serverscripts don't go on the clientside. so that's nice.
so i cant get it to work?
i just gave you a new script, try it out while i analayze the log you sent
okay
and if it fails to complete, send me the latest.log again
i admitted to not realizing it didn't need to be on the client side. go ahead and remove it there.
what should i change?
in here?
client
local
the part on your computer
i'm sure you added the script to your pack on your side after i said it goes on both sides
i was thinking of crafttweaker when i saidthat
that's why you got the dirtscreen message
this error came from the client, not the server
how did you get this error?
opened the game
note: in minecraft when opens the game, we call it opening the client
did you modify the client at all in our talk?
nope
send the latest.log from the server, do yo u recall me saying that if it fails again?
in minecraft dev, we always send the latest.log from the side that failed
๐น ๐ญ ๐ช ๐ท ๐ช ๐ผ ๐ฆ ๐ธ ๐ฆ ๐ธ ๐ฑ ๐ฎ ๐ฌ ๐ญ ๐น ๐น ๐พ ๐ต ๐ด ๐ฎ ๐ณ ๐น ๐ญ ๐ช ๐ฑ ๐ฆ ๐ธ ๐น ๐ธ ๐จ ๐ท ๐ฎ ๐ต ๐น
// quest_reset.js โ place in kubejs/server_scripts
// โโโโโโโโโโโ CONFIGURABLE SETTINGS โโโโโโโโโโโ
const QUEST_ID = '32ACF80E24F7AD9C'; // Quest to reset
const RESET_INTERVAL_HRS = 12; // Coolโdown length
const RESET_INTERVAL_MS = RESET_INTERVAL_HRS * 60 * 60 * 1000; // milliseconds
const RESET_INTERVAL_TICKS = RESET_INTERVAL_HRS * 60 * 60 * 20; // game ticks
const LAST_KEY = `questLast_${QUEST_ID}`; // NBT key
// โโโโโโโโโโโ HELPER โโโโโโโโโโโ
function resetQuest(server, playerName) {
server.runCommandSilent(`/ftbquests change_progress ${playerName} reset ${QUEST_ID}`);
}
// โโโโโโโโโโโ HANDLERS โโโโโโโโโโโ
// 1๏ธโฃย Store completion time & schedule inโsession reset
FTBQuestsEvents.completed(QUEST_ID, event => {
const player = event.player;
if (!player) return; // guard against null
player.persistentData[LAST_KEY] = Date.now().toString();
event.server.scheduleInTicks(RESET_INTERVAL_TICKS, event.server, ctx => {
if (ctx.data.playerList.getPlayerByName(player.username)) {
resetQuest(ctx.data, player.username);
player.persistentData[LAST_KEY] = '';
}
});
});
// 2๏ธโฃย Periodic checker (once per minute) for online players
ServerEvents.tick(event => {
if (event.server.tickCount % 1200 !== 0) return; // 1200โฏt = 60โฏs
event.server.players.forEach(p => {
const ts = parseInt(p.persistentData[LAST_KEY] || '0', 10);
if (ts && Date.now() - ts >= RESET_INTERVAL_MS) {
resetQuest(event.server, p.username);
p.persistentData[LAST_KEY] = '';
}
});
});
// 3๏ธโฃย Login checker for timers that expired while offline
PlayerEvents.loggedIn(event => {
const player = event.player;
const ts = parseInt(player.persistentData[LAST_KEY] || '0', 10);
if (ts && Date.now() - ts >= RESET_INTERVAL_MS) {
resetQuest(event.server, player.username);
player.persistentData[LAST_KEY] = '';
}
});
when you copy the quest id from ftb quest, and then you paste it somewhere, is it not in lower case? because here we have it in uppercase.
i'm being told that the ftb quest ids have the alphabet part in lowercase
let me try changing it
so you were changing it to uppercase?
no, it came in uppercase
ok thats' odd then
try this version of the script if that doesn't work
// server_scripts/quest_reset.js
// Autoโreset a quest for each player 12ย h after their last completion
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
const QUEST_ID = '32acf80e24f7ad9c'; // ๐ lowerโcase!
const RESET_DELAY_MS = 12 * 60 * 60 * 1000; // 12ย hours
const CHECK_INTERVAL = 20 * 60; // serverโtick interval (1ย min)
// โโโ 1.ย Stamp the moment a player finishes the quest โโโโโโโโโโโโโโโ
FTBQuestsEvents.completed(QUEST_ID, e => { // fires once per finish
const p = e.player;
if (!p) return; // safety guard
const now = Date.now();
p.persistentData[`last_${QUEST_ID}`] = now;
console.log(`[quest_reset] ${p.username} completed, reset in 12h`);
scheduleReset(p, now);
});
// โโโ 2.ย Check on login so offline players donโt get stuck โโโโโโโโโโ
PlayerEvents.loggedIn(e => {
const p = e.player;
if (Date.now() - (p.persistentData[`last_${QUEST_ID}`] ?? 0) >= RESET_DELAY_MS)
resetQuestFor(p);
});
// โโโ 3.ย Lightweight ticker for active players โโโโโโโโโโโโโโโโโโโโโโ
let ticks = 0;
ServerEvents.tick(e => { // official tick event
if (++ticks % CHECK_INTERVAL) return; // once per minute
e.server.getPlayerList().getPlayers().forEach(p => {
if (Date.now() - (p.persistentData[`last_${QUEST_ID}`] ?? 0) >= RESET_DELAY_MS)
resetQuestFor(p);
});
});
// โโโ Helpers โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
function scheduleReset(p, stamp) {
const delay = Math.ceil((stamp + RESET_DELAY_MS - Date.now()) / 50);
p.server.scheduleInTicks(delay, ctx => {
const live = ctx.server.getPlayerByUUID(p.uuid);
if (live) resetQuestFor(live); // online โ instant
});
}
function resetQuestFor(p) {
p.server.runCommandSilent(`/ftbquests change_progress ${p.username} reset ${QUEST_ID}`);
p.persistentData[`last_${QUEST_ID}`] = 0; // clear timestamp
console.log(`[quest_reset] reset performed for ${p.username}`);
}
the hour is diffrent do i just pput 1/60 * 60 * 60 * 1000?
yes you can do that
we're going fast here because i'm using ai to help me get to the bottom of things faster. if we did this with manual read method, i'd have given up by now.
i really appriciate your help
PLEASE STOP USING AI
It hallucinates code! It makes things up from thin air!
This is BAD!!
we will wait on flyingbox to research the issue now.
because we're going to manually press nails into boards to build a house
no stress, and thanks guys
ironically, but maybe not so, they will say this script business is beyond their scope. i'll be shocked if they don't say that.
are you able to share your sever with me?
like zip it up, not the world folder, just the configs,/mods/kubejs folders and put it on cloud somewhere?
like the modpack zip file? is that good=
in that case the share code if you built it in curseforge app
and i need the kubejs folder from your server
the mod pack you sent me has no quests in it
therefore i need your config folder from the server
the quests you made
the pudding btw. it's a good idea to have the configs on the server match the one in the pack you are distributing. that way if players want do something in private before doing it on the server they can.
oh okay
awesome
don't watch the questbook screen btw
it reset three times now
and i was testing it insingle player too
the working script
wait hallucinating script
it dind't even enable debug mode and it was resetting every 1 minute
let me tweak it manually so ti works right
should i try this one or was it the wrong one?
it works!
you are the best
it doesnt' really work. i kept testing and found minor issues, i've gone thru about 12 iterations so far.
it works way better than when you started this thread.
that's for sure. ๐