Add keybind, label, nametag, scoreboard scripts

This commit is contained in:
Vortrex
2020-12-21 22:49:48 -06:00
parent 0a29cef6f9
commit ddcc70afa8
5 changed files with 176 additions and 18 deletions

45
scripts/client/keybind.js Normal file
View File

@@ -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;
}
// ----------------------------------------------------------------------------