#Am i doing this as it is not working and idk why

1 messages · Page 1 of 1 (latest)

wise nexus
#
function startCountdown(player, locationName, x, y, z) {
    let countdown = 5;
    let cancel = false;


    function countdownTick() {
        if (cancel) {
            player.sendMessage('§cWarp cancelled.');
            return;
        }

        if (countdown > 0) {
            player.sendMessage(`§fWarping in §a§l${countdown} §r§fseconds...`);
            countdown--;
            system.run(countdownTick, 20);
        } else {
            teleportPlayer(player, locationName, x, y, z);
        }
    }

    player.sendMessage(`§fYou will be warped to §a§l${locationName}§r §fin §a§l${countdown} §r§fseconds. \n§cType 'cancel' to stop.`);

    system.run(countdownTick, 20);

    world.afterEvents.chat.subscribe((eventData) => {
        if (eventData.source === player && eventData.message.toLowerCase() === 'cancel') {
            cancel = true;
        }
    });
}

function teleportPlayer(player, locationName, x, y, z) {
    player.teleport({ x: x, y: y, z: z });
    player.sendMessage(`§aYou have successfully warped to your §l${locationName}!`);
}
winter geyser
# wise nexus ```js function startCountdown(player, locationName, x, y, z) { let countdown...
function startCountdown(player, locationName, x, y, z) {
    let countdown = 5;
    let cancel = false;


    function countdownTick() {
        if (cancel) {
            player.sendMessage('§cWarp cancelled.');
            return;
        }

        if (countdown > 0) {
            player.sendMessage(`§fWarping in §a§l${countdown} §r§fseconds...`);
            countdown--;
            system.runTimeout(countdownTick, 20);
        } else {
            teleportPlayer(player, locationName, x, y, z);
        }
    }

    player.sendMessage(`§fYou will be warped to §a§l${locationName}§r §fin §a§l${countdown} §r§fseconds. \n§cType 'cancel' to stop.`);

    system.runTimeout(countdownTick, 20);

    world.afterEvents.chatSend.subscribe((eventData) => {
        if (eventData.sender instanceof Player && eventData.message.toLowerCase() === 'cancel') {
            cancel = true;
        }
    });
}

function teleportPlayer(player, locationName, x, y, z) {
    player.teleport({ x: x, y: y, z: z });
    player.sendMessage(`§aYou have successfully warped to your §l${locationName}!`);
}
wise nexus
winter geyser
#

keep checking if the velocity is not equal to 0 then cancel it

wise nexus
#

what the he

winter geyser
#

system.run to syste.runTmeout

wise nexus
#

oh

winter geyser
#

make sure to import Player

wise nexus
wise nexus
#

how i do that

winter geyser
#
if (player.getVelocity().x != 0 || player.getVelocity().y != 0 || player.getVelocity().z != 0) cancel = true;
wise nexus
# winter geyser

llike this

function startCountdown(player, locationName, x, y, z) {
let countdown = 5;
let cancel = false;

function countdownTick() {
    if (cancel) {
        player.sendMessage('§cWarp cancelled.');
        return;
    }

    const velocity = player.velocity;
    if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
        cancel = true;
        player.sendMessage('§cWarp cancelled due to movement.');
        return;
    }

    if (countdown > 0) {
        player.sendMessage(`§fWarping in §a§l${countdown} §r§fseconds...`);
        countdown--;
        system.runTimeout(countdownTick, 20);
    } else {
        teleportPlayer(player, locationName, x, y, z);
    }
}

player.sendMessage(`§fYou will be warped to §a§l${locationName}§r §fin §a§l${countdown} §r§fseconds. \n§cType 'cancel' to stop.`);

system.runTimeout(countdownTick, 20);

world.afterEvents.chatSend.subscribe((eventData) => {
    if (eventData.sender === player && eventData.message.toLowerCase() === 'cancel') {
        cancel = true;
    }
});

}

function teleportPlayer(player, locationName, x, y, z) {
player.teleport({ x: x, y: y, z: z });
player.sendMessage(§aYou have successfully warped to your §l${locationName}!);
}

winter geyser
#

no, it's player.getVelocity()

wise nexus
#

were i put it

winter geyser
wise nexus
# winter geyser

if (player.getVelocity().x != 0 || player.getVelocity().y != 0 || player.getVelocity().z != 0) cancel = true;
cancel = true;
player.sendMessage('§cWarp cancelled due to movement.');
return;
}

#

iv never delt with volcity

winter geyser
#
if (player.getVelocity().x != 0 || player.getVelocity().y != 0 || player.getVelocity().z != 0) {
            cancel = true;
            player.sendMessage('§cWarp cancelled due to movement.');
            return;
        }
winter geyser
#

idk

wise nexus
#

like what do i impoer

#

import

wise nexus
winter geyser
#

Player

wise nexus
#

Player or player

winter geyser
#

Player

wise nexus
#

player in this is not define

player.sendMessage(§fYou will be warped to §a§o${locationName}§r §fin §a§l${countdown} §r§fseconds. \n§cType 'cancel' to stop.);

wise nexus
#

the entire code

function startCountdown(player, locationName, x, y, z) {
    let countdown = 5;
    let cancel = false;

    function countdownTick() {
        if (cancel) {
            player.sendMessage('§cWarp cancelled.');
            return;
        }

        if (player.getVelocity().x != 0 || player.getVelocity().y != 0 || player.getVelocity().z != 0) {
            cancel = true;
            player.sendMessage('§cWarp cancelled due to movement.');
            return;
        }

        if (countdown > 0) {
            player.sendMessage(`§fWarping in §a§l${countdown} §r§fseconds...`);
            countdown--;
            system.runTimeout(countdownTick, 20);
        } else {
            teleportPlayer(player, locationName, x, y, z);
        }
    }
}

    player.sendMessage(`§fYou will be warped to §a§o${locationName}§r §fin §a§l${countdown} §r§fseconds. \n§cType 'cancel' to stop.`);

    system.runTimeout(countdownTick, 20);

    world.afterEvents.chatSend.subscribe((eventData) => {
        if (eventData.sender === player && eventData.message.toLowerCase() === 'cancel') {
            cancel = true;
        }
    });

function teleportPlayer(player, locationName, x, y, z) {
    player.teleport({ x: x, y: y, z: z });
    player.sendMessage(`§aYou have successfully warped to your §l${locationName}!`);
}