#i have a problem
1 messages · Page 1 of 1 (latest)
do console.warn(vipDatabase)
after
const playerData = vipDatabase.get(playerName);
I put it in, it gave a warning in the game
what the warning
[Scripting][warning]-[object Object]
verificarVip is running than
and vipDatabase do return data
the problem is after
if (playerData)
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()}"}]}`);
}
inside
if (expirationDate && expirationDate <= currentDate)
put
console.warn('test passed')
Ok
i think the problem is that the player don't exist when playerJoin event fire
so the commands don't work
use playerSpawn instead
@upper atlas No warning
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
isn't that what that event?
What?
let me test it
never used it
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
np