const x = 160;
const y = 115;
const z = 183.5;
var RedTeamPlayers = 0;
var BlueTeamPlayers = 0;
let redScore = 0;
let blueScore = 0;
const scoredMobs = new Set();
const redGoalMin = [154, 101, 234.5];
const redGoalMax = [166, 105, 238];
const blueGoalMin = [154, 101, 131.5];
const blueGoalMax = [166, 105, 128];
let tickTimer = 0;
let elapsedTime = 0;
const gameDuration = 5 * 60 * 1000; // 5 minutes
let gameOver = false;
let resetTimer = 0;
const resetCountdown = 15 * 1000; // 15 seconds
function SpawnBall() {
const x = 160;
const y = 115;
const z = 183.5;
const mobId = [Link]("Pig", x, y + 1, z, {
name: "Ball"})
[Link](x , y , z , "Invisible Solid")
[Link]([168,101,191],[152,101,175],"Air")
[Link]([168,102,191],[152,102,175],"Air")
[Link]([168,103,191],[152,103,175],"Air")
[Link]([162 , 103 , 191] , [158 , 101 , 191] , "Invisible Solid")
[Link]([162 , 103 , 175] , [158 , 101 , 175] , "Invisible Solid")
[Link]([168 , 103 , 185] , [168 , 101 , 181] , "Invisible Solid")
[Link]([152 , 103 , 185] , [152 , 101 , 181] , "Invisible Solid")
[Link]([157 , 103 , 190] , [156 , 101 , 190] , "Invisible Solid")
[Link]([164 , 103 , 190] , [163 , 101 , 190] , "Invisible Solid")
[Link]([168 , 103 , 185] , [168 , 101 , 181] , "Invisible Solid")
[Link]([152 , 103 , 185] , [152 , 101 , 181] , "Invisible Solid")
[Link]([167 , 103 , 187] , [167 , 101 , 186] , "Invisible Solid")
[Link]([167 , 103 , 180] , [167 , 101 , 179] , "Invisible Solid")
[Link]([153 , 103 , 187] , [153 , 101 , 186] , "Invisible Solid")
[Link]([153 , 103 , 180] , [153 , 101 , 179] , "Invisible Solid")
[Link]([164 , 103 , 176] , [163 , 101 , 176] , "Invisible Solid")
[Link]([156 , 103 , 176] , [157 , 101 , 176] , "Invisible Solid")
[Link]([166 , 103 , 188] , [166 , 101 , 188] , "Invisible Solid")
[Link]([165 , 103 , 189] , [165 , 101 , 189] , "Invisible Solid")
[Link]([155 , 103 , 189] , [155 , 101 , 189] , "Invisible Solid")
[Link]([154 , 103 , 188] , [154 , 101 , 188] , "Invisible Solid")
[Link]([154 , 103 , 178] , [154 , 101 , 178] , "Invisible Solid")
[Link]([155 , 103 , 177] , [155 , 101 , 177] , "Invisible Solid")
[Link]([165 , 103 , 177] , [165 , 101 , 177] , "Invisible Solid")
[Link]([166 , 103 , 178] , [166 , 101 , 178] , "Invisible Solid")
;
if (mobId) {
[Link](mobId, "maxHealth", 9999999999);
[Link](mobId, 9999999999);
[Link](mobId, "Frozen", 99999999, { inbuiltLevel: 9999 });
}
}
function formatTime(ms) {
const totalSec = [Link](ms / 1000);
const min = [Link](totalSec / 60).toString().padStart(1, '0');
const sec = (totalSec % 60).toString().padStart(2, '0');
return `${min}:${sec}`;
}
function updateRightInfo(playerId) {
let lines = [
{ str: `⚽Football⚽`, style: { color: "yellow" , fontSize: "20px" } },
{ str: `\n🔴 Red: ${redScore}`, style: { color: "#FF0000" } },
{ str: ` - `, style: { color: "#FFFFFF" } },
{ str: `${blueScore} :Blue 🔵`, style: { color: "#0000FF" } },
];
if (!gameOver) {
[Link](
{ str: `\n Time Left: ${formatTime(gameDuration - elapsedTime)} `, style: { color:
"#FFFFFF" } },
{ str: `\n🔴 ${RedTeamPlayers} `, style: { color: "#FF0000" } },
{ str: ` v `, style: { color: "#FFFFFF" } },
{ str: ` ${BlueTeamPlayers} 🔵`, style: { color: "#0000FF" } },
);
} else {
[Link]({ str: `\n🏁 Game Over! 🏁`, style: { color: "#FFD700" } });
[Link]({ str: `\n🔄 Restarting in ${[Link]((resetCountdown -
resetTimer) / 1000)}s🔄`, style: { color: "#AAAAAA" } });
}
[Link](playerId, "RightInfoText", lines);
}
onPlayerJoin = (playerId) => {
[Link](playerId)
updateRightInfo(playerId);
[Link](playerId, [216.50, 101, 183.50])
// Only spawn ball if this is the first player joining
if ([Link]() === 1) {
SpawnBall();
[Link]("Game Started⚽", { color: "red" })
}
};
onPlayerDamagingMob = (playerId, mobId, damageDealt, withItem) => {
const facing = [Link](playerId);
if (!facing || ![Link]) return;
const dir = [Link];
const length = [Link](dir[0] ** 2 + dir[1] ** 2 + dir[2] ** 2);
if (length === 0) return;
const held = [Link](playerId);
const name = held?.attributes?.customDisplayName;
if (!name || [Link]() === "null") return;
let vy = 0;
let knockbackStrength = 75;
if (name === "Power Shot") {
vy = 10;
knockbackStrength = 80;
} else if (name === "Lob") {
vy = 40;
knockbackStrength = 60;
} else if (name === "Pass") {
vy = -5;
knockbackStrength = 40;
} else if (name === "Dribble") {
vy = -5;
knockbackStrength = 25;
}
const vx = (dir[0] / length) * knockbackStrength;
const vz = (dir[2] / length) * knockbackStrength;
[Link](mobId, vx, vy, vz);
};
tick = (ms) => {
tickTimer += ms;
for (const playerId of [Link]()) {
if ([Link]([Link](playerId), [155 , 101 , 234.25] , [166 ,
104 , 236] , false)||[Link]([Link](playerId), [155 , 101 ,
131.75] , [166 , 104 , 130] , false)) {
[Link](playerId , [187.5 , 101 , 183.5])
[Link](playerId , "[⚠ WARNING ⚠] DO NOT ENTER GOALS!" , {color :
"yellow"})
}
if (gameOver) {
resetTimer += ms;
if (resetTimer >= resetCountdown) {
// Reset game
redScore = 0;
blueScore = 0;
[Link]();
tickTimer = 0;
elapsedTime = 0;
resetTimer = 0;
gameOver = false;
[Link](" New match started!");
const allMobs = [Link]();
[Link](mobId => {
[Link](mobId);
});
SpawnBall();
}
for (const id of [Link]()) {
updateRightInfo(id);
}
return;
}
elapsedTime += ms;
if (elapsedTime >= gameDuration) {
gameOver = true;
let winner = "Draw!";
if (redScore > blueScore) winner = "🔴 Red Team Wins!";
else if (blueScore > redScore) winner = "🔵 Blue Team Wins!";
[Link](`🏁 Game Over! ${winner}`);
return;
}
if (tickTimer < 1000) return;
tickTimer = 0;
if ((gameDuration - elapsedTime) == 150000) {
[Link]("HALF TIME!! Gigajaat_Tappu is Owner")
}
if ([Link](x,y,z) == "Lime Concrete") {
[Link](x , y , z , "Air")
[Link]([168,101,191],[152,101,175],"Air")
[Link]([168,102,191],[152,102,175],"Air")
[Link]([168,103,191],[152,103,175],"Air")
for (const playerId of [Link]()) {
if ([Link]([Link](playerId), [192 , 101 , 169] , [175 , 103 ,
152] , false)) {
[Link](playerId , [184.5 , 101 , 183.5])
}
if ([Link](x,y,z) == "Yellow Concrete") {
[Link](x , y , z , "Lime Concrete")
for (const playerId of [Link]()) {
if ([Link]([Link](playerId), [192 , 101 , 169] , [175 , 103 ,
152] , false)) {
[Link](playerId , [184.5 , 101 , 183.5])
}
}
if ([Link](x,y,z) == "Red Concrete") {
[Link](x , y , z , "Yellow Concrete")
for (const playerId of [Link]()) {
if ([Link]([Link](playerId), [192 , 101 , 169] , [175 , 103 ,
152] , false)) {
[Link](playerId , [184.5 , 101 , 183.5])
}
}
if ([Link](x,y,z) == "Invisible Solid") {
[Link](x , y , z , "Red Concrete")
for (const playerId of [Link]()) {
if ([Link]([Link](playerId), [192 , 101 , 169] , [175 , 103 ,
152] , false)) {
[Link](playerId , [184.5 , 101 , 183.5])
}
}
RedTeamPlayers = 0;
BlueTeamPlayers = 0;
for (const playerId of [Link]()) {
if ([Link](playerId, "Red Wood Chestplate")) {
RedTeamPlayers += 1;
}
else if ([Link](playerId, "Blue Wood Chestplate")) {
BlueTeamPlayers += 1;
}
[Link](playerId, "canPickUpItems", false)
}
const redZoneMobs = [Link](redGoalMin, redGoalMax);
const blueZoneMobs = [Link](blueGoalMin, blueGoalMax);
for (const mobId of redZoneMobs) {
if () {
[Link](mobId);
blueScore++;
[Link](mobId);
[Link](`⚽GOAL!⚽`);
[Link](`🔵 Blue scored! Blue: ${blueScore} | 🔴 Red: ${redScore}`);
SpawnBall();
}
}
for (const mobId of blueZoneMobs) {
if () {
[Link](mobId);
redScore++;
[Link](mobId);
[Link](`⚽GOAL!⚽`);
[Link](`🔴 Red scored! Red: ${redScore} | 🔵 Blue: ${blueScore}`);
SpawnBall();
}
}
for (const id of [Link]()) {
updateRightInfo(id);
}
};
function onItemDropCreated(a) {
[Link](a)
}