Watermelon smp code

PHOTO EMBED

Fri Aug 07 2026 17:41:06 GMT+0000 (Coordinated Universal Time)

Saved by @ItzStubZ

// start music
const MUSIC_LOOP_TIME = 112000;
const musicStartTimes = {};

function startEpicMusic(playerId) {
    api.setClientOption(playerId, "music", null);
    api.setClientOption(playerId, "music", "Emotional Epic");
    api.setClientOption(playerId, "musicVolumeLevel", 0.6);
    musicStartTimes[playerId] = Date.now();
}
/* 1. Global callback that triggers whenever a player joins */
function onPlayerJoin(playerId) {

    // MUSIC
function onPlayerJoin(playerId) {
    startEpicMusic(playerId);

    api.setClientOption(playerId, "RightInfoText", [
        { str: "šŸ‰ Watermelon ", style: { color: "#F01E0F", fontWeight: "bold", fontSize: "20px" } },
        { str: "SMP šŸ’¦\n", style: { color: "#5CFF5C", fontWeight: "bold", fontSize: "20px" } },

        /* rest of sidebar */
    ]);

    /* join messages etc */
}
    
    /* 2. Set up the Right Sidebar Info Text */
    api.setClientOption(playerId, "RightInfoText", [
        { str: "šŸ‰ Watermelon ", style: { color: "#F01E0F", fontWeight: "bold", fontSize: "20px" } },
        { str: "SMP šŸ’¦\n", style: { color: "#5CFF5C", fontWeight: "bold", fontSize: "20px" } },
        { str: "————————————————————————\n", style: { color: "lightgrey", fontWeight: "bold" } },
        
        /* Discord Row */
        { icon: "discord", style: { fontSize: "14px", color: "#5865F2" } },
        { str: " discord.gg/b3sHbhwum7\n", style: { color: "#5865F2", fontWeight: "bold" } },
        
        /* YouTube Row */
        { icon: "youtube", style: { fontSize: "14px", color: "#FF0000" } },
        { str: " @z0x_-bloxd\n", style: { color: "#FF0000", fontWeight: "bold" } },
        
        /* Extras Row*/
        { str: "————————————————————————\n", style: { color: "lightgrey", fontWeight: "bold", fontSize: "15px" } },
        { icon: "star", style: { fontSize: "14px", color: "#FFFFA6" } },
        { str: " Make sure to check the Info warp!\n Type !rtp to get started!\n", style: { color: "#FFFFA6", fontWeight: "bold" } },
        { str: "————————————————————————", style: { color: "lightgrey", fontWeight: "bold", fontSize: "15px" } },
        
    ]);

    /* 3. Send the chat messages instantly */
    api.sendMessage(playerId, "—— Welcome to šŸ‰ Watermelon-SMP šŸ’¦! ——", { color: "red", fontWeight: "bold" });
    api.sendMessage(playerId, "šŸ“ Latest Updates šŸ“:", { color: "gold" });
    api.sendMessage(playerId, "— New GUI for sidebar and Suggestion Box at spawn.\n— Forge has been RELEASED! (extras at ItzStubZ's Plot)\n— MOON IS OUT SORTA, still not finished tho.\n", { color:   "white" });
    api.sendMessage(playerId, "—————————————————", { color: "red" });
}

function setMusic(playerId) {
    api.setClientOption(
        playerId,
        "music",
        "Epic1"
    );

    api.setClientOption(
        playerId,
        "musicVolumeLevel",
        0.6
    );
}


/* ================
    RANKS SYSTEM & RTP COMMAND
   ================ */

