Open pog666 opened 3 years ago
up
up...
When you set an avatar from a player, you are overwriting his personal choice. When you set avatar to null, his original avatar shows back.
The code could be something near this:
const secondsToResetAvatar = 3;
room.onTeamGoal = function(team) {
let players = room.getPlayerList();
for (let i = 0; i < players.length; i++) {
if (players[i].team == team) room.setPlayerAvatar(players[i].id, "⚽️");
}
setTimeout(() => {
for (let i = 0; i < players.length; i++) {
room.setPlayerAvatar(players[i].id, null);
}
}, secondsToResetAvatar * 1000);
}
I see, what about, a script that does the same thing, but only for the player who scored ?
I see, what about, a script that does the same thing, but only for the player who scored ?
You have to implement a system to record who is the last player who touched the ball.
Ok, by the way the first code isn't working it seems like, can you give me an example of the code when only the scorer gets an avatar change ?
Ok, by the way the first code isn't working it seems like, can you give me an example of the code when only the scorer gets an avatar change ?
Code working: https://jsfiddle.net/fjxsey03/ Video of the code working: https://www.youtube.com/watch?v=P_11jvJeuFE
I got in my room some functions to get who is the scorer of the goals. So I just set the avatar from that player.
Yeah nevermind, i didn't saw there were already a onTeamGoal function in my original code, works good. Thanks!
^^
I got in my room some functions to get who is the scorer of the goals. So I just set the avatar from that player.
Actually, i would like to have it, if i am not asking too much, would be cool, and with the script that changes then.
I got in my room some functions to get who is the scorer of the goals. So I just set the avatar from that player.
Actually, i would like to have it, if i am not asking too much, would be cool, and with the script that changes then.
Check his code https://github.com/Wazarr94/haxball_bot_headless , I use his system. Look into the onTeamGoal function.
Check his code https://github.com/Wazarr94/haxball_bot_headless , I use his system. Look into the onTeamGoal function.
Okay, i see now, i guess i will stay on the first code you gave me, by the way, can you help me again? How to put this script:
room.onTeamGoal = function(team) {
let players = room.getPlayerList();
for (let i = 0; i < players.length; i++) {
if (players[i].team == team) room.setPlayerAvatar(players[i].id, "⚽️");
}
setTimeout(() => {
for (let i = 0; i < players.length; i++) {
room.setPlayerAvatar(players[i].id, null);
}
}, secondsToResetAvatar * 1000);
}
in this:
room.onTeamGoal = function(_0xdb6ax73) {
var _0xdb6ax97 = room.getScores().time ;
firstTickAfterPause = false;
scores = room.getScores();
goalScored = true;
timebetongk = _0xdb6ax97 + 3.0;
timebetonpole = _0xdb6ax97 + 3.0;
goalMessage(_0xdb6ax73);
if(tercion < 5) {
if(_0xdb6ax73 == 1) {
matchRedGoals++
} else {
matchBlueGoals++
};
if(tercion < 4) {
room.sendAnnouncement('[Official] Match state: ' + redname + ' ' + matchRedGoals + ' - ' + matchBlueGoals + ' ' + bluename, null, 0x00ff44, 'bold', 0)
}
};
if(tercion == 5) {
if(_0xdb6ax73 == 1) {
penaltiesRedGoals++
} else {
penaltiesBlueGoals++
}
};
if(tercion < 3 && _0xdb6ax97 >= 300) {
koniecTercjiKaryPrzechodza(scores)
};
if(tercion == 3 && _0xdb6ax97 > 300 && matchRedGoals != matchBlueGoals) {
room.sendAnnouncement('[Official] The match has ended! ' + redname + ' ' + matchRedGoals + ' - ' + matchBlueGoals + ' ' + bluename, null, 0x00ff44, 'bold', 0);
CleanSheetsSummary(scores);
teamPossFun();
periodResult.push({
period: tercion,
redscore: scores.red ,
bluescore: scores.blue
});
howEnd = 'Regular time';
rec = room.stopRecording();
saveRec(rec);
saveStats();
room.sendAnnouncement('[Official] Replay has been saved', null, 0x8ed2ab, 'bold', 0);
room.stopGame();
getStatsFun();
resetStatsMatch();
firstTickAfterPause = false
};
if(tercion == 3 && _0xdb6ax97 > 300 && matchRedGoals == matchBlueGoals) {
koniecTercjiKaryPrzechodza(scores)
};
if(tercion == 4) {
room.sendAnnouncement('[Official] The match has ended! ' + redname + ' ' + matchRedGoals + ' - ' + matchBlueGoals + ' ' + bluename, null, 0x00ff44, 'bold', 0);
howEnd = 'OVERTIME';
CleanSheetsSummary(scores);
teamPossFun();
periodResult.push({
period: 'OVERTIME',
redscore: scores.red ,
bluescore: scores.blue
});
rec = room.stopRecording();
saveRec(rec);
saveStats();
room.sendAnnouncement('[Official] Replay has been saved', null, 0x8ed2ab, 'bold', 0);
room.stopGame();
getStatsFun();
redname = 'RED';
bluename = 'BLUE';
resetStatsMatch();
firstTickAfterPause = false
};
whoTouchedBall = [];
whoTouchedLast = undefined;
checked3 = false;
for(var i = 0; i < betonPlayers.length ; i++) {
if(betonPlayers[i].team != _0xdb6ax73) {
betonPlayers[i].value = 0;
room.sendAnnouncement(betonPlayers[i].player .name + '\'s penalty has been shortened due to lost goal by his team.', null, 0xffffff, 'bold', 0)
}
}
};
which is working? That's the last thing i will ask for, I promise.
You should change this part of the code:
let players = room.getPlayerList();
if(tercion < 5) {
if(_0xdb6ax73 == 1) {
matchRedGoals++
// set avatar of red players to ⚽️
for (let i = 0; i < players.length; i++)
if (players[i].team == 1) room.setPlayerAvatar(players[i].id, "⚽️");
} else {
matchBlueGoals++
// set avatar of blue players to ⚽️
for (let i = 0; i < players.length; i++)
if (players[i].team == 2) room.setPlayerAvatar(players[i].id, "⚽️");
};
// set a timer of secondsToResetAvatar seconds to reset the avatars
setTimeout(() => { for (let i = 0; i < players.length; i++) room.setPlayerAvatar(players[i].id, null); }, secondsToResetAvatar * 1000);
if(tercion < 4) {
room.sendAnnouncement('[Official] Match state: ' + redname + ' ' + matchRedGoals + ' - ' + matchBlueGoals + ' ' + bluename, null, 0x00ff44, 'bold', 0)
}
};
if(tercion == 5) {
if(_0xdb6ax73 == 1) {
penaltiesRedGoals++
// set avatar of red players to ⚽️
for (let i = 0; i < players.length; i++)
if (players[i].team == 1) room.setPlayerAvatar(players[i].id, "⚽️");
} else {
penaltiesBlueGoals++
// set avatar of blue players to ⚽️
for (let i = 0; i < players.length; i++)
if (players[i].team == 2) room.setPlayerAvatar(players[i].id, "⚽️");
}
// set a timer of secondsToResetAvatar seconds to reset the avatars
setTimeout(() => { for (let i = 0; i < players.length; i++) room.setPlayerAvatar(players[i].id, null); }, secondsToResetAvatar * 1000);
};
Thanks!
@csvergaraa
Do you have discord or something? I would like to ask you for other things, if not i can post it here.
can you share the bot with me @pog666
So basically, i'm trying to do a script that gives every member of a team the same avatar when a goal is scored by their team, until positions are reset. I tried something with onTeamGoal, setPlayerAvatar and onPositionsReset, but as far as i know there isn't a way to stock players avatar, so I am now blocked.. Is there a way to make it work? Maybe instead of using onPositionsReset, put a timer after the goal on setPlayerAvatar or something else?