#i have a problem

1 messages · Page 1 of 1 (latest)

deft pilot
#

@upper atlas

upper atlas
#

do console.warn(vipDatabase)
after
const playerData = vipDatabase.get(playerName);

deft pilot
upper atlas
#

what the warning

deft pilot
#

[Scripting][warning]-[object Object]

upper atlas
#

verificarVip is running than
and vipDatabase do return data
the problem is after
if (playerData)

deft pilot
#
    if (playerData) {
        const expirationDate = playerData.expiration;
        const currentDate = new Date();
        if (expirationDate <= currentDate) {
            world.getDimension("overworld").runCommandAsync(`tag ${playerName} remove vip`);
            world.getDimension("overworld").runCommandAsync(`tag ${playerName} remove ${playerData.vipType}`);
            vipDatabase.delete(playerName);
            world.getDimension("overworld").runCommandAsync(`tellraw ${playerName} {"rawtext":[{"text":"§c[§rDB()§c]§rSeu VIP [expirou]! Você perdeu seus privilégios VIP."}]}`);
        } else {
            const daysLeft = Math.ceil((expirationDate - currentDate) / (1000 * 60 * 60 * 24));
            world.getDimension("overworld").runCommandAsync(`tellraw ${playerName} {"rawtext":[{"text":"§a[DB]§rSeu VIP irá expirar em: ${daysLeft} dias. Data de expiração: ${playerData.expiration.toLocaleString()}"}]}`);
        }
upper atlas
#

inside
if (expirationDate && expirationDate <= currentDate)
put
console.warn('test passed')

deft pilot
#

Ok

upper atlas
#

i think the problem is that the player don't exist when playerJoin event fire
so the commands don't work

#

use playerSpawn instead

deft pilot
#

@upper atlas No warning

deft pilot
# upper atlas use playerSpawn instead

But if I use playerspawn, it will only run the first time the player enters the server, I want it to run every time a player enters, not just the first time

#
world.afterEvents.playerSpawn.subscribe(function(data) {
    let { player, initialSpawn } = data;
    if (initialSpawn) {
        let playerName = player.name;
    }
});
#

I have it

upper atlas
#

isn't that what that event?

deft pilot
#

What?

deft pilot
#

One minute

upper atlas
#

let me test it
never used it

deft pilot
#
world.afterEvents.playerSpawn.subscribe(function(data) {
    let { player, initialSpawn } = data;
    if (initialSpawn) {
        let playerName = player.name;
        verificarVip(playerName)
    }
});
#

I am going to try

#

@upper atlas It worked

#

Lol

#

Thx you

upper atlas
#

cool

#

remove initialSpawn if you want it to fire when player respawn after he die

upper atlas