function onPlayerChat(id, msg) {
    // 1. RTP COMMAND CHECK (Checks if any player typed !rtp)
    if (msg.trim() === "!rtp") {
        // Generates random coordinates between -100,000 and 100,000
        const x = Math.floor(200000 * Math.random() - 100000);
        const z = Math.floor(200000 * Math.random() - 100000);
        const y = 125; // Safe standard height above ground level
        
        // Teleports the player
        api.setPosition(id, [x, y, z]);
        
        // Sends a private confirmation message to that specific player
 

        // Stops the function here so '!rtp' doesn't show up in global chat
        return false;
    }

    // 2. EXISTING RANK SYSTEM
    let name = api.getEntityName(id);
    
// Windows7601
    if (name === "Windows7601") {
        api.broadcastMessage([
            { str: "[", style: { color: "white" } }, { icon: "question-mark", style: { color: "lightgrey" } }, { str: "IDK", style: { color: "lightgrey" } }, { str: "] ", style: { color: "white" } },
 
            { str: "Windows7601: ", style: { color: "white" } },
            { str: " " + msg, style: { color: "white" } }
        ]);
        return false;
    } 
// ItzStubZ brother
    if (name === "Tiny_asian_Squirtle") {
        api.broadcastMessage([
            /*discord*/
            { icon: "discord", style: { color: "#5865F2" } }, { str: " ", style: { color: "white" } },
            
            { str: "[", style: { color: "white" } }, { icon: "cog", style: { color: "lightgrey" } }, { str: "Clan", style: { color: "lightgrey" } }, { str: "ker Jr.", style: { color: "lightgrey" } }, { str: "] ", style: { color: "white" } },
 
            { str: "Tiny_asian_Squirtle: ", style: { color: "white" } },
            { str: " " + msg, style: { color: "white" } }
        ]);
        return false;
    } 
    // ItzStubZ
    if (name === "ItzStubZ") {
        api.broadcastMessage([
            /*discord*/
            { icon: "discord", style: { color: "#5865F2" } }, { str: " ", style: { color: "white" } },
            
            { str: "[", style: { color: "white" } }, { icon: "cog", style: { color: "lightgrey" } }, { str: "Clan", style: { color: "lightgrey" } }, { str: "ker", style: { color: "lightgrey" } }, { str: "] ", style: { color: "white" } },
            
 { str: "[", style: { color: "red" } }, { icon: "Watermelon Slice", style: { color: "lightgrey" } }, { str: "Watermelon", style: { color: "lime" } }, { str: "]", style: { color: "red" } },
            
            { str: "[", style: { color: "cyan" } }, { icon: "cog", style: { color: "cyan" } }, { str: " Programmer] ", style: { color: "cyan" } },
            
            { str: "ItzStubZ: ", style: { color: "gold" } },
            { str: " " + msg, style: { color: "white" } }
        ]);
        return false;
    }
    // z0x_
    if (name === "z0x_") {
        api.broadcastMessage([
            /*discord*/
            { icon: "discord", style: { color: "red" } }, { str: " ", style: { color: "white" } },
            
            { str: " [", style: { color: "red" } }, { icon: "Damage", style: { color: "red" } }, { str: "PvPer", style: { color: "red" } }, { str: "] ", style: { color: "red" } },
            { str: "𖤓 z0x_: ", style: { color: "red" } },
            { str: " " + msg, style: { color: "white" } }
        ]);
        return false;
    }
    // Cyber_NebulaX
    if (name === "Cyber_NebulaX") {
        api.broadcastMessage([
                    { str: "[", style: { color: "brown" } }, { icon: "Mob Slayer", style: { color: "red" } }, { str: "Survivor", style: { color: "red" } }, { str: "] ", style: { color: "brown" } },
            { str: "[", style: { color: "purple" } }, { icon: "star", style: { color: "purple" } }, { str: "Nebula", style: { color: "purple" } }, { str: "] ", style: { color: "purple" } },
            { str: "[", style: { color: "#3D2D3C" } }, { icon: "shield", style: { color: "#5C3E5A" } }, { str: "M", style: { color: "#73416F" } }, { str: "A", style: { color: "#94478E" } }, { str: "X", style: { colour: "#A845A0" } }, { str: "] ", style: {colour: "#C93CBE" } },
            { str: "Cyber_NebulaX: ", style: { color: "#A746B8" } },
            { str: " " + msg, style: { color: "white" } }
        ]);
        return false;
    }
    // Drellie1
    if (name === "Drellie1") {
        api.broadcastMessage([
            { str: "[", style: { color: "purple" } }, { icon: "star", style: { color: "purple" } }, { str: "Nebula", style: { color: "purple" } }, { str: "] ", style: { color: "purple" } },
            { str: "[", style: { color: "red" } }, { icon: "swords", style: { color: "red" } }, { str: "Killer", style: { color: "red" } }, { str: "] ", style: { color: "red" } },
            { str: "Drellie1: ", style: { color: "orange" } },
            { str: " " + msg, style: { color: "white" } }
        ]);
        return false;
    }

    // ZaLegend
    if (name === "ZaLegend") {
        api.broadcastMessage([
            /*discord*/
            { icon: "discord", style: { color: "#5865F2" } }, { str: " ", style: { color: "white" } },
            { str: "ZaLegend: ", style: { color: "white" } },
            { str: " " + msg, style: { color: "white" } }
        ]);
        return false;
    }
}
/* Global variables to manage the weapon systems */
if (typeof magmaWandCooldowns === "undefined") {
    var magmaWandCooldowns = {};
}
if (typeof magmaWandTimers === "undefined") {
    var magmaWandTimers = {};
}

/* Global dictionary to manage weapon timestamps */
if (typeof magmaWandCooldowns === "undefined") {
    var magmaWandCooldowns = {};
}

/* Custom Weapon Abilities & Right-Click Magma Wand Functionality */

