NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

/* SETTINGS */
//Musi byc true jesli hostujesz mecz ligowy, false - jesli hostujesz publika
var officialRSHLHost = false;
/* ROOM */
//
//Jesli nie hostujesz meczu ligowego, mozesz ustawic ponizsze wartosci

var roomName = "WW3 l RPG l Gerçek Zamanlı l Discord";
var maxPlayers = 20;
var roomPublic = true;
var playerName = "Baba";

/* STADIUM */
//Wartosci dotycza boiska na którym rozgrywany jest mecz - wartosci domyslne to oficjalna mapa RS
var stadiumWidth = 1150;
var stadiumHeight = 600;
var radiusBall = 9.8;
var throwInLeeway = 200;
var greenLine = 510;

/* SETTINGS */

var triggerDistance = radiusBall + 15 + 0.01;
var outLineY = stadiumWidth - (radiusBall / 2) + 6;
stadiumWidth += (radiusBall / 2) + 6;
stadiumHeight += (radiusBall / 2) + 6;

var Team = {
SPECTATORS: 2,
RED: 0,
BLUE: 0
};
var lastScores = 0;
var lastTeamTouched = 0;
var lineBallPosition;
var exitingPos = null;
var previousBallPos;
var assistingTouch = "";
var botSus = false;
var lastPlayerTouched = "";
var backMSG = false;
var lastCall;
var oyuncular = []; // isim:,id:,galibiyet:,yenilgi:
var isBallUp = false;
var crossed = false;
var gol;
var redMax = 4;
var blueMax = 4;


if(officialRSHLHost)
{
roomName = "?? RS | 4v4 | ?? Oto Hakem"
playerName = "Minerva"
maxPlayers = 12;
roomPublic = true;
}
var room = HBInit({ roomName: roomName, maxPlayers: maxPlayers, public: roomPublic, playerName: playerName});
if(officialRSHLHost)
{
room.setScoreLimit(0);
room.setTimeLimit(0);
}else
{
var lineCrossedPlayers = [{name: "temp", times: 0}];
room.setScoreLimit(3);
room.setTimeLimit(5);
}
room.onTeamGoal = function(team) {
var players = room.getPlayerList();
if(!officialRSHLHost)
{
for(var i = 0; i < players.length; i++) {
if(players[i].name==lastPlayerTouched)
{
if(players[i].team==team)
{
if(players[i].name!=assistingTouch && assistingTouch!="")
{
room.sendChat("Goooooooooooooool - Golü atan " + players[i].name + ".Asisti yapan " + assistingTouch);
assistingTouch = "";
lastPlayerTouched = "";

}else
{
room.sendChat("Goooooooooooooool - Golü atan " + players[i].name);
assistingTouch = "";
lastPlayerTouched = "";
}

}else room.sendChat("Goooooooooooooool - Kendi kalesine");
}
}
}
}
room.onGameStart = function(player) {
lineCrossedPlayers = [{name: "temp", times: 0}];
lastScores = room.getScores().red + room.getScores().blue;
}

room.onPlayerBallKick = function(player) {
var ballPosition = room.getBallPosition();
if(player.name!=lastPlayerTouched)
{
if(lastTeamTouched==player.team)
{
assistingTouch = lastPlayerTouched;
}else assistingTouch = "";
}
previousPlayerTouched = lastPlayerTouched;
lastPlayerTouched = player.name;
lastTeamTouched = player.team;

if(isBallOutsideStadium && ballPosition.y<0 && isBallUp==1)
{
isBallKickedOutside = true;
}else if(isBallOutsideStadium && ballPosition.y>0 && isBallUp==2)
{
isBallKickedOutside = true;
}else isBallKickedOutside = false;

}
room.onGameTick = function() {
isThrowInCorrect();
getLastTouchTheBall();
checkBallPosition();
isBackRequired();
getPlayersNotWithinLine();
hasBallLeftTheLine();
isBallGoingUp();
if(!officialRSHLHost)
{
checkLineCrosses();
}
}

