Check if in paintball when start/stop
This commit is contained in:
@@ -50,14 +50,18 @@ let paintBallItemNames = {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function initPaintBallScript() {
|
function initPaintBallScript() {
|
||||||
logToConsole(LOG_DEBUG, "[VRR.PaintBall]: Initializing paintball script ...");
|
logToConsole(LOG_DEBUG, "[AGRP.PaintBall]: Initializing paintball script ...");
|
||||||
logToConsole(LOG_DEBUG, "[VRR.PaintBall]: Paintball script initialized successfully!");
|
logToConsole(LOG_DEBUG, "[AGRP.PaintBall]: Paintball script initialized successfully!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function startPaintBall(client) {
|
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)) {
|
if (isPlayerWorking(client)) {
|
||||||
stopWorking(client);
|
stopWorking(client);
|
||||||
}
|
}
|
||||||
@@ -69,23 +73,31 @@ function startPaintBall(client) {
|
|||||||
getPlayerData(client).paintBallBusiness = getPlayerBusiness(client);
|
getPlayerData(client).paintBallBusiness = getPlayerBusiness(client);
|
||||||
|
|
||||||
givePlayerPaintBallItems(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) {
|
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);
|
clearPlayerWeapons(client);
|
||||||
deletePaintBallItems(client);
|
deletePaintBallItems(client);
|
||||||
restorePlayerTempLockerItems(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) {
|
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) {
|
for (let i in paintBallItems) {
|
||||||
let itemId = createItem(paintBallItems[i], 999999, AGRP_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId);
|
let itemId = createItem(paintBallItems[i], 999999, AGRP_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId);
|
||||||
getItemData(itemId).needsSaved = false;
|
getItemData(itemId).needsSaved = false;
|
||||||
@@ -95,26 +107,26 @@ function givePlayerPaintBallItems(client) {
|
|||||||
getPlayerData(client).paintBallItemCache.push(itemId);
|
getPlayerData(client).paintBallItemCache.push(itemId);
|
||||||
updatePlayerHotBar(client);
|
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) {
|
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) {
|
for (let i in getPlayerData(client).paintBallItemCache) {
|
||||||
deleteItem(getPlayerData(client).paintBallItemCache[i]);
|
deleteItem(getPlayerData(client).paintBallItemCache[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
cachePlayerHotBarItems(client);
|
cachePlayerHotBarItems(client);
|
||||||
updatePlayerHotBar(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() {
|
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()]) {
|
for (let i in paintBallItemNames[getGame()]) {
|
||||||
let itemTypeId = getItemTypeFromParams(paintBallItemNames[getGame()][i]);
|
let itemTypeId = getItemTypeFromParams(paintBallItemNames[getGame()][i]);
|
||||||
if (itemTypeId != -1 && getItemTypeData(itemTypeId) != false) {
|
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) {
|
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);
|
despawnPlayer(client);
|
||||||
|
|
||||||
let businessId = getPlayerData(client).paintBallBusiness;
|
let businessId = getPlayerData(client).paintBallBusiness;
|
||||||
@@ -143,7 +155,7 @@ function respawnPlayerForPaintBall(client) {
|
|||||||
makePlayerStopAnimation(client);
|
makePlayerStopAnimation(client);
|
||||||
setPlayerControlState(client, true);
|
setPlayerControlState(client, true);
|
||||||
resetPlayerBlip(client);
|
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