/* Triggered whenever a player right-clicks or interacts while holding an item */
onPlayerAltAction = (playerId) => {
    try {
        const heldItem = api.getHeldItem(playerId);
        if (!heldItem) return;

        /* Checks for a Molten Magma Rod specifically named Magma Wand */
        if (
            heldItem.name === "Molten Magma Rod" && 
            heldItem.attributes && 
            heldItem.attributes.customDisplayName === "Magma Wand"
        ) {
            const currentTime = Date.now();
            const lastUsed = magmaWandCooldowns[playerId] || 0;
            const cooldownDuration = 2500; /* 2.5 seconds */

            /* Blocks firing if 2.5 seconds have not passed */
            if (currentTime - lastUsed < cooldownDuration) {
                return;
            }

            const playerPos = api.getPosition(playerId);
            if (playerPos && Array.isArray(playerPos)) {
                const px = playerPos[0];
                const py = playerPos[1];
                const pz = playerPos[2];

                /* Get looking direction to fire the fireballs forward */
                let facing = [0, 0, -1]; 
                const facingInfo = api.getPlayerFacingInfo ? api.getPlayerFacingInfo(playerId) : null;
                if (facingInfo && facingInfo.dir) {
                    facing = facingInfo.dir;
                }

                const fx = facing[0];
                const fy = facing[1];
                const fz = facing[2];

                /* Set the cooldown timestamp immediately before firing */
                magmaWandCooldowns[playerId] = currentTime;

                /* LAUNCH 9 FIREBALLS IN A COMPACT, SMALLER 3x3 SQUARE GRID PATTERN */
                
                /* MIDDLE ROW (Eye Level - Small 0.08 spacing) */
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx, fy, fz], 2, 2, 0); 
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx - 0.08, fy, fz + 0.08], 2, 2, 0); 
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx + 0.08, fy, fz - 0.08], 2, 2, 0); 

                /* TOP ROW (Tighter vertical offset) */
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx, fy + 0.08, fz], 2, 2, 0); 
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx - 0.08, fy + 0.08, fz + 0.08], 2, 2, 0); 
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx + 0.08, fy + 0.08, fz - 0.08], 2, 2, 0); 

                /* BOTTOM ROW (Tighter vertical offset) */
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx, fy - 0.08, fz], 2, 2, 0); 
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx - 0.08, fy - 0.08, fz + 0.08], 2, 2, 0); 
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx + 0.08, fy - 0.08, fz - 0.08], 2, 2, 0); 
            }
        }
    } catch (err) {
        api.log("Error in Magma Wand Right-Click: " + err);
    }
};

/* Global dictionary to manage weapon timestamps */
if (typeof magmaWandCooldowns === "undefined") {
    var magmaWandCooldowns = {};
}

/* Custom Weapon Abilities & Right-Click Magma Wand Functionality */

/* Triggered whenever a player right-clicks or interacts while holding an item */
onPlayerAltAction = (playerId) => {
    try {
        const heldItem = api.getHeldItem(playerId);
        if (!heldItem) return;

        /* Checks for a Molten Magma Rod specifically named Magma Wand */
        if (
            heldItem.name === "Molten Magma Rod" && 
            heldItem.attributes && 
            heldItem.attributes.customDisplayName === "Magma Wand"
        ) {
            const currentTime = Date.now();
            const lastUsed = magmaWandCooldowns[playerId] || 0;
            const cooldownDuration = 2500; /* 2.5 seconds in milliseconds */

            /* FIXED: Blocks firing instantly if 2.5 seconds have not passed */
            if (currentTime - lastUsed < cooldownDuration) {
                return;
            }

            const playerPos = api.getPosition(playerId);
            if (playerPos && Array.isArray(playerPos)) {
                const px = playerPos[0];
                const py = playerPos[1];
                const pz = playerPos[2];

                /* Get looking direction to fire the fireballs forward */
                let facing = [0, 0, -1]; 
                const facingInfo = api.getPlayerFacingInfo ? api.getPlayerFacingInfo(playerId) : null;
                if (facingInfo && facingInfo.dir) {
                    facing = facingInfo.dir;
                }

                const fx = facing[0];
                const fy = facing[1];
                const fz = facing[2];

                /* Set the cooldown timestamp immediately before firing */
                magmaWandCooldowns[playerId] = currentTime;

                /* LAUNCH 9 FIREBALLS IN A 3x3 SQUARE GRID PATTERN */
                
                /* MIDDLE ROW (Eye Level) */
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx, fy, fz], 2, 2, 0); 
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx - 0.2, fy, fz + 0.2], 2, 2, 0); 
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx + 0.2, fy, fz - 0.2], 2, 2, 0); 

                /* TOP ROW (Angled Upward) */
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx, fy + 0.2, fz], 2, 2, 0); 
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx - 0.2, fy + 0.2, fz + 0.2], 2, 2, 0); 
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx + 0.2, fy + 0.2, fz - 0.2], 2, 2, 0); 

                /* BOTTOM ROW (Angled Downward) */
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx, fy - 0.2, fz], 2, 2, 0); 
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx - 0.2, fy - 0.2, fz + 0.2], 2, 2, 0); 
                api.attemptCreateThrowable(playerId, "Fireball", [px, py + 1.5, pz], [fx + 0.2, fy - 0.2, fz - 0.2], 2, 2, 0); 
            }
        }
    } catch (err) {
        api.log("Error in Magma Wand Right-Click: " + err);
    }
};

