Open IvanBre opened 4 years ago
Hello. Here is a votekick system. But it works based on the players' name, not the ID. I hope it will helpful for you.
const votedPlayers = new Set() //The set of players which were voted.
var votekickInfoInterval; //The interval for information message about votekick.
var votekickInfoIntervalTime = 180000; //The time for the interval to be reset. (180000 means 180 seconds, you are free to change it according to your preference.)
let votekickTimes = {}; //This holds the amount of votes which the players used.
let votekickCount = {}; //This holds the amount of votes which were done against each of the players.
var votekickTimeout = 60000; //If votekick doesn't reach a result, then it's reset after 60 seconds. (60000 means 60 seconds, you are free to change it according to your preference.)
var PlayerFound = false; //If voted player doesn't exist, then this is false. Initial value: false.
function votekickRemove(player) {
votekickCount[player.id] = [];
var players = room.getPlayerList();
for(var i=0; i<players.length; i++){
if(votedPlayers.has(players[i].id)==true){
votedPlayers.delete(players[i].id);
}
}
}
function votekickCheck(player){
if((room.getPlayerList().length)%2 == 0){
if(votekickCount[player.id].length >= (room.getPlayerList().length)*1/2){
room.kickPlayer(player.id,"You've kicked by vote.",false);
}
else{
room.sendAnnouncement("🗳️ " + player.name + " : " + votekickCount[player.id].length + "/" + (room.getPlayerList().length)*1/2,null,0xFFFFFF,"normal",1);
}
}
else if((room.getPlayerList().length)%2 == 1){
if(votekickCount[player.id].length >= Math.round((room.getPlayerList().length)*1/2)){
room.kickPlayer(player.id,"You've kicked by vote.",false);
}
else{
room.sendAnnouncement("🗳️ " + player.name + " : " + votekickCount[player.id].length + "/" + Math.round((room.getPlayerList().length)*1/2),null,0xFFFFFF,"normal",1);
}
}
}
room.onPlayerJoin = function(player){
votekickCount[player.id] = []; //This is needed to hold the amount of the votes against a player.
}
room.onPlayerLeave = function(player){
delete votekickCount[player.id]; //Delete the votes used against the player.
delete votekickTimes[player.id]; //Delete the votes used by the player.
}
room.onPlayerChat = function(player,msg){
if(msg.startsWith("!votekick ")==true){
playerFound = false;
players = room.getPlayerList();
for(var i=0; i<players.length; i++){
if(msg === ("!votekick " + players[i].name)){
if(room.getPlayerList().length < 4){ //If there's less than 4 players. Don't do vote because of trolls can easily abuse it.
room.sendAnnouncement("There's not enough players to do voting.",player.id,0xFF0000,"bold",2);
return false;
}
if(players[i].name==player.name){ //You shouldn't vote yourself.
room.sendAnnouncement("You cannot vote yourself.",player.id,0xFF0000,"bold",2);
return false;
}
if(votedPlayers.has(player.id)){ //If you voted a player, then you have to wait the timeout to finish.
room.sendAnnouncement("Please wait " + votekickTimeout/1000 + " seconds to vote again.",player.id,0xFF0000,"bold",2);
return false;
}
votedPlayers.add(player.id);
playerFound = true;
if(votekickCount[players[i].id].indexOf(players[i]) === -1){
votekickCount[players[i].id].push(player);
}
votekickTimes[players[i].id] = setTimeout(votekickRemove, votekickTimeout, players[i]); //Start the timeout after the player was voted.
votekickCheck(players[i]); //Do votekick check for the player who was voted.
}
}
if(playerFound === false){ //If there's no such a player, then here is called.
playersString = "";
for(i=0; i<players.length; i++){
playersString = playersString + players[i].name + ", ";
}
room.sendAnnouncement("There's no such a player. Here is the list for available players: " + playersString,player.id,0xFFFF00,"normal",1);
}
return false;
}
}
votekickInfoInterval = setInterval(function(){room.sendAnnouncement("You can type !votekick [player_name] (for example: !votekick IvanBre) to kick a player in the room by voting. The voting system does not work if there are less than 4 people in the room.",null,0xFFFFFF,"normal",1);},votekickInfoIntervalTime);
Wow! Thank you, You are awesome <3
You are welcome, dude. :)
@thenorthstar can I contact you on another website?
Hello. Here is a votekick system. But it works based on the players' name, not the ID. I hope it will helpful for you.
const votedPlayers = new Set() //The set of players which were voted. var votekickInfoInterval; //The interval for information message about votekick. var votekickInfoIntervalTime = 180000; //The time for the interval to be reset. (180000 means 180 seconds, you are free to change it according to your preference.) let votekickTimes = {}; //This holds the amount of votes which the players used. let votekickCount = {}; //This holds the amount of votes which were done against each of the players. var votekickTimeout = 60000; //If votekick doesn't reach a result, then it's reset after 60 seconds. (60000 means 60 seconds, you are free to change it according to your preference.) var PlayerFound = false; //If voted player doesn't exist, then this is false. Initial value: false. function votekickRemove(player) { votekickCount[player.id] = []; var players = room.getPlayerList(); for(var i=0; i<players.length; i++){ if(votedPlayers.has(players[i].id)==true){ votedPlayers.delete(players[i].id); } } } function votekickCheck(player){ if((room.getPlayerList().length)%2 == 0){ if(votekickCount[player.id].length >= (room.getPlayerList().length)*1/2){ room.kickPlayer(player.id,"You've kicked by vote.",false); } else{ room.sendAnnouncement("🗳️ " + player.name + " : " + votekickCount[player.id].length + "/" + (room.getPlayerList().length)*1/2,null,0xFFFFFF,"normal",1); } } else if((room.getPlayerList().length)%2 == 1){ if(votekickCount[player.id].length >= Math.round((room.getPlayerList().length)*1/2)){ room.kickPlayer(player.id,"You've kicked by vote.",false); } else{ room.sendAnnouncement("🗳️ " + player.name + " : " + votekickCount[player.id].length + "/" + Math.round((room.getPlayerList().length)*1/2),null,0xFFFFFF,"normal",1); } } } room.onPlayerJoin = function(player){ votekickCount[player.id] = []; //This is needed to hold the amount of the votes against a player. } room.onPlayerLeave = function(player){ delete votekickCount[player.id]; //Delete the votes used against the player. delete votekickTimes[player.id]; //Delete the votes used by the player. } room.onPlayerChat = function(player,msg){ if(msg.startsWith("!votekick ")==true){ playerFound = false; players = room.getPlayerList(); for(var i=0; i<players.length; i++){ if(msg === ("!votekick " + players[i].name)){ if(room.getPlayerList().length < 4){ //If there's less than 4 players. Don't do vote because of trolls can easily abuse it. room.sendAnnouncement("There's not enough players to do voting.",player.id,0xFF0000,"bold",2); return false; } if(players[i].name==player.name){ //You shouldn't vote yourself. room.sendAnnouncement("You cannot vote yourself.",player.id,0xFF0000,"bold",2); return false; } if(votedPlayers.has(player.id)){ //If you voted a player, then you have to wait the timeout to finish. room.sendAnnouncement("Please wait " + votekickTimeout/1000 + " seconds to vote again.",player.id,0xFF0000,"bold",2); return false; } votedPlayers.add(player.id); playerFound = true; if(votekickCount[players[i].id].indexOf(players[i]) === -1){ votekickCount[players[i].id].push(player); } votekickTimes[players[i].id] = setTimeout(votekickRemove, votekickTimeout, players[i]); //Start the timeout after the player was voted. votekickCheck(players[i]); //Do votekick check for the player who was voted. } } if(playerFound === false){ //If there's no such a player, then here is called. playersString = ""; for(i=0; i<players.length; i++){ playersString = playersString + players[i].name + ", "; } room.sendAnnouncement("There's no such a player. Here is the list for available players: " + playersString,player.id,0xFFFF00,"normal",1); } return false; } } votekickInfoInterval = setInterval(function(){room.sendAnnouncement("You can type !votekick [player_name] (for example: !votekick IvanBre) to kick a player in the room by voting. The voting system does not work if there are less than 4 people in the room.",null,0xFFFFFF,"normal",1);},votekickInfoIntervalTime);
kanka şimdi bunu ekledım çalıstırdım chate yazı yazınca bota msg hatası düştü bende botuma göre message olarak hatayı düzenledim tekrar denedım busefer yazı yazdıgın gibi bu hata düşüyor
TypeError: message.startsWith is not a function
at room.onPlayerChat (
msg.startsWith("!votekick ")==true){ playerFound = false; players = room.getPlayerList(); for(var i=0; i<players.length; i++){ if(msg === buradaki 2 msg yide message olarak güncelledim hata devam ediyor aynı hata
Hello. Here is a votekick system. But it works based on the players' name, not the ID. I hope it will helpful for you.
const votedPlayers = new Set() //The set of players which were voted. var votekickInfoInterval; //The interval for information message about votekick. var votekickInfoIntervalTime = 180000; //The time for the interval to be reset. (180000 means 180 seconds, you are free to change it according to your preference.) let votekickTimes = {}; //This holds the amount of votes which the players used. let votekickCount = {}; //This holds the amount of votes which were done against each of the players. var votekickTimeout = 60000; //If votekick doesn't reach a result, then it's reset after 60 seconds. (60000 means 60 seconds, you are free to change it according to your preference.) var PlayerFound = false; //If voted player doesn't exist, then this is false. Initial value: false. function votekickRemove(player) { votekickCount[player.id] = []; var players = room.getPlayerList(); for(var i=0; i<players.length; i++){ if(votedPlayers.has(players[i].id)==true){ votedPlayers.delete(players[i].id); } } } function votekickCheck(player){ if((room.getPlayerList().length)%2 == 0){ if(votekickCount[player.id].length >= (room.getPlayerList().length)*1/2){ room.kickPlayer(player.id,"You've kicked by vote.",false); } else{ room.sendAnnouncement("🗳️ " + player.name + " : " + votekickCount[player.id].length + "/" + (room.getPlayerList().length)*1/2,null,0xFFFFFF,"normal",1); } } else if((room.getPlayerList().length)%2 == 1){ if(votekickCount[player.id].length >= Math.round((room.getPlayerList().length)*1/2)){ room.kickPlayer(player.id,"You've kicked by vote.",false); } else{ room.sendAnnouncement("🗳️ " + player.name + " : " + votekickCount[player.id].length + "/" + Math.round((room.getPlayerList().length)*1/2),null,0xFFFFFF,"normal",1); } } } room.onPlayerJoin = function(player){ votekickCount[player.id] = []; //This is needed to hold the amount of the votes against a player. } room.onPlayerLeave = function(player){ delete votekickCount[player.id]; //Delete the votes used against the player. delete votekickTimes[player.id]; //Delete the votes used by the player. } room.onPlayerChat = function(player,msg){ if(msg.startsWith("!votekick ")==true){ playerFound = false; players = room.getPlayerList(); for(var i=0; i<players.length; i++){ if(msg === ("!votekick " + players[i].name)){ if(room.getPlayerList().length < 4){ //If there's less than 4 players. Don't do vote because of trolls can easily abuse it. room.sendAnnouncement("There's not enough players to do voting.",player.id,0xFF0000,"bold",2); return false; } if(players[i].name==player.name){ //You shouldn't vote yourself. room.sendAnnouncement("You cannot vote yourself.",player.id,0xFF0000,"bold",2); return false; } if(votedPlayers.has(player.id)){ //If you voted a player, then you have to wait the timeout to finish. room.sendAnnouncement("Please wait " + votekickTimeout/1000 + " seconds to vote again.",player.id,0xFF0000,"bold",2); return false; } votedPlayers.add(player.id); playerFound = true; if(votekickCount[players[i].id].indexOf(players[i]) === -1){ votekickCount[players[i].id].push(player); } votekickTimes[players[i].id] = setTimeout(votekickRemove, votekickTimeout, players[i]); //Start the timeout after the player was voted. votekickCheck(players[i]); //Do votekick check for the player who was voted. } } if(playerFound === false){ //If there's no such a player, then here is called. playersString = ""; for(i=0; i<players.length; i++){ playersString = playersString + players[i].name + ", "; } room.sendAnnouncement("There's no such a player. Here is the list for available players: " + playersString,player.id,0xFFFF00,"normal",1); } return false; } } votekickInfoInterval = setInterval(function(){room.sendAnnouncement("You can type !votekick [player_name] (for example: !votekick IvanBre) to kick a player in the room by voting. The voting system does not work if there are less than 4 people in the room.",null,0xFFFFFF,"normal",1);},votekickInfoIntervalTime);
kanka şimdi bunu ekledım çalıstırdım chate yazı yazınca bota msg hatası düştü bende botuma göre message olarak hatayı düzenledim tekrar denedım busefer yazı yazdıgın gibi bu hata düşüyor TypeError: message.startsWith is not a function at room.onPlayerChat (:929:13) at Aa.u.ef (headless-min.js:64) at Object.Rf (headless-min.js:111) at Fa.zh (headless-min.js:51) at Fa.wh (headless-min.js:50) at Na.a.$e (headless-min.js:47) at RTCDataChannel.Na.e.onmessage (headless-min.js:9)
msg.startsWith("!votekick ")==true){ playerFound = false; players = room.getPlayerList(); for(var i=0; i<players.length; i++){ if(msg === buradaki 2 msg yide message olarak güncelledim hata devam ediyor aynı hata
@qoksel00 Tahmin ediyorum odanda noPlayer:true özelliği aktif değil yani spec'te pingi 0 olarak duran host oyuncu mevcut. Eğer böyleyse host oyuncuyu kaldırıp tekrar dene. Yine aynı hata oluşursa benim yapabileceğim bir şey yok çünkü aklıma gelen tek ihtimal bu.
Nedeni de şu: room.onPlayerJoin içerisinde şöyle bir kod satırı var: votekickCount[player.id] = []. Bu satır odaya giren oyunculara aleyhlerinde oy atılabilmesi için bir alan açıyor fakat host oyuncu oda tarafından otomatik oluşturulduğu (yani room.onPlayerJoin olay yakalayıcısına girmediği) için bu oyuncunun aleyhinde oy atılabilmesi için bir alan açılmamış oluyor ve sen de !votekick komutunu kullandığında odan patlıyor. Yani sen oradaki mesaj argümanını ne olarak değiştirirsen değiştir, host oyuncuyu kaldırmadığın sürece odan patlamaya devam eder.
O kadar şeyi yazmışken yapman gereken değişikliği de söyleyeyim:
var room = HBInit({roomName:"Room Name", noPlayer:true, public:true, maxPlayers:12});
noPlayer:true,
kanka dedigin gibi bot kullanıcısnı kaldırdıgım zaman botta sürekli odaya girdigim gibi oda donuyor panele bu hata dusuyor true yi false yapınca hata dusmuyor ama bu sefer bot yine odada duruyor
1473 satırındaki bu kodu gosteriyor bot
if (byPlayer.id != 0 && localStorage.getItem(getAuth(byPlayer)) && JSON.parse(localStorage.getItem(getAuth(byPlayer)))[Ss.RL] == "admin") {
Uncaught (in promise) TypeError: Cannot read property 'id' of null
at room.onPlayerAdminChange (
şu şekilde yaptım ama dedigim gibi ustteki hata dusuyor bot odada olmuyor ama girdigin gibi oyun donuyor waazar94 botunu kullanıyorum aşşağıya bu şekilde ekledım sondaki bot name player nameyi kaldırıp denedım yine olmadı const room = HBInit({ roomName: roomName, noPlayer:true, maxPlayers: maxPlayers, public: roomPublic, playerName: botName, geo: geo[0] });
@basro, @thenorthstar Why double voting is allowed after leave the room and re-enter? Maybe you can update it?
@basro, @thenorthstar Why double voting is allowed after leave the room and re-enter? Maybe you can update it?
@azagni You can set it based on the auth property so one cannot vote others after re-joining. So, how you can do this? Let me explain:
votedPlayers.add(player.id); You have to change this player.id as player.auth in some manner (you have to store player auth somewhere and use it as player.auth or something similar, or write a function which gets auth by ID). Also you have to change the related zones from id to auth.
@basro Hello, can you show the edited version?
@basro Hello, can you show the edited version?
@azagni You can try coding some stuff instead of waiting it from others.
@thenorthstar You are right, i tried but i got bad actor when searching related zones.
@thenorthstar You are right, i tried but i got bad actor when searching related zones.
@azagni OK. I understood. Maybe tomorrow I will post some stuff about this here if I'm available.
@thenorthstar You are right, i tried but i got bad actor when searching related zones.
@azagni OK. I understood. Maybe tomorrow I will post some stuff about this here if I'm available. bot kullanıcısını kaldırdım yine aynı hatayı alıyorum anlamadım neyse saol kardeşim
@thenorthstar You are right, i tried but i got bad actor when searching related zones.
@azagni OK. I understood. Maybe tomorrow I will post some stuff about this here if I'm available.
@thenorthstar Hi. What's up?
@thenorthstar You are right, i tried but i got bad actor when searching related zones.
@azagni OK. I understood. Maybe tomorrow I will post some stuff about this here if I'm available.
@thenorthstar Hi. What's up?
@azagni Fine man, it's OK in my opinion but you can test it and report the potential issues here.
(Note: The new scripts have been compiled from my own bot scripts so some content maybe different.)
@thenorthstar You are right, i tried but i got bad actor when searching related zones.
@azagni OK. I understood. Maybe tomorrow I will post some stuff about this here if I'm available.
@thenorthstar Hi. What's up?
@azagni Fine man, it's OK in my opinion but you can test it and report the potential issues here.
(Note: The new scripts have been compiled from my own bot scripts so some content maybe different.)
kanka bu attıgında ne gibi değişiklikler var acaba soylermısın kısaca
@thenorthstar You are right, i tried but i got bad actor when searching related zones.
@azagni OK. I understood. Maybe tomorrow I will post some stuff about this here if I'm available.
@thenorthstar Hi. What's up?
@azagni Fine man, it's OK in my opinion but you can test it and report the potential issues here. VoteBan.txt (Note: The new scripts have been compiled from my own bot scripts so some content maybe different.)
kanka bu attıgında ne gibi değişiklikler var acaba soylermısın kısaca
@qoksel00 Önceki versiyonda oylar !votekick + isim ile kullanılıyordu; şimdiyse !voteban + ID ile kullanılıyor. Kick/ban olayına takılma bu arada, kendi botumdaki koddan derlediğim için öyle. Diğer fark ise şu, önceki versiyonda oyuncunun aleyhine kullanılan oylar oyuncunun ID'sinde tutuluyor yani oyuncu çıkıp girdiğinde oyları sıfırlanıyor, bundaysa oylar oyuncunun auth'unda (localStorage yardımıyla) tutuluyor ve oyuncu çıkıp girse bile oyları sıfırlanmıyor.
Hello. Here is a votekick system. But it works based on the players' name, not the ID. I hope it will helpful for you.
const votedPlayers = new Set() //The set of players which were voted. var votekickInfoInterval; //The interval for information message about votekick. var votekickInfoIntervalTime = 180000; //The time for the interval to be reset. (180000 means 180 seconds, you are free to change it according to your preference.) let votekickTimes = {}; //This holds the amount of votes which the players used. let votekickCount = {}; //This holds the amount of votes which were done against each of the players. var votekickTimeout = 60000; //If votekick doesn't reach a result, then it's reset after 60 seconds. (60000 means 60 seconds, you are free to change it according to your preference.) var PlayerFound = false; //If voted player doesn't exist, then this is false. Initial value: false. function votekickRemove(player) { votekickCount[player.id] = []; var players = room.getPlayerList(); for(var i=0; i<players.length; i++){ if(votedPlayers.has(players[i].id)==true){ votedPlayers.delete(players[i].id); } } } function votekickCheck(player){ if((room.getPlayerList().length)%2 == 0){ if(votekickCount[player.id].length >= (room.getPlayerList().length)*1/2){ room.kickPlayer(player.id,"You've kicked by vote.",false); } else{ room.sendAnnouncement("🗳️ " + player.name + " : " + votekickCount[player.id].length + "/" + (room.getPlayerList().length)*1/2,null,0xFFFFFF,"normal",1); } } else if((room.getPlayerList().length)%2 == 1){ if(votekickCount[player.id].length >= Math.round((room.getPlayerList().length)*1/2)){ room.kickPlayer(player.id,"You've kicked by vote.",false); } else{ room.sendAnnouncement("🗳️ " + player.name + " : " + votekickCount[player.id].length + "/" + Math.round((room.getPlayerList().length)*1/2),null,0xFFFFFF,"normal",1); } } } room.onPlayerJoin = function(player){ votekickCount[player.id] = []; //This is needed to hold the amount of the votes against a player. } room.onPlayerLeave = function(player){ delete votekickCount[player.id]; //Delete the votes used against the player. delete votekickTimes[player.id]; //Delete the votes used by the player. } room.onPlayerChat = function(player,msg){ if(msg.startsWith("!votekick ")==true){ playerFound = false; players = room.getPlayerList(); for(var i=0; i<players.length; i++){ if(msg === ("!votekick " + players[i].name)){ if(room.getPlayerList().length < 4){ //If there's less than 4 players. Don't do vote because of trolls can easily abuse it. room.sendAnnouncement("There's not enough players to do voting.",player.id,0xFF0000,"bold",2); return false; } if(players[i].name==player.name){ //You shouldn't vote yourself. room.sendAnnouncement("You cannot vote yourself.",player.id,0xFF0000,"bold",2); return false; } if(votedPlayers.has(player.id)){ //If you voted a player, then you have to wait the timeout to finish. room.sendAnnouncement("Please wait " + votekickTimeout/1000 + " seconds to vote again.",player.id,0xFF0000,"bold",2); return false; } votedPlayers.add(player.id); playerFound = true; if(votekickCount[players[i].id].indexOf(players[i]) === -1){ votekickCount[players[i].id].push(player); } votekickTimes[players[i].id] = setTimeout(votekickRemove, votekickTimeout, players[i]); //Start the timeout after the player was voted. votekickCheck(players[i]); //Do votekick check for the player who was voted. } } if(playerFound === false){ //If there's no such a player, then here is called. playersString = ""; for(i=0; i<players.length; i++){ playersString = playersString + players[i].name + ", "; } room.sendAnnouncement("There's no such a player. Here is the list for available players: " + playersString,player.id,0xFFFF00,"normal",1); } return false; } } votekickInfoInterval = setInterval(function(){room.sendAnnouncement("You can type !votekick [player_name] (for example: !votekick IvanBre) to kick a player in the room by voting. The voting system does not work if there are less than 4 people in the room.",null,0xFFFFFF,"normal",1);},votekickInfoIntervalTime);
geçersiz bi isim girdiğimizde bize oyuncu listesini atıyor fakat bu listede botta gözüküyor, noplayer yapmayı denedim fakat bu seferde bottaki diğer kısımlarda hata çıkmaya başladı(wazarr94 ün botunu kullanıyorum) bu listede botun gözükmemesi için ne yapmalıyım
Hello everyone!
I have programmed VPS Automated Room, and i need VoteKick function
If someone can help me i'll be grateful
Thanks !