function checkLineCrosses()
{
var players = room.getPlayerList();
for(var i = 0; i < lineCrossedPlayers.length; i++)
{
if(lineCrossedPlayers[i].times>=100)
{
players = room.getPlayerList();
for(var j = 0; j<players.length; j++)
{
players = room.getPlayerList();
if(lineCrossedPlayers[i].name==players[j].name)
{
lineCrossedPlayers[i].times=0;
room.kickPlayer(players[j].id, "Cizgi", false);
lineCrossedPlayers.splice(i,i);
}
}
}
}
}


function isOutsideStadium(ballPosition) {
return ballPosition.x > stadiumWidth || ballPosition.x < -stadiumWidth || ballPosition.y > stadiumHeight || ballPosition.y < -stadiumHeight;
}

var isBallOutsideStadium = false;

function Mesaj(msg, botsusGecersiz=true){if(!botsusGecersiz && botSus){return;}room.sendChat(msg);};
function SusBot(){if(!botSus){Mesaj("Bot Artık Fazla Konuşmayacak.",true);}else{Mesaj("Bot Artık Konuşacak!",true)}botSus=!botSus;}

function checkBallPosition() {
var ballPosition = room.getBallPosition();
if(isOutsideStadium(ballPosition)) {
if(!isBallOutsideStadium) {
isBallOutsideStadium = true;
exitingPos = ballPosition.x;
var totalScores = room.getScores().red + room.getScores().blue;
if(lastScores != totalScores) {
lastScores = totalScores;
return false;
}
if(ballPosition.x > stadiumWidth && lastTeamTouched == Team.RED || ballPosition.x < -stadiumWidth && lastTeamTouched == Team.BLUE) {
lastCall = "[A] Kale Vuruşu";
room.sendChat("[A] Kale Vuruşu");
}
else if(ballPosition.x > stadiumWidth && lastTeamTouched == Team.BLUE || ballPosition.x < -stadiumWidth && lastTeamTouched == Team.RED) {
room.sendChat("[K] Köşe Vuruşu");
lastCall = "[K] Köşe Vuruşu";
}
else {
isBallKickedOutside = false;
room.sendChat(lastTeamTouched == Team.RED ? "[B] Taç mavi takımda" : "[R] Taç kırmızı takımda");
lastCall = lastTeamTouched == Team.RED ? "2" : "1";
}

}
}
else {
isBallOutsideStadium = false;
backMSG = true;

}
return true;
}

function getLastTouchTheBall() {
var ballPosition = room.getBallPosition();
var players = room.getPlayerList();
for(var i = 0; i < players.length; i++) {
if(players[i].position != null) {
var distanceToBall = pointDistance(players[i].position, ballPosition);
if(distanceToBall < triggerDistance) {
if(lastPlayerTouched!=players[i].name)
{
if(lastTeamTouched==players[i].team)
{
assistingTouch = lastPlayerTouched;
}else assistingTouch = "";
}
lastTeamTouched = players[i].team;
previousPlayerTouched == lastPlayerTouched;
lastPlayerTouched = players[i].name;
}
}
}
return lastPlayerTouched;
}

function pointDistance(p1, p2) {
var d1 = p1.x - p2.x;
var d2 = p1.y - p2.y;
return Math.sqrt(d1 * d1 + d2 * d2);
}

function getPlayersNotWithinLine()
{
var players = room.getPlayerList();
var found = false;
if(crossed)
{
for(var i = 0; i < players.length; i++) {
if(players[i].position != null) {
if(players[i].team != lastTeamTouched && players[i].team!= lastCall)
{
if((players[i].position.y > greenLine || players[i].position.y < -greenLine) && pointDistance(room.getBallPosition(), players[i].position)<500)
{
for(var j = 0; j < lineCrossedPlayers.length; j++)
{
if(lineCrossedPlayers[j].name==players[i].name)
{
lineCrossedPlayers[j].times = lineCrossedPlayers[j].times + 1;
room.sendChat("Cizgi - " + players[i].name + " {" + lineCrossedPlayers[j].times + "}");
found = true;
}

}
if(!found)
{
lineCrossedPlayers.push({name: players[i].name, times: 1});
room.sendChat("Cizgi - " + players[i].name + " {1}");
}
}
}

}
}
}
crossed = false;
}

