Add paintball script
This commit is contained in:
110
scripts/server/paintball.js
Normal file
110
scripts/server/paintball.js
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
Reference in New Issue
Block a user