From 732d268e04fc3e042bd235cf82c00675e162a3b8 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sun, 26 Jun 2022 13:30:35 -0500 Subject: [PATCH] Start working on banking script --- scripts/server/bank.js | 66 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 scripts/server/bank.js diff --git a/scripts/server/bank.js b/scripts/server/bank.js new file mode 100644 index 00000000..052eaa19 --- /dev/null +++ b/scripts/server/bank.js @@ -0,0 +1,66 @@ +// =========================================================================== +// Vortrex's Roleplay Resource +// https://github.com/VortrexFTW/gtac_roleplay +// =========================================================================== +// FILE: bank.js +// DESC: Provides banking functions and usage +// TYPE: Server (JavaScript) +// =========================================================================== + +function isPlayerAtBank(client) { + if (isPositionAtATM(getPlayerPosition(client))) { + return true; + } + + let businessId = getPlayerBusiness(client); + if (getBusinessData(client) != false) { + if (getBusinessData(businessId).entranceType == VRR_BIZ_ENTRANCE_TYPE_BANK) { + return true; + } + } + + return false; +} + +// =========================================================================== + +function isPositionAtATM(position) { + let atmId = getClosestATM(position); + + let atmData = getServerData().atmLocationCache[atmId]; + + if (getDistance(position, atmData[2]) <= getGlobalConfig().atmDistance) { + return true; + } + + return false; +} + +// =========================================================================== + +function getClosestATM(position) { + let atmLocations = getServerData().atmLocationCache; + let closest = 0; + + for (let i in atmLocations) { + if (getDistance(position, atmLocations[i]) < getDistance(position, atmLocations[closest])) { + closest = i; + } + } + + return closest; +} + +// =========================================================================== + +function isPositionAtATM(position) { + let atmId = getClosestATM(position); + + let atmData = getServerData().atmLocationCache[atmId]; + + if (getDistance(position, atmData[2]) <= getGlobalConfig().atmDistance) { + return true; + } + + return false; +} \ No newline at end of file