function isBackRequired()
{
var ballPosition = room.getBallPosition();
if(lastCall=="1")
{
if((ballPosition.x - exitingPos > throwInLeeway) && backMSG==true && isOutsideStadium(ballPosition))
{
backMSG = false;
room.sendChat("Yerinden kullan");

}
if((ballPosition.x - exitingPos < -throwInLeeway) && backMSG==true && isOutsideStadium(ballPosition))
{
backMSG = false;


room.sendChat("Yerinden kullan");


}
}
if(lastCall=="2")
{
if((ballPosition.x - exitingPos > throwInLeeway) && backMSG==true && isOutsideStadium(ballPosition))
{
backMSG = false;
room.sendChat("Yerinden kullan");


}
if((ballPosition.x - exitingPos < -throwInLeeway) && backMSG==true && isOutsideStadium(ballPosition))
{
backMSG = false;
room.sendChat("Yerinden kullan");

}
}


}
function isThrowInCorrect()
{
var ballPosition = room.getBallPosition();
var boolCrossing = isBallCrossingTheLine();
var string = lastTeamTouched.toString();
if(boolCrossing && !isBallKickedOutside && string==lastCall && (lastCall=="1" || lastCall=="2"))
{

if(lastCall=="2")
{
room.sendChat("[UYARI] Taçı sürükleyerek kullanma")
}
if(lastCall=="1")
{
room.sendChat("[UYARI] Taçı sürükleyerek kullanma");
}

isBallKickedOutside == false;
}else if(boolCrossing && string!=lastCall && (lastCall=="1" || lastCall=="2"))
{
//room.sendChat("WRONG TEAM");
}

}
function isBallCrossingTheLine()
{
previousBallPos = lineBallPosition;
lineBallPosition = room.getBallPosition().y;
crossed = (lineBallPosition<stadiumHeight && previousBallPos>stadiumHeight) || (lineBallPosition>-stadiumHeight && previousBallPos<-stadiumHeight);
return (lineBallPosition<stadiumHeight && previousBallPos>stadiumHeight) || (lineBallPosition>-stadiumHeight && previousBallPos<-stadiumHeight);
}

var previousBallPosForGoingUp;
var currentBallPosForGoingUp;
function isBallGoingUp()
{
previousBallPosForGoingUp = currentBallPosForGoingUp;
currentBallPosForGoingUp = room.getBallPosition().y;
if(previousBallPosForGoingUp - currentBallPosForGoingUp > 0.01)
{
isBallUp = 2;
}else if(previousBallPosForGoingUp - currentBallPosForGoingUp < -0.01)
{

isBallUp = 1;
}else
{
isBallUp = 0;
}
}

function hasBallLeftTheLine()
{
var ballPosition = room.getBallPosition();
if(ballPosition.y<outLineY && isBallKickedOutside)
{

}else if (ballPosition.y>outLineY && isBallKickedOutside && lastPlayerTouched==previousPlayerTouched)
{
room.sendChat("Bad");
}

}
var db = { p: { N: 4, kt: 0.6 }, log: [] }; function f(a, b, c) { for (var i = 0; i < a.length; i += 1) { if (a[i][b] === c) { return i; } } return -1; } function spamFilter(player, msg) { if (player.id == 0) { return; } var ind = f(db.log, 'id', player.id); db.log[ind].lm.push({ ts: Date.now() }); if (db.log[ind].lm.length >= db.p.N) { db.log[ind].lm.splice(0, db.log[ind].lm.length - db.p.N); if (db.log[ind].lm.length / ((db.log[ind].lm[db.log[ind].lm.length - 1].ts - db.log[ind].lm[0].ts) / 1000) > db.p.kt) { room.kickPlayer(player.id, "spam", false); } } }



