Check if in paintball when start/stop
This commit is contained in:
@@ -50,14 +50,18 @@ let paintBallItemNames = {
|
||||
// ===========================================================================
|
||||
|
||||
function initPaintBallScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.PaintBall]: Initializing paintball script ...");
|
||||
logToConsole(LOG_DEBUG, "[VRR.PaintBall]: Paintball script initialized successfully!");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.PaintBall]: Initializing paintball script ...");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.PaintBall]: Paintball script initialized successfully!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function startPaintBall(client) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Starting paintball for ${getPlayerDisplayForConsole(client)} ...`);
|
||||
if (isPlayerInPaintBall(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Starting paintball for ${getPlayerDisplayForConsole(client)} ...`);
|
||||
if (isPlayerWorking(client)) {
|
||||
stopWorking(client);
|
||||
}
|
||||
@@ -69,23 +73,31 @@ function startPaintBall(client) {
|
||||
getPlayerData(client).paintBallBusiness = getPlayerBusiness(client);
|
||||
|
||||
givePlayerPaintBallItems(client);
|
||||
logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Started paintball for ${getPlayerDisplayForConsole(client)} successfully`);
|
||||
|
||||
messagePlayerAlert(client, getLocaleString(client, "JoinedPaintBall"));
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Started paintball for ${getPlayerDisplayForConsole(client)} successfully`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function stopPaintBall(client) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Stopping paintball for ${getPlayerDisplayForConsole(client)} ...`);
|
||||
if (!isPlayerInPaintBall(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Stopping paintball for ${getPlayerDisplayForConsole(client)} ...`);
|
||||
clearPlayerWeapons(client);
|
||||
deletePaintBallItems(client);
|
||||
restorePlayerTempLockerItems(client);
|
||||
logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Stopped paintball for ${getPlayerDisplayForConsole(client)} successfully`);
|
||||
|
||||
messagePlayerAlert(client, getLocaleString(client, "LeftPaintBall"));
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Stopped paintball for ${getPlayerDisplayForConsole(client)} successfully`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function givePlayerPaintBallItems(client) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Giving ${getPlayerDisplayForConsole(client)} paintball items ...`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Giving ${getPlayerDisplayForConsole(client)} paintball items ...`);
|
||||
for (let i in paintBallItems) {
|
||||
let itemId = createItem(paintBallItems[i], 999999, AGRP_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId);
|
||||
getItemData(itemId).needsSaved = false;
|
||||
@@ -95,26 +107,26 @@ function givePlayerPaintBallItems(client) {
|
||||
getPlayerData(client).paintBallItemCache.push(itemId);
|
||||
updatePlayerHotBar(client);
|
||||
}
|
||||
logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Gave ${getPlayerDisplayForConsole(client)} paintball items successfully`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Gave ${getPlayerDisplayForConsole(client)} paintball items successfully`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deletePaintBallItems(client) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Deleting paintball items for ${getPlayerDisplayForConsole(client)} ...`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Deleting paintball items for ${getPlayerDisplayForConsole(client)} ...`);
|
||||
for (let i in getPlayerData(client).paintBallItemCache) {
|
||||
deleteItem(getPlayerData(client).paintBallItemCache[i]);
|
||||
}
|
||||
|
||||
cachePlayerHotBarItems(client);
|
||||
updatePlayerHotBar(client);
|
||||
logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Deleting paintball items for ${getPlayerDisplayForConsole(client)} successfully`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Deleting paintball items for ${getPlayerDisplayForConsole(client)} successfully`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function cacheAllPaintBallItemTypes() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Cacheing all paintball item types ...`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Cacheing all paintball item types ...`);
|
||||
for (let i in paintBallItemNames[getGame()]) {
|
||||
let itemTypeId = getItemTypeFromParams(paintBallItemNames[getGame()][i]);
|
||||
if (itemTypeId != -1 && getItemTypeData(itemTypeId) != false) {
|
||||
@@ -122,13 +134,13 @@ function cacheAllPaintBallItemTypes() {
|
||||
}
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Cached all paintball item types`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Cached all paintball item types`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function respawnPlayerForPaintBall(client) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Respawning ${getPlayerDisplayForConsole(client)} for paintball ...`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Respawning ${getPlayerDisplayForConsole(client)} for paintball ...`);
|
||||
despawnPlayer(client);
|
||||
|
||||
let businessId = getPlayerData(client).paintBallBusiness;
|
||||
@@ -143,7 +155,7 @@ function respawnPlayerForPaintBall(client) {
|
||||
makePlayerStopAnimation(client);
|
||||
setPlayerControlState(client, true);
|
||||
resetPlayerBlip(client);
|
||||
logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Respawned ${getPlayerDisplayForConsole(client)} for paintball successfully`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Respawned ${getPlayerDisplayForConsole(client)} for paintball successfully`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
Reference in New Issue
Block a user