From 326286bdc5f60cadb4fb861d5511b6e42ae019be Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Fri, 17 Jun 2022 09:40:14 -0500 Subject: [PATCH] Add paintball script --- scripts/server/paintball.js | 110 ++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 scripts/server/paintball.js diff --git a/scripts/server/paintball.js b/scripts/server/paintball.js new file mode 100644 index 00000000..5a682eb6 --- /dev/null +++ b/scripts/server/paintball.js @@ -0,0 +1,110 @@ +// =========================================================================== +// Vortrex's Roleplay Resource +// https://github.com/VortrexFTW/gtac_roleplay +// =========================================================================== +// FILE: paintball.js +// DESC: Provides paintball/airsoft arena functions and commands +// TYPE: Server (JavaScript) +// =========================================================================== + +let paintBallItems = []; + +let paintBallItemNames = { + [VRR_GAME_GTA_III]: [ + "Colt 45", + "Uzi", + "Shotgun", + "AK-47", + "Sniper Rifle", + ], + + [VRR_GAME_GTA_VC]: [ + "Colt 45", + "Pump Shotgun", + "Ingram", + "MP5", + "Ruger", + "Sniper Rifle", + ], + + [VRR_GAME_GTA_SA]: [ + "Desert Eagle", + "Shotgun", + "MP5", + "AK-47", + "Sniper Rifle", + ], + + [VRR_GAME_GTA_IV]: [ + "Glock 9mm", + "Micro Uzi", + "Stubby Shotgun", + "AK-47", + "Sniper Rifle", + ], +}; + +// =========================================================================== + +function initPaintBallScript() { + logToConsole(LOG_INFO, "[VRR.PaintBall]: Initializing paintball script ..."); + logToConsole(LOG_INFO, "[VRR.PaintBall]: Paintball script initialized successfully!"); +} + +// =========================================================================== + +function startPaintBall(client) { + if (isPlayerWorking(client)) { + stopWorking(client); + } + + storePlayerItemsInTempLocker(client); + getPlayerData(client).tempLockerType = VRR_TEMP_LOCKER_TYPE_PAINTBALL; + + givePlayerPaintBallItems(client); +} + +// =========================================================================== + +function stopPaintBall(client) { + deletePaintBallItems(client); + restorePlayerTempLockerItems(client); +} + +// =========================================================================== + +function givePlayerPaintBallItems(client) { + for (let i in paintBallItems) { + let itemId = createItem(paintBallItems[i], value, VRR_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId); + getItemData(itemId).needsSaved = false; + getItemData(itemId).databaseId = -1; // Make sure it doesnt save + let freeSlot = getPlayerFirstEmptyHotBarSlot(client); + getPlayerData(client).hotBarItems[freeSlot] = itemId; + getPlayerData(client).paintBallItemCache.push(itemId); + updatePlayerHotBar(client); + } +} + +// =========================================================================== + +function deletePaintBallItems(client) { + for (let i in getPlayerData(client).paintBallItemCache) { + deleteItem(getPlayerData(client).paintBallItemCache[i]); + } + + cachePlayerHotBarItems(client); + updatePlayerHotBar(client); +} + +// =========================================================================== + +function cacheAllPaintBallItemTypes() { + for (let i in paintBallItemNames[getGame()]) { + let itemType = getItemTypeFromParams(paintBallItems[getGame()][i]); + if (getItemTypeData(itemType) != false) { + paintBallItems.push(itemType); + } + } +} + +// =========================================================================== \ No newline at end of file