/* Triggered when damaging players with standard weapons */
onPlayerDamagingOtherPlayer = (attackerId, targetId, damageAmount, itemName, bodyPartHit, damagerDbId) => {
    try {
        const heldItem = api.getHeldItem(attackerId);
        if (!heldItem) return;

        /* Abyssal Sword */
        if (
            heldItem.name === "Knight Sword" && 
            heldItem.attributes && 
            heldItem.attributes.customDisplayName === "Abyssal Sword"
        ) {
            api.applyEffect(targetId, "Weakness", 5000, { displayName: "Weakness", icon: "Weakness" });
            api.applyEffect(targetId, "Blindness", 5000, { displayName: "Blind", icon: "Blindness" });
        }

        /* Sun Blade */
        if (
            heldItem.name === "Gold Sword" && 
            heldItem.attributes && 
            heldItem.attributes.customDisplayName === "Sun Blade"
        ) {
            api.applyEffect(targetId, "Blindness", 5000, { displayName: "Flashbanged", icon: "Blindness" });
            api.applyEffect(targetId, "Poisoned", 5000, { displayName: "Flamed", icon: "Fire Resistance" });
        }

        /* Poison knife */
        if (
            heldItem.name === "Iron Dagger" && 
            heldItem.attributes && 
            heldItem.attributes.customDisplayName === "Poison Knife"
        ) {
            api.applyEffect(targetId, "Weakness", 5000, { displayName: "Weakness", icon: "Weakness" });
            api.applyEffect(targetId, "Poisoned", 2500, { displayName: "Poisoned", icon: "Poisoned" });
        }

        /* frost whip */
        if (
            heldItem.name === "Diamond Whip" &&
            heldItem.attributes && 
            heldItem.attributes.customDisplayName === "Frost Whip"
        ) {
            api.applyEffect(targetId, "Frozen", 1000, { displayName: "Frozen", icon: "Frozen" });
            api.applyEffect(targetId, "Slowness", 2500, { displayName: "Icey", icon: "Slowness" });
        }

        /* Wind Mace */
        if (
            heldItem.name === "Moonstone Mace" && 
            heldItem.attributes && 
            heldItem.attributes.customDisplayName === "Wind Mace"
        ) {
            const attackerPos = api.getPosition(attackerId);
            if (!attackerPos || !Array.isArray(attackerPos)) return;

            const x = attackerPos[0];
            const y = attackerPos[1];
            const z = attackerPos[2];

            if (y - Math.floor(y) > 0.1) {
                api.applyHealthChange(targetId, -20, attackerId);
                api.applyEffect(targetId, "Slowness", 5000, {
                    icon: "Slowness",
                    displayName: "Slammed",
                    inbuiltLevel: 2
                });
                api.setVelocity(attackerId, 0, 20, 0);
                
                /* FIXED: Fully restored all array values to prevent unexpected comma crashes */
                api.playParticleEffect({
                    dir1: [-3, -3, -3],
                    dir2: [3, 3, 3], 
                    pos1: [x - 3, y, z - 3],
                    pos2: [x + 3, y + 3, z + 3],
                    texture: "glint",
                    minLifeTime: 0.3,
                    maxLifeTime: 1,
                    minEmitPower: 3,
                    maxEmitPower: 5,
                    minSize: 0.3,
                    maxSize: 0.7,
                    manualEmitCount: 100,
                    gravity: [0, -5, 0],
                    colorGradients: [
                        { 
                            timeFraction: 0, 
                            minColor: [200, 200, 255], 
                            maxColor: [255, 255, 255] 
                        }
                    ],
                    velocityGradients: [
                        { 
                            timeFraction: 0, 
                            factor: 1, 
                            factor2: 1 
                        }
                    ],
                    blendMode: 1
                });

                return "preventDamage";
            }
        }
    } catch (err) {
        api.log("Error in Weapon Script: " + err);
    }
};

function tick() {
    const now = Date.now();

    for (const playerId of api.getPlayerIds()) {
        if (!musicStartTimes[playerId]) {
            startEpicMusic(playerId);
            continue;
        }

        if (now - musicStartTimes[playerId] >= MUSIC_LOOP_TIME) {
            startEpicMusic(playerId);
        }
    }
}
content_copyCOPY