diff --git a/meta.xml b/meta.xml
index 55a19cfa..36797747 100644
--- a/meta.xml
+++ b/meta.xml
@@ -12,6 +12,7 @@
+
@@ -74,8 +75,11 @@
-
+
+
+
+
diff --git a/scripts/client/keybind.js b/scripts/client/keybind.js
new file mode 100644
index 00000000..ee4f79aa
--- /dev/null
+++ b/scripts/client/keybind.js
@@ -0,0 +1,45 @@
+// ===========================================================================
+// Asshat-Gaming Roleplay
+// https://github.com/VortrexFTW/gtac_asshat_rp
+// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// ---------------------------------------------------------------------------
+// FILE: afk.js
+// DESC: Provides AFK detection
+// TYPE: Client (JavaScript)
+// ===========================================================================
+
+let lastKeyBindUse = 0;
+let keyBindDelayTime = 2000;
+
+// ----------------------------------------------------------------------------
+
+function bindAccountKey(key, keyState) {
+ bindKey(toInteger(key), keyState, function(event) {
+ if(hasKeyBindDelayElapsed()) {
+ triggerNetworkEvent("ag.keybind.trig", key);
+ lastKeyBindUse = sdl.ticks;
+ }
+ });
+ return false;
+}
+addNetworkHandler("ag.keybinds.add", bindAccountKey);
+
+// ----------------------------------------------------------------------------
+
+function unBindAccountKey(key) {
+ unbindKey(key);
+ return true;
+}
+addNetworkHandler("ag.keybinds.del", unBindAccountKey);
+
+// ----------------------------------------------------------------------------
+
+function hasKeyBindDelayElapsed() {
+ if(sdl.ticks-lastKeyBindUse >= keyBindDelayTime) {
+ return true;
+ }
+
+ return false;
+}
+
+// ----------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/client/label.js b/scripts/client/label.js
new file mode 100644
index 00000000..38108020
--- /dev/null
+++ b/scripts/client/label.js
@@ -0,0 +1,9 @@
+// ===========================================================================
+// Asshat-Gaming Roleplay
+// https://github.com/VortrexFTW/gtac_asshat_rp
+// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// ---------------------------------------------------------------------------
+// FILE: labels.js
+// DESC: Provides functionality for world labels (3D labels)
+// TYPE: Client (JavaScript)
+// ===========================================================================
\ No newline at end of file
diff --git a/scripts/client/nametags.js b/scripts/client/nametag.js
similarity index 79%
rename from scripts/client/nametags.js
rename to scripts/client/nametag.js
index 3c1feff6..8a2d6202 100644
--- a/scripts/client/nametags.js
+++ b/scripts/client/nametag.js
@@ -4,12 +4,10 @@
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: nametags.js
-// DESC: Provides nametags for VRS
+// DESC: Provides nametag rendering
// TYPE: Client (JavaScript)
// ===========================================================================
-// ----------------------------------------------------------------------------
-
// Configuration
let nametagFont = null;
let afkStatusFont = null;
@@ -17,6 +15,11 @@ let pingFont = null;
let nametagDistance = 50.0;
let nametagWidth = 70;
+let playerNames = {};
+let playerColours = {};
+let playerPaused = {};
+let playerPing = {};
+
// ----------------------------------------------------------------------------
addEventHandler("OnResourceReady", function(event, resource) {
@@ -28,6 +31,15 @@ addEventHandler("OnResourceReady", function(event, resource) {
// ----------------------------------------------------------------------------
+addNetworkHandler("ag.nametag", function(mainName, characterName, colour, paused, ping) {
+ playerNames[mainName] = characterName;
+ playerColours[mainName] = colour;
+ playerPaused[mainName] = paused;
+ playerPing[mainName] = ping;
+});
+
+// ----------------------------------------------------------------------------
+
function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour, afk, skin) {
if(nametagFont == null) {
return false;
@@ -49,6 +61,8 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
} else {
y -= 5;
}
+ } else {
+ y -= 5;
}
if(health > 0.0) {
@@ -121,21 +135,26 @@ function updateNametags(element) {
if(element.type == ELEMENT_PLAYER) {
let name = element.name;
let colour = COLOUR_WHITE;
- let afk = false;
+ let paused = false;
+ let ping = -1;
- if(getEntityData(client, "ag.name") != null) {
- name = getEntityData(client, "ag.name");
+ if(typeof playerNames[element.name] != "undefined") {
+ name = playerNames[element.name];
}
- if(getEntityData(client, "ag.afk") != null) {
- afk = true;
+ if(typeof playerPaused[element.name] != "undefined") {
+ paused = playerPaused[element.name];
}
- if(getEntityData(client, "ag.colour") != null) {
- colour = getEntityData(client, "ag.colour");
+ if(typeof playerColours[element.name] != "undefined") {
+ colour = playerColours[element.name];
}
+
+ if(typeof playerPing[element.name] != "undefined") {
+ ping = playerPing[element.name];
+ }
- drawNametag(screenPos[0], screenPos[1], health, armour, name, 0, 1.0-distance/nametagDistance, distance, colour, afk, element.skin);
+ drawNametag(screenPos[0], screenPos[1], health, armour, name, ping, 1.0-distance/nametagDistance, distance, colour, paused, element.skin);
}
}
}
@@ -155,13 +174,15 @@ function getClientFromPlayer(player) {
// ----------------------------------------------------------------------------
addEventHandler("OnDrawnHUD", function(event) {
- //if(gta.game >= GAME_GTA_IV) {
- // return false;
- //}
+ if(gta.game >= GAME_GTA_IV) {
+ return false;
+ }
- //getElementsByType(ELEMENT_PLAYER).forEach(function(player) {
- // updateNametags(player)
- //})
+ getElementsByType(ELEMENT_PLAYER).forEach(function(player) {
+ if(player != localPlayer) {
+ updateNametags(player);
+ }
+ });
});
// ----------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/client/scoreboard.js b/scripts/client/scoreboard.js
new file mode 100644
index 00000000..cf815273
--- /dev/null
+++ b/scripts/client/scoreboard.js
@@ -0,0 +1,79 @@
+// ===========================================================================
+// Asshat-Gaming Roleplay
+// https://github.com/VortrexFTW/gtac_asshat_rp
+// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// ---------------------------------------------------------------------------
+// FILE: scoreboard.js
+// DESC: Provides scoreboard feature and rendering
+// TYPE: Client (JavaScript)
+// ===========================================================================
+
+let titleFont = null;
+let listFont = null;
+
+// ----------------------------------------------------------------------------
+
+bindEventHandler("OnResourceReady", thisResource, function(event, resource) {
+ titleFont = lucasFont.createDefaultFont(22.0, "Roboto", "Medium");
+ listFont = lucasFont.createDefaultFont(12.0, "Roboto", "Light");
+});
+
+// ----------------------------------------------------------------------------
+
+addEventHandler("OnDrawnHUD", function (event) {
+ if(isKeyDown(SDLK_TAB)) {
+ if(listFont != null && titleFont != null) {
+ let scoreboardStart = (game.height/2)-(Math.floor(getClients().length/2)*20);
+ let titleSize = titleFont.measure("PLAYERS", game.width, 0.0, 1.0, 10, false, false);
+ titleFont.render("PLAYERS", [game.width/2, scoreboardStart-50], 0, 0.5, 0.0, titleFont.size, COLOUR_WHITE, false, false, false, true);
+
+ titleSize = titleFont.measure("____________________________", game.width, 0.0, 1.0, 10, false, false);
+ titleFont.render("____________________________", [game.width/2, scoreboardStart-35], 0, 0.5, 0.0, titleFont.size, COLOUR_WHITE, false, false, false, true);
+
+ let clients = getClients();
+ for(let i in clients) {
+ let name = element.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") {
+ paused = playerPaused[clients[i].name];
+ }
+
+ if(typeof playerColours[clients[i].name] != "undefined") {
+ colour = playerColours[clients[i].name];
+ }
+
+ if(typeof playerPing[element.name] != "undefined") {
+ ping = toString(playerPing[element.name]);
+ }
+
+ // Player ID
+ let text = String(clients[i].index);
+ let size = listFont.measure(text, 75, 0.0, 1.0, 10, false, false);
+ listFont.render(text, [game.width/2-100, scoreboardStart + (i*20)], 0, 0.5, 0.0, listFont.size, COLOUR_WHITE, false, false, false, true);
+
+ // Player Name
+ text = name;
+ size = listFont.measure(text, 100, 0.0, 1.0, 10, false, false);
+ listFont.render(text, [game.width/2, scoreboardStart + (i*20)], 0, 0.5, 0.0, listFont.size, colour, false, false, false, true);
+
+ // Ping
+
+ size = listFont.measure(ping, 75, 0.0, 1.0, 10, false, false);
+ listFont.render(ping, [game.width/2+100, scoreboardStart + (i*20)], 0, 0.5, 0.0, listFont.size, COLOUR_WHITE, false, false, false, true);
+
+ // PAUSED Status (depends on resource "afk")
+ if(paused == true) {
+ size = listFont.measure("PAUSED", 100, 0.0, 1.0, 10, false, false);
+ listFont.render("PAUSED", [game.width/2+200, scoreboardStart + (i*20)], 0, 0.5, 0.0, listFont.size, COLOUR_RED, false, false, false, true);
+ }
+ }
+ }
+ }
+});
\ No newline at end of file