Init scoreboard script

This commit is contained in:
Vortrex
2021-03-30 21:46:36 -05:00
parent 47f99404f7
commit 9f058ad777

View File

@@ -15,67 +15,85 @@ let pausedColour = COLOUR_RED;
let scoreboardKey = SDLK_TAB; let scoreboardKey = SDLK_TAB;
// ------------------------------------------------------------------------- // ===========================================================================
bindEventHandler("OnResourceReady", thisResource, function(event, resource) { function initScoreBoardScript() {
scoreBoardTitleFont = lucasFont.createDefaultFont(22.0, "Roboto", "Regular"); logToConsole(LOG_DEBUG, "[Asshat.ScoreBoard]: Initializing scoreboard script ...");
scoreBoardListFont = lucasFont.createDefaultFont(12.0, "Roboto", "Light"); scoreBoardTitleFont = initScoreBoardTitleFont();
}); scoreBoardListFont = initScoreBoardListFont();
logToConsole(LOG_DEBUG, "[Asshat.ScoreBoard]: Scoreboard script initialized!");
}
// ------------------------------------------------------------------------- // ===========================================================================
function processScoreboardRendering() { function initScoreBoardTitleFont() {
if(scoreBoardListFont != null && scoreBoardTitleFont != null) { return lucasFont.createDefaultFont(22.0, "Roboto", "Regular");
let scoreboardStart = (game.height/2)-(Math.floor(getClients().length/2)*20); }
let titleSize = scoreBoardTitleFont.measure("PLAYERS", game.width, 0.0, 1.0, 10, false, false);
scoreBoardTitleFont.render("PLAYERS", [game.width/2, scoreboardStart-50], 0, 0.5, 0.0, scoreBoardTitleFont.size, COLOUR_WHITE, false, false, false, true);
titleSize = scoreBoardTitleFont.measure("____________________________", game.width, 0.0, 1.0, 10, false, false); // ===========================================================================
scoreBoardTitleFont.render("____________________________", [game.width/2, scoreboardStart-35], 0, 0.5, 0.0, scoreBoardTitleFont.size, COLOUR_WHITE, false, false, false, true);
let clients = getClients(); function initScoreBoardListFont() {
for(let i in clients) { return lucasFont.createDefaultFont(12.0, "Roboto", "Light");
if(!clients[i].console) { }
let name = clients[i].name;
let colour = COLOUR_WHITE;
let paused = false;
let ping = "-1";
if(typeof playerNames[clients[i].name] != "undefined") { // ===========================================================================
name = playerNames[clients[i].name];
}
if(typeof playerPaused[clients[i].name] != "undefined") { function processScoreBoardRendering() {
paused = playerPaused[clients[i].name]; if(renderScoreBoard) {
} if(isKeyDown(SDLK_TAB)) {
if(scoreBoardListFont != null && scoreBoardTitleFont != null) {
let scoreboardStart = (game.height/2)-(Math.floor(getClients().length/2)*20);
let titleSize = scoreBoardTitleFont.measure("PLAYERS", game.width, 0.0, 1.0, 10, false, false);
scoreBoardTitleFont.render("PLAYERS", [game.width/2, scoreboardStart-50], 0, 0.5, 0.0, scoreBoardTitleFont.size, COLOUR_WHITE, false, false, false, true);
if(typeof playerColours[clients[i].name] != "undefined") { titleSize = scoreBoardTitleFont.measure("____________________________", game.width, 0.0, 1.0, 10, false, false);
colour = playerColours[clients[i].name]; scoreBoardTitleFont.render("____________________________", [game.width/2, scoreboardStart-35], 0, 0.5, 0.0, scoreBoardTitleFont.size, COLOUR_WHITE, false, false, false, true);
}
if(typeof playerPing[clients[i].name] != "undefined") { let clients = getClients();
ping = toString(playerPing[clients[i].name]); for(let i in clients) {
} if(!clients[i].console) {
let name = clients[i].name;
let colour = COLOUR_WHITE;
let paused = false;
let ping = "-1";
// Player ID if(typeof playerNames[clients[i].name] != "undefined") {
let text = String(clients[i].index); name = playerNames[clients[i].name];
let size = scoreBoardListFont.measure(text, 75, 0.0, 1.0, 10, false, false); }
scoreBoardListFont.render(text, [game.width/2-100, scoreboardStart + (i*20)], 0, 0.5, 0.0, scoreBoardListFont.size, COLOUR_WHITE, false, false, false, true);
// Player Name if(typeof playerPaused[clients[i].name] != "undefined") {
text = name; paused = playerPaused[clients[i].name];
size = scoreBoardListFont.measure(text, 100, 0.0, 1.0, 10, false, false); }
scoreBoardListFont.render(text, [game.width/2, scoreboardStart + (i*20)], 0, 0.5, 0.0, scoreBoardListFont.size, colour, false, false, false, true);
// Ping if(typeof playerColours[clients[i].name] != "undefined") {
text = ping; colour = playerColours[clients[i].name];
size = scoreBoardListFont.measure(ping, 75, 0.0, 1.0, 10, false, false); }
scoreBoardListFont.render(ping, [game.width/2+100, scoreboardStart + (i*20)], 0, 0.5, 0.0, scoreBoardListFont.size, COLOUR_WHITE, false, false, false, true);
// PAUSED Status (depends on resource "afk") if(typeof playerPing[clients[i].name] != "undefined") {
if(paused == true) { ping = toString(playerPing[clients[i].name]);
size = scoreBoardListFont.measure("PAUSED", 100, 0.0, 1.0, 10, false, false); }
scoreBoardListFont.render("PAUSED", [game.width/2+200, scoreboardStart + (i*20)], 0, 0.5, 0.0, scoreBoardListFont.size, pausedColour, false, false, false, true);
// Player ID
let text = String(clients[i].index);
let size = scoreBoardListFont.measure(text, 75, 0.0, 1.0, 10, false, false);
scoreBoardListFont.render(text, [game.width/2-100, scoreboardStart + (i*20)], 0, 0.5, 0.0, scoreBoardListFont.size, COLOUR_WHITE, false, false, false, true);
// Player Name
text = name;
size = scoreBoardListFont.measure(text, 100, 0.0, 1.0, 10, false, false);
scoreBoardListFont.render(text, [game.width/2, scoreboardStart + (i*20)], 0, 0.5, 0.0, scoreBoardListFont.size, colour, false, false, false, true);
// Ping
text = ping;
size = scoreBoardListFont.measure(ping, 75, 0.0, 1.0, 10, false, false);
scoreBoardListFont.render(ping, [game.width/2+100, scoreboardStart + (i*20)], 0, 0.5, 0.0, scoreBoardListFont.size, COLOUR_WHITE, false, false, false, true);
// PAUSED Status (depends on resource "afk")
if(paused == true) {
size = scoreBoardListFont.measure("PAUSED", 100, 0.0, 1.0, 10, false, false);
scoreBoardListFont.render("PAUSED", [game.width/2+200, scoreboardStart + (i*20)], 0, 0.5, 0.0, scoreBoardListFont.size, pausedColour, false, false, false, true);
}
}
} }
} }
} }