#onEvent code fix?

10 messages · Page 1 of 1 (latest)

woven shardBOT
#

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

humble violet
#

ThingEvents.thing, essentially.
in this case, PlayerEvents.tick, i believe

wintry lantern
#

so i should change the OnEvent tag with PlayerEvents.tick

humble violet
#

yes

#

you also remove the "player.tick", since the event format change deprecates it

wintry lantern
#

var timeLimit = 7200.0; // 2h
 
PlayerEvents.tick(event => {
 
    if ((event.level.time % 20) == 0) {
        const currentDate = new Date().toDateString(); //        
        const player = event.player;
 
        if (player.persistentData.playedTime === undefined
            || player.persistentData.playedTime == null
            || isNaN(player.persistentData.playedTime)
            || player.persistentData.date != currentDate) {
            console.info(`Reset time for: ${player.name} `)
            player.persistentData.playedTime = 0;
        }
 
        if (player.persistentData.playedTime >= timeLimit) {
            console.log("The Player " + player.name + " Has exceeded the time limit");
            console.info("The Player " + player.name + "Has exceeded the time limit");
            player.kick("You have exceeded 2 hours, rest");
        }
 
        player.persistentData.date = currentDate;
        player.persistentData.playedTime += 1;
    }
});
#

so it would look like this

humble violet
#

that seems correct

wintry lantern
#

alrighty thank you for your help!

#

i seem to be getting this error when i try to run the .js Event handler 'PlayerEvents.tick' doesn't support extra id!