// 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;
}
}
/*custom weapon abilities*/
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"
});
// Forces dark theme overlay
api.applyEffect(targetId, "Blindness", 5000, {
displayName: "Blind",
icon: "Blindness"
});
}
/*Sun Blade*/
if (
heldItem.name === "Gold Sword" &&
heldItem.attributes &&
heldItem.attributes.customDisplayName === "Sun Blade"
) {
// Forces bright flashbang theme overlay
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"
});
}
/* Mace */
if (
heldItem.name === "Moonstone Mace" &&
heldItem.attributes &&
heldItem.attributes.customDisplayName === "Wind Mace"
) {
const attackerPos = api.getPosition(attackerId);
if (!attackerPos) return;
const x = attackerPos[0];
const y = attackerPos[1];
const z = attackerPos[2];
/* FIXED: Checks the Y coordinate array index to see if the attacker is airborne */
if (y - Math.floor(y) > 0.1) {
/* Deal bonus damage directly */
api.applyHealthChange(targetId, -20, attackerId);
/* Apply Slowness effect to the target */
api.applyEffect(targetId, "Slowness", 5000, {
icon: "Slowness",
displayName: "Slammed",
inbuiltLevel: 2
});
/* Launch attacker upward to give slam effect */
api.setVelocity(attackerId, 0, 20, 0);
/* FIXED: Reconstructed missing array parameters to prevent parsing 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
});
/* Prevent default damage to avoid doubling */
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);
}
}
}