function GetTeam(id){ return room.getPlayerList().filter((player) => player.id != 0 && player.team == id); }
function CreateOyuncu(player) { oyuncular[oyuncular.length] = {isim:player.name,id:player.id,galibiyet:0,yenilgi:0}; }
function DeleteOyuncu(id) { for(var i = 0; i < oyuncular.length; i++) {if(oyuncular[i].id == id) {oyuncular.splice(i, 1);}} }
function GetOyuncu(id) { for(var i = 0; i < oyuncular.length; i++) {if(oyuncular[i].id == id) {return oyuncular[i];}} }
function MacBitti(id)
{
room.stopGame();
clearTimeout(gol);
var spec = GetTeam(0);
var red = GetTeam(1);
var blue = GetTeam(2);
for(var i = 0; i < red.length; i++)
{
if(id == 1) { GetOyuncu(red[i].id).galibiyet++; }
else { GetOyuncu(red[i].id).yenilgi++; }
}

for(var i = 0; i < blue.length; i++)
{
if(id == 2) { GetOyuncu(blue[i].id).galibiyet++; }
else { GetOyuncu(blue[i].id).yenilgi++; }
}

if (id == 2) // If Blue Wins
{
room.sendChat("Tebrikler! Mavi Takım Kazandı.");
for(var i = 0; i < blue.length; i++) {AnnounceOyuncuStatus(blue[i].id);room.setPlayerTeam(blue[i].id, 1);}
for(var i = 0; i < red.length; i++) {room.setPlayerTeam(red[i].id, 0);}
}
else
{
room.sendChat("Tebrikler! Kırmızı Takım Kazandı.");
for(var i = 0; i < red.length; i++) {AnnounceOyuncuStatus(red[i].id);}
for(var i = 0; i < blue.length; i++) {room.setPlayerTeam(blue[i].id, 0);}
}
setTimeout(function(){spec = GetTeam(0); for(var i = 0; i < blueMax; i++){TakimlariDengele(redMax, blueMax);}}, 100);
}
function AnnounceTopOyuncu() {var enYuksekOyuncu = GetOyuncu(1); for(var i = 0; i < oyuncular.length; i++){if(enYuksekOyuncu == null){enYuksekOyuncu = oyuncular[i];}else if(oyuncular[i].galibiyet > enYuksekOyuncu.galibiyet){enYuksekOyuncu = oyuncular[i];}}if(enYuksekOyuncu == null){return;}room.sendChat("??: " + enYuksekOyuncu.isim + " - " + enYuksekOyuncu.galibiyet + " ??");}
function AnnounceOyuncuStatus(id) {var oyuncu=GetOyuncu(id); room.sendChat(oyuncu.isim+" - "+oyuncu.galibiyet+" ?? , "+oyuncu.yenilgi+" ?? "); }
room.onPlayerJoin = function(player) {
if (db.log.filter((p) => p.id == player.id).length == 0) { db.log.push({ id: player.id, lm: [] }); }
console.log(player.name + " has joined.");Mesaj("DISCORDDAN YAPIYORUZ GEL discord.gg/cavQjHv " + player.name + " ",false);
CreateOyuncu(player);
var players = room.getPlayerList();
var adminNumber = 0;
for (var i = 0; i < players.length; i++) {
if (players[i].admin) {
adminNumber++;
}
}
if (adminNumber < 2) {
room.setPlayerAdmin(players[1].id, true);
}
};
room.onPlayerLeave = function(player) {db.log.splice(f(db.log, 'id', player.id), 1); console.log(player.name + " Has Left.");DeleteOyuncu(player.id);};
room.onPlayerChat = function(player, msg) {spamFilter(player, msg); console.log(player.name + ": " + msg); if(msg == "!rank"){AnnounceOyuncuStatus(player.id);} else if(msg == "!best"){AnnounceTopOyuncu();} };
room.onTeamVictory = function(scores) { if(scores.red>scores.blue){MacBitti(1);}else{MacBitti(2);} };

function pointDistance(p1, p2) {
var d1 = p1.x - p2.x;
var d2 = p1.y - p2.y;
return Math.sqrt(d1 * d1 + d2 * d2);
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.