KEMBAR78
Message | PDF
0% found this document useful (0 votes)
3 views6 pages

Message

Uploaded by

wwwwwwwwwwwdfe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Message

Uploaded by

wwwwwwwwwwwdfe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

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 = api.attemptSpawnMob("Pig", x, y + 1, z, {


name: "Ball"})
api.setBlock(x , y , z , "Invisible Solid")
api.setBlockRect([168,101,191],[152,101,175],"Air")
api.setBlockRect([168,102,191],[152,102,175],"Air")
api.setBlockRect([168,103,191],[152,103,175],"Air")
api.setBlockRect([162 , 103 , 191] , [158 , 101 , 191] , "Invisible Solid")
api.setBlockRect([162 , 103 , 175] , [158 , 101 , 175] , "Invisible Solid")
api.setBlockRect([168 , 103 , 185] , [168 , 101 , 181] , "Invisible Solid")
api.setBlockRect([152 , 103 , 185] , [152 , 101 , 181] , "Invisible Solid")
api.setBlockRect([157 , 103 , 190] , [156 , 101 , 190] , "Invisible Solid")
api.setBlockRect([164 , 103 , 190] , [163 , 101 , 190] , "Invisible Solid")
api.setBlockRect([168 , 103 , 185] , [168 , 101 , 181] , "Invisible Solid")
api.setBlockRect([152 , 103 , 185] , [152 , 101 , 181] , "Invisible Solid")
api.setBlockRect([167 , 103 , 187] , [167 , 101 , 186] , "Invisible Solid")
api.setBlockRect([167 , 103 , 180] , [167 , 101 , 179] , "Invisible Solid")
api.setBlockRect([153 , 103 , 187] , [153 , 101 , 186] , "Invisible Solid")
api.setBlockRect([153 , 103 , 180] , [153 , 101 , 179] , "Invisible Solid")
api.setBlockRect([164 , 103 , 176] , [163 , 101 , 176] , "Invisible Solid")
api.setBlockRect([156 , 103 , 176] , [157 , 101 , 176] , "Invisible Solid")
api.setBlockRect([166 , 103 , 188] , [166 , 101 , 188] , "Invisible Solid")
api.setBlockRect([165 , 103 , 189] , [165 , 101 , 189] , "Invisible Solid")
api.setBlockRect([155 , 103 , 189] , [155 , 101 , 189] , "Invisible Solid")
api.setBlockRect([154 , 103 , 188] , [154 , 101 , 188] , "Invisible Solid")
api.setBlockRect([154 , 103 , 178] , [154 , 101 , 178] , "Invisible Solid")
api.setBlockRect([155 , 103 , 177] , [155 , 101 , 177] , "Invisible Solid")
api.setBlockRect([165 , 103 , 177] , [165 , 101 , 177] , "Invisible Solid")
api.setBlockRect([166 , 103 , 178] , [166 , 101 , 178] , "Invisible Solid")
;
if (mobId) {
api.setMobSetting(mobId, "maxHealth", 9999999999);
api.setHealth(mobId, 9999999999);
api.applyEffect(mobId, "Frozen", 99999999, { inbuiltLevel: 9999 });
}
}

function formatTime(ms) {
const totalSec = Math.floor(ms / 1000);
const min = Math.floor(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) {
lines.push(
{ 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 {
lines.push({ str: `\n🏁 Game Over! 🏁`, style: { color: "#FFD700" } });
lines.push({ str: `\n🔄 Restarting in ${Math.ceil((resetCountdown -
resetTimer) / 1000)}s🔄`, style: { color: "#AAAAAA" } });
}

api.setClientOption(playerId, "RightInfoText", lines);


}

onPlayerJoin = (playerId) => {


api.clearInventory(playerId)
updateRightInfo(playerId);
api.setPosition(playerId, [216.50, 101, 183.50])

// Only spawn ball if this is the first player joining


if (api.getNumPlayers() === 1) {
SpawnBall();
api.broadcastMessage("Game Started⚽", { color: "red" })
}
};

onPlayerDamagingMob = (playerId, mobId, damageDealt, withItem) => {


const facing = api.getPlayerFacingInfo(playerId);
if (!facing || !facing.dir) return;

const dir = facing.dir;


const length = Math.sqrt(dir[0] ** 2 + dir[1] ** 2 + dir[2] ** 2);
if (length === 0) return;

const held = api.getHeldItem(playerId);


const name = held?.attributes?.customDisplayName;
if (!name || name.toLowerCase() === "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;

api.setVelocity(mobId, vx, vy, vz);


};

tick = (ms) => {


tickTimer += ms;

for (const playerId of api.getPlayerIds()) {

if (api.isInsideRect(api.getPosition(playerId), [155 , 101 , 234.25] , [166 ,


104 , 236] , false)||api.isInsideRect(api.getPosition(playerId), [155 , 101 ,
131.75] , [166 , 104 , 130] , false)) {

api.setPosition(playerId , [187.5 , 101 , 183.5])


api.sendMessage(playerId , "[⚠ WARNING ⚠] DO NOT ENTER GOALS!" , {color :
"yellow"})
}

if (gameOver) {
resetTimer += ms;
if (resetTimer >= resetCountdown) {
// Reset game
redScore = 0;
blueScore = 0;
scoredMobs.clear();
tickTimer = 0;
elapsedTime = 0;
resetTimer = 0;
gameOver = false;
api.broadcastMessage(" New match started!");
const allMobs = api.getMobIds();

allMobs.forEach(mobId => {
api.despawnMob(mobId);
});

SpawnBall();
}

for (const id of api.getPlayerIds()) {


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!";

api.broadcastMessage(`🏁 Game Over! ${winner}`);


return;
}

if (tickTimer < 1000) return;


tickTimer = 0;

if ((gameDuration - elapsedTime) == 150000) {


api.broadcastMessage("HALF TIME!! Gigajaat_Tappu is Owner")
}

if (api.getBlock(x,y,z) == "Lime Concrete") {


api.setBlock(x , y , z , "Air")
api.setBlockRect([168,101,191],[152,101,175],"Air")
api.setBlockRect([168,102,191],[152,102,175],"Air")
api.setBlockRect([168,103,191],[152,103,175],"Air")
for (const playerId of api.getPlayerIds()) {
if (api.isInsideRect(api.getPosition(playerId), [192 , 101 , 169] , [175 , 103 ,
152] , false)) {
api.setPosition(playerId , [184.5 , 101 , 183.5])
}

if (api.getBlock(x,y,z) == "Yellow Concrete") {


api.setBlock(x , y , z , "Lime Concrete")
for (const playerId of api.getPlayerIds()) {
if (api.isInsideRect(api.getPosition(playerId), [192 , 101 , 169] , [175 , 103 ,
152] , false)) {
api.setPosition(playerId , [184.5 , 101 , 183.5])
}
}

if (api.getBlock(x,y,z) == "Red Concrete") {


api.setBlock(x , y , z , "Yellow Concrete")
for (const playerId of api.getPlayerIds()) {
if (api.isInsideRect(api.getPosition(playerId), [192 , 101 , 169] , [175 , 103 ,
152] , false)) {
api.setPosition(playerId , [184.5 , 101 , 183.5])
}

}
if (api.getBlock(x,y,z) == "Invisible Solid") {
api.setBlock(x , y , z , "Red Concrete")

for (const playerId of api.getPlayerIds()) {


if (api.isInsideRect(api.getPosition(playerId), [192 , 101 , 169] , [175 , 103 ,
152] , false)) {
api.setPosition(playerId , [184.5 , 101 , 183.5])
}

}
RedTeamPlayers = 0;
BlueTeamPlayers = 0;
for (const playerId of api.getPlayerIds()) {
if (api.hasItem(playerId, "Red Wood Chestplate")) {
RedTeamPlayers += 1;
}
else if (api.hasItem(playerId, "Blue Wood Chestplate")) {
BlueTeamPlayers += 1;
}
api.setClientOption(playerId, "canPickUpItems", false)
}

const redZoneMobs = api.getEntitiesInRect(redGoalMin, redGoalMax);


const blueZoneMobs = api.getEntitiesInRect(blueGoalMin, blueGoalMax);

for (const mobId of redZoneMobs) {


if (!scoredMobs.has(mobId)) {
api.despawnMob(mobId);
blueScore++;
scoredMobs.add(mobId);
api.broadcastMessage(`⚽GOAL!⚽`);
api.broadcastMessage(`🔵 Blue scored! Blue: ${blueScore} | 🔴 Red: ${redScore}`);
SpawnBall();
}
}

for (const mobId of blueZoneMobs) {


if (!scoredMobs.has(mobId)) {
api.despawnMob(mobId);
redScore++;
scoredMobs.add(mobId);
api.broadcastMessage(`⚽GOAL!⚽`);
api.broadcastMessage(`🔴 Red scored! Red: ${redScore} | 🔵 Blue: ${blueScore}`);
SpawnBall();
}
}

for (const id of api.getPlayerIds()) {


updateRightInfo(id);
}
};

function onItemDropCreated(a) {
api.deleteItemDrop(a)
}

You might also like