Rename create game element funcs to "spawn"

This commit is contained in:
Vortrex
2023-02-15 03:19:00 -06:00
parent ae0178717c
commit 8ca2e84e62
8 changed files with 156 additions and 109 deletions

View File

@@ -382,8 +382,8 @@ function createBusiness(name, entrancePosition, exitPosition, entrancePickupMode
setBusinessDataIndexes(); setBusinessDataIndexes();
saveAllBusinessesToDatabase(); saveAllBusinessesToDatabase();
createBusinessPickups(businessId - 1); spawnBusinessPickups(businessId - 1);
createBusinessBlips(businessId - 1); spawnBusinessBlips(businessId - 1);
return tempBusinessData; return tempBusinessData;
} }
@@ -460,8 +460,9 @@ function setBusinessNameCommand(command, params, client) {
let oldBusinessName = getBusinessData(businessId).name; let oldBusinessName = getBusinessData(businessId).name;
getBusinessData(businessId).name = newBusinessName; getBusinessData(businessId).name = newBusinessName;
setEntityData(getBusinessData(businessId).entrancePickup, "v.rp.label.name", getBusinessData(businessId).name, true);
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
updateBusinessPickupLabelData(businessId);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} renamed business {businessBlue}${oldBusinessName}{MAINCOLOUR} to {businessBlue}${newBusinessName}`, true); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} renamed business {businessBlue}${oldBusinessName}{MAINCOLOUR} to {businessBlue}${newBusinessName}`, true);
} }
@@ -503,6 +504,7 @@ function setBusinessOwnerCommand(command, params, client) {
getBusinessData(businessId).ownerType = V_BIZ_OWNER_PLAYER; getBusinessData(businessId).ownerType = V_BIZ_OWNER_PLAYER;
getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(newBusinessOwner).databaseId; getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(newBusinessOwner).databaseId;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
updateBusinessPickupLabelData(businessId);
messagePlayerSuccess(client, `{MAINCOLOUR}You gave business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} to {ALTCOLOUR}${getCharacterFullName(newBusinessOwner)}`); messagePlayerSuccess(client, `{MAINCOLOUR}You gave business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} to {ALTCOLOUR}${getCharacterFullName(newBusinessOwner)}`);
} }
@@ -545,6 +547,7 @@ function setBusinessJobCommand(command, params, client) {
getBusinessData(businessId).ownerType = V_BIZ_OWNER_JOB; getBusinessData(businessId).ownerType = V_BIZ_OWNER_JOB;
getBusinessData(businessId).ownerId = getJobData(jobId).databaseId; getBusinessData(businessId).ownerId = getJobData(jobId).databaseId;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
updateBusinessPickupLabelData(businessId);
messagePlayerSuccess(client, `{MAINCOLOUR}You set the owner of business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} to the {jobYellow}${getJobData(jobId).name}`); messagePlayerSuccess(client, `{MAINCOLOUR}You set the owner of business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} to the {jobYellow}${getJobData(jobId).name}`);
} }
@@ -728,8 +731,9 @@ function setBusinessJobCommand(command, params, client) {
getBusinessData(businessId).ownerType = V_BIZ_OWNER_JOB; getBusinessData(businessId).ownerType = V_BIZ_OWNER_JOB;
getBusinessData(businessId).ownerId = getJobData(jobId).databaseId; getBusinessData(businessId).ownerId = getJobData(jobId).databaseId;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
updateBusinessPickupLabelData(businessId);
messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}owner to the {jobYellow}${getJobData(jobId).name} {MAINCOLOUR}job`); messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}owner to the {jobYellow}${getJobData(jobId).name} {MAINCOLOUR}job`);
} }
@@ -758,8 +762,9 @@ function setBusinessPublicCommand(command, params, client) {
getBusinessData(businessId).ownerType = V_BIZ_OWNER_PUBLIC; getBusinessData(businessId).ownerType = V_BIZ_OWNER_PUBLIC;
getBusinessData(businessId).ownerId = 0; getBusinessData(businessId).ownerId = 0;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
updateBusinessPickupLabelData(businessId);
messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}owner set to {ALTCOLOUR}public`); messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}owner set to {ALTCOLOUR}public`);
} }
@@ -789,6 +794,7 @@ function removeBusinessOwnerCommand(command, params, client) {
getBusinessData(businessId).ownerType = V_BIZ_OWNER_NONE; getBusinessData(businessId).ownerType = V_BIZ_OWNER_NONE;
getBusinessData(businessId).ownerId = -1; getBusinessData(businessId).ownerId = -1;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
updateBusinessPickupLabelData(businessId);
messagePlayerSuccess(client, `{MAINCOLOUR}You removed business {businessBlue}${getBusinessData(businessId).name}'s{MAINCOLOUR} owner`); messagePlayerSuccess(client, `{MAINCOLOUR}You removed business {businessBlue}${getBusinessData(businessId).name}'s{MAINCOLOUR} owner`);
} }
@@ -819,8 +825,8 @@ function toggleBusinessInteriorLightsCommand(command, params, client) {
getBusinessData(businessId).interiorLights = !getBusinessData(businessId).interiorLights; getBusinessData(businessId).interiorLights = !getBusinessData(businessId).interiorLights;
updateBusinessInteriorLightsForOccupants(businessId); updateBusinessInteriorLightsForOccupants(businessId);
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
meActionToNearbyPlayers(client, `turns ${toLowerCase(getOnOffFromBool(getBusinessData(businessId).interiorLights))} the business lights`); meActionToNearbyPlayers(client, `turns ${toLowerCase(getOnOffFromBool(getBusinessData(businessId).interiorLights))} the business lights`);
} }
@@ -852,6 +858,7 @@ function setBusinessEntranceFeeCommand(command, params, client) {
getBusinessData(businessId).entranceFee = entranceFee; getBusinessData(businessId).entranceFee = entranceFee;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
updateBusinessPickupLabelData(businessId); updateBusinessPickupLabelData(businessId);
messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} entrance fee to {ALTCOLOUR}${getCurrencyString(entranceFee)}`); messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} entrance fee to {ALTCOLOUR}${getCurrencyString(entranceFee)}`);
} }
@@ -881,6 +888,8 @@ function setBusinessPaintBallCommand(command, params, client) {
getBusinessData(businessId).type = V_BIZ_TYPE_PAINTBALL; getBusinessData(businessId).type = V_BIZ_TYPE_PAINTBALL;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
updateBusinessPickupLabelData(businessId);
messagePlayerSuccess(client, getLocaleString(client, "BusinessIsNowPaintBall")); messagePlayerSuccess(client, getLocaleString(client, "BusinessIsNowPaintBall"));
} }
@@ -1139,8 +1148,8 @@ function setBusinessInteriorTypeCommand(command, params, client) {
//deleteBusinessExitPickup(businessId); //deleteBusinessExitPickup(businessId);
//deleteBusinessExitBlip(businessId); //deleteBusinessExitBlip(businessId);
//createBusinessExitBlip(businessId); //spawnBusinessExitBlip(businessId);
//createBusinessExitPickup(businessId); //spawnBusinessExitPickup(businessId);
resetBusinessPickups(businessId); resetBusinessPickups(businessId);
@@ -1198,8 +1207,8 @@ function addBusinessPropertyTemplateEntities(command, params, client) {
//deleteBusinessExitPickup(businessId); //deleteBusinessExitPickup(businessId);
//deleteBusinessExitBlip(businessId); //deleteBusinessExitBlip(businessId);
//createBusinessExitBlip(businessId); //spawnBusinessExitBlip(businessId);
//createBusinessExitPickup(businessId); //spawnBusinessExitPickup(businessId);
resetBusinessPickups(businessId); resetBusinessPickups(businessId);
@@ -1301,6 +1310,7 @@ function giveDefaultItemsToBusinessCommand(command, params, client) {
cacheBusinessItems(businessId); cacheBusinessItems(businessId);
updateBusinessPickupLabelData(businessId); updateBusinessPickupLabelData(businessId);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} gave business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} the default items for ${typeParam}`, true); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} gave business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} the default items for ${typeParam}`, true);
} }
@@ -1326,6 +1336,7 @@ function setBusinessDealershipCommand(command, params, client) {
getBusinessData(businessId).labelHelpType == V_PROPLABEL_INFO_ENTERVEHICLE; getBusinessData(businessId).labelHelpType == V_PROPLABEL_INFO_ENTERVEHICLE;
getBusinessData(businessId).type = V_BIZ_TYPE_DEALERSHIP; getBusinessData(businessId).type = V_BIZ_TYPE_DEALERSHIP;
updateBusinessPickupLabelData(businessId); updateBusinessPickupLabelData(businessId);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set the type of business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} to dealership`, true); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set the type of business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} to dealership`, true);
} }
@@ -1468,9 +1479,9 @@ function setBusinessBuyPriceCommand(command, params, client) {
} }
getBusinessData(businessId).buyPrice = amount; getBusinessData(businessId).buyPrice = amount;
setEntityData(getBusinessData(businessId).entrancePickup, "v.rp.label.price", getBusinessData(businessId).buyPrice, true);
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
updateBusinessPickupLabelData(businessId);
messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name}'s{MAINCOLOUR} for-sale price to {ALTCOLOUR}${getCurrencyString(amount)}`); messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name}'s{MAINCOLOUR} for-sale price to {ALTCOLOUR}${getCurrencyString(amount)}`);
} }
@@ -1573,23 +1584,14 @@ function orderItemForBusinessCommand(command, params, client) {
getPlayerData(client).businessOrderBusiness = businessId; getPlayerData(client).businessOrderBusiness = businessId;
getPlayerData(client).businessOrderItem = itemType; getPlayerData(client).businessOrderItem = itemType;
getPlayerData(client).businessOrderCost = orderTotalCost; getPlayerData(client).businessOrderCost = orderTotalCost;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
showPlayerPrompt(client, `Ordering ${amount} ${getPluralForm(getItemTypeData(itemType).name)} will cost a total of ${getCurrencyString(orderTotalCost)}`, "Business Order Cost"); showPlayerPrompt(client, `Ordering ${amount} ${getPluralForm(getItemTypeData(itemType).name)} will cost a total of ${getCurrencyString(orderTotalCost)}`, "Business Order Cost");
getPlayerData(client).promptType = V_PROMPT_BIZORDER; getPlayerData(client).promptType = V_PROMPT_BIZORDER;
} }
// =========================================================================== // ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function orderItemForBusiness(businessId, itemType, amount) { function orderItemForBusiness(businessId, itemType, amount) {
if (getBusinessData(businessId).till < orderTotalCost) { if (getBusinessData(businessId).till < orderTotalCost) {
let neededAmount = orderTotalCost - getBusinessData(businessId).till; let neededAmount = orderTotalCost - getBusinessData(businessId).till;
@@ -1695,8 +1697,8 @@ function moveBusinessEntranceCommand(command, params, client) {
//deleteBusinessEntranceBlip(businessId); //deleteBusinessEntranceBlip(businessId);
//deleteBusinessEntrancePickup(businessId); //deleteBusinessEntrancePickup(businessId);
//createBusinessEntranceBlip(businessId); //spawnBusinessEntranceBlip(businessId);
//createBusinessEntrancePickup(businessId); //spawnBusinessEntrancePickup(businessId);
resetBusinessPickups(businessId); resetBusinessPickups(businessId);
resetBusinessBlips(businessId); resetBusinessBlips(businessId);
@@ -1736,8 +1738,8 @@ function moveBusinessExitCommand(command, params, client) {
deleteBusinessExitBlip(businessId); deleteBusinessExitBlip(businessId);
deleteBusinessExitPickup(businessId); deleteBusinessExitPickup(businessId);
createBusinessExitBlip(businessId); spawnBusinessExitBlip(businessId);
createBusinessExitPickup(businessId); spawnBusinessExitPickup(businessId);
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
@@ -1962,14 +1964,14 @@ function saveBusinessToDatabase(businessId) {
* @return {Boolean} Whether or not the server pickups were created * @return {Boolean} Whether or not the server pickups were created
* *
*/ */
function createAllBusinessPickups() { function spawnAllBusinessPickups() {
if (!getServerConfig().createBusinessPickups) { if (!getServerConfig().createBusinessPickups) {
return false; return false;
} }
for (let i in getServerData().businesses) { for (let i in getServerData().businesses) {
createBusinessEntrancePickup(i); spawnBusinessEntrancePickup(i);
createBusinessExitPickup(i); spawnBusinessExitPickup(i);
updateBusinessPickupLabelData(i); updateBusinessPickupLabelData(i);
} }
@@ -1984,7 +1986,7 @@ function createAllBusinessPickups() {
* @return {Boolean} Whether or not the server blips were created * @return {Boolean} Whether or not the server blips were created
* *
*/ */
function createAllBusinessBlips() { function spawnAllBusinessBlips() {
if (!getServerConfig().createBusinessBlips) { if (!getServerConfig().createBusinessBlips) {
return false; return false;
} }
@@ -1994,8 +1996,8 @@ function createAllBusinessBlips() {
} }
for (let i in getServerData().businesses) { for (let i in getServerData().businesses) {
createBusinessEntranceBlip(i); spawnBusinessEntranceBlip(i);
createBusinessExitBlip(i); spawnBusinessExitBlip(i);
} }
} }
@@ -2008,7 +2010,7 @@ function createAllBusinessBlips() {
* @return {Boolean} Whether or not the blip was created * @return {Boolean} Whether or not the blip was created
* *
*/ */
function createBusinessEntrancePickup(businessId) { function spawnBusinessEntrancePickup(businessId) {
if (!getServerConfig().createBusinessPickups) { if (!getServerConfig().createBusinessPickups) {
return false; return false;
} }
@@ -2071,7 +2073,7 @@ function createBusinessEntrancePickup(businessId) {
* @return {Boolean} Whether or not the blip was created * @return {Boolean} Whether or not the blip was created
* *
*/ */
function createBusinessEntranceBlip(businessId) { function spawnBusinessEntranceBlip(businessId) {
if (!getServerConfig().createBusinessBlips) { if (!getServerConfig().createBusinessBlips) {
return false; return false;
} }
@@ -2129,7 +2131,7 @@ function createBusinessEntranceBlip(businessId) {
* @return {Boolean} Whether or not the pickup was created * @return {Boolean} Whether or not the pickup was created
* *
*/ */
function createBusinessExitPickup(businessId) { function spawnBusinessExitPickup(businessId) {
if (!areServerElementsSupported()) { if (!areServerElementsSupported()) {
return false; return false;
} }
@@ -2191,7 +2193,7 @@ function createBusinessExitPickup(businessId) {
* @return {Boolean} Whether or not the blip was created * @return {Boolean} Whether or not the blip was created
* *
*/ */
function createBusinessExitBlip(businessId) { function spawnBusinessExitBlip(businessId) {
if (!areServerElementsSupported()) { if (!areServerElementsSupported()) {
return false; return false;
} }
@@ -2412,7 +2414,7 @@ function deleteBusinessEntrancePickup(businessId) {
//removeFromWorld(getBusinessData(businessId).entrancePickup); //removeFromWorld(getBusinessData(businessId).entrancePickup);
deleteGameElement(getBusinessData(businessId).entrancePickup); deleteGameElement(getBusinessData(businessId).entrancePickup);
getBusinessData(businessId).entrancePickup = null; getBusinessData(businessId).entrancePickup = null;
updateBusinessPickupLabelData(businessId);
return true; return true;
} }
@@ -2511,8 +2513,8 @@ function reloadAllBusinessesCommand(command, params, client) {
//forceAllPlayersToStopWorking(); //forceAllPlayersToStopWorking();
clearArray(getServerData().businesses); clearArray(getServerData().businesses);
getServerData().businesses = loadBusinessesFromDatabase(); getServerData().businesses = loadBusinessesFromDatabase();
createAllBusinessPickups(); spawnAllBusinessPickups();
createAllBusinessBlips(); spawnAllBusinessBlips();
setBusinessDataIndexes(); setBusinessDataIndexes();
cacheAllBusinessItems(); cacheAllBusinessItems();
@@ -2871,9 +2873,9 @@ function getBusinessIdFromDatabaseId(databaseId) {
function updateBusinessPickupLabelData(businessId) { function updateBusinessPickupLabelData(businessId) {
if (!areServerElementsSupported() || getGame() == V_GAME_MAFIA_ONE || getGame() == V_GAME_GTA_IV) { if (!areServerElementsSupported() || getGame() == V_GAME_MAFIA_ONE || getGame() == V_GAME_GTA_IV) {
if (getBusinessData(businessId) == false) { if (getBusinessData(businessId) == false) {
sendBusinessToPlayer(null, businessId, "", false, -1, -1, 0, 0, false, false, false); sendBusinessToPlayer(null, businessId, true, "", false, -1, -1, 0, 0, false, false, false);
} else { } else {
sendBusinessToPlayer(null, businessId, getBusinessData(businessId).name, getBusinessData(businessId).entrancePosition, getBusinessEntranceBlipModelForNetworkEvent(businessId), getBusinessEntrancePickupModelForNetworkEvent(businessId), getBusinessData(businessId).buyPrice, getBusinessData(businessId).rentPrice, getBusinessData(businessId).hasInterior, getBusinessData(businessId).locked, doesBusinessHaveAnyItemsToBuy(businessId)); sendBusinessToPlayer(null, businessId, false, getBusinessData(businessId).name, getBusinessData(businessId).entrancePosition, getBusinessEntranceBlipModelForNetworkEvent(businessId), getBusinessEntrancePickupModelForNetworkEvent(businessId), getBusinessData(businessId).buyPrice, getBusinessData(businessId).rentPrice, getBusinessData(businessId).hasInterior, getBusinessData(businessId).locked, doesBusinessHaveAnyItemsToBuy(businessId));
} }
return false; return false;
} }
@@ -2931,24 +2933,24 @@ function updateBusinessPickupLabelData(businessId) {
function resetBusinessPickups(businessId) { function resetBusinessPickups(businessId) {
deleteBusinessPickups(businessId); deleteBusinessPickups(businessId);
createBusinessEntrancePickup(businessId); spawnBusinessEntrancePickup(businessId);
createBusinessExitPickup(businessId); spawnBusinessExitPickup(businessId);
} }
// =========================================================================== // ===========================================================================
function resetBusinessBlips(businessId) { function resetBusinessBlips(businessId) {
deleteBusinessBlips(businessId); deleteBusinessBlips(businessId);
createBusinessEntranceBlip(businessId); spawnBusinessEntranceBlip(businessId);
createBusinessExitBlip(businessId); spawnBusinessExitBlip(businessId);
} }
// =========================================================================== // ===========================================================================
function resetAllBusinessPickups(businessId) { function resetAllBusinessPickups(businessId) {
deleteBusinessPickups(businessId); deleteBusinessPickups(businessId);
createBusinessEntrancePickup(businessId); spawnBusinessEntrancePickup(businessId);
createBusinessExitPickup(businessId); spawnBusinessExitPickup(businessId);
} }
// =========================================================================== // ===========================================================================
@@ -2956,15 +2958,15 @@ function resetAllBusinessPickups(businessId) {
function resetAllBusinessBlips() { function resetAllBusinessBlips() {
for (let i in getServerData().businesses) { for (let i in getServerData().businesses) {
deleteBusinessBlips(i); deleteBusinessBlips(i);
createBusinessBlips(i); spawnBusinessBlips(i);
} }
} }
// =========================================================================== // ===========================================================================
function createBusinessBlips(businessId) { function spawnBusinessBlips(businessId) {
createBusinessEntranceBlip(businessId); spawnBusinessEntranceBlip(businessId);
createBusinessExitBlip(businessId); spawnBusinessExitBlip(businessId);
} }
// =========================================================================== // ===========================================================================
@@ -2972,15 +2974,15 @@ function createBusinessBlips(businessId) {
function resetAllBusinessPickups() { function resetAllBusinessPickups() {
for (let i in getServerData().businesses) { for (let i in getServerData().businesses) {
deleteBusinessPickups(i); deleteBusinessPickups(i);
createBusinessPickups(i); spawnBusinessPickups(i);
} }
} }
// =========================================================================== // ===========================================================================
function createBusinessPickups(businessId) { function spawnBusinessPickups(businessId) {
createBusinessEntrancePickup(businessId); spawnBusinessEntrancePickup(businessId);
createBusinessExitPickup(businessId); spawnBusinessExitPickup(businessId);
} }
// =========================================================================== // ===========================================================================

View File

@@ -643,9 +643,9 @@ function fixAllServerBlipsCommand(command, params, client) {
deleteGameElement(blip); deleteGameElement(blip);
}); });
createAllJobBlips(); spawnAllJobBlips();
createAllBusinessBlips(); spawnAllBusinessBlips();
createAllHouseBlips(); spawnAllHouseBlips();
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} reset all server blips`); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} reset all server blips`);
} }
@@ -658,9 +658,9 @@ function fixAllServerPickupsCommand(command, params, client) {
deleteGameElement(pickup); deleteGameElement(pickup);
}); });
createAllJobPickups(); spawnAllJobPickups();
createAllBusinessPickups(); spawnAllBusinessPickups();
createAllHousePickups(); spawnAllHousePickups();
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} reset all server pickups`); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} reset all server pickups`);
} }

View File

@@ -462,7 +462,7 @@ function setHousePickupCommand(command, params, client) {
} }
deleteHouseEntrancePickup(houseId); deleteHouseEntrancePickup(houseId);
createHouseEntrancePickup(houseId); spawnHouseEntrancePickup(houseId);
getHouseData(houseId).needsSaved = true; getHouseData(houseId).needsSaved = true;
@@ -527,8 +527,8 @@ function setHouseInteriorTypeCommand(command, params, client) {
deleteHouseEntrancePickup(houseId); deleteHouseEntrancePickup(houseId);
deleteHouseExitPickup(houseId); deleteHouseExitPickup(houseId);
createHouseEntrancePickup(houseId); spawnHouseEntrancePickup(houseId);
createHouseExitPickup(houseId); spawnHouseExitPickup(houseId);
getHouseData(houseId).needsSaved = true; getHouseData(houseId).needsSaved = true;
@@ -654,8 +654,8 @@ function moveHouseExitCommand(command, params, client) {
deleteHouseExitPickup(houseId); deleteHouseExitPickup(houseId);
deleteHouseExitBlip(houseId); deleteHouseExitBlip(houseId);
createHouseExitPickup(houseId); spawnHouseExitPickup(houseId);
createHouseExitBlip(houseId); spawnHouseExitBlip(houseId);
getHouseData(houseId).needsSaved = true; getHouseData(houseId).needsSaved = true;
@@ -798,8 +798,8 @@ function createHouse(description, entrancePosition, exitPosition, entrancePickup
saveHouseToDatabase(houseId - 1); saveHouseToDatabase(houseId - 1);
setHouseDataIndexes(); setHouseDataIndexes();
createHousePickups(houseId - 1); spawnHousePickups(houseId - 1);
createHouseBlips(houseId - 1); spawnHouseBlips(houseId - 1);
return houseId - 1; return houseId - 1;
} }
@@ -1016,25 +1016,25 @@ function saveHouseLocationToDatabase(houseId, locationId) {
// =========================================================================== // ===========================================================================
function createAllHousePickups() { function spawnAllHousePickups() {
for (let i in getServerData().houses) { for (let i in getServerData().houses) {
createHouseEntrancePickup(i); spawnHouseEntrancePickup(i);
createHouseExitPickup(i); spawnHouseExitPickup(i);
} }
} }
// =========================================================================== // ===========================================================================
function createAllHouseBlips() { function spawnAllHouseBlips() {
for (let i in getServerData().houses) { for (let i in getServerData().houses) {
createHouseEntranceBlip(i); spawnHouseEntranceBlip(i);
createHouseExitBlip(i); spawnHouseExitBlip(i);
} }
} }
// =========================================================================== // ===========================================================================
function createHouseEntrancePickup(houseId) { function spawnHouseEntrancePickup(houseId) {
if (!getServerConfig().createHousePickups) { if (!getServerConfig().createHousePickups) {
return false; return false;
} }
@@ -1082,7 +1082,7 @@ function createHouseEntrancePickup(houseId) {
// =========================================================================== // ===========================================================================
function createHouseEntranceBlip(houseId) { function spawnHouseEntranceBlip(houseId) {
if (!areServerElementsSupported()) { if (!areServerElementsSupported()) {
return false; return false;
} }
@@ -1139,7 +1139,7 @@ function createHouseEntranceBlip(houseId) {
// =========================================================================== // ===========================================================================
function createHouseExitPickup(houseId) { function spawnHouseExitPickup(houseId) {
if (!areServerElementsSupported()) { if (!areServerElementsSupported()) {
return false; return false;
} }
@@ -1189,7 +1189,7 @@ function createHouseExitPickup(houseId) {
// =========================================================================== // ===========================================================================
function createHouseExitBlip(houseId) { function spawnHouseExitBlip(houseId) {
if (!areServerElementsSupported()) { if (!areServerElementsSupported()) {
return false; return false;
} }
@@ -1702,8 +1702,8 @@ function canPlayerLockUnlockHouse(client, houseId) {
function resetHousePickups(houseId) { function resetHousePickups(houseId) {
deleteHouseEntrancePickup(houseId); deleteHouseEntrancePickup(houseId);
deleteHouseExitPickup(houseId); deleteHouseExitPickup(houseId);
createHouseEntrancePickup(houseId); spawnHouseEntrancePickup(houseId);
createHouseExitPickup(houseId); spawnHouseExitPickup(houseId);
} }
// =========================================================================== // ===========================================================================
@@ -1711,8 +1711,8 @@ function resetHousePickups(houseId) {
function resetHouseBlips(houseId) { function resetHouseBlips(houseId) {
deleteHouseEntranceBlip(houseId); deleteHouseEntranceBlip(houseId);
deleteHouseExitBlip(houseId); deleteHouseExitBlip(houseId);
createHouseEntranceBlip(houseId); spawnHouseEntranceBlip(houseId);
createHouseExitBlip(houseId); spawnHouseExitBlip(houseId);
} }
// =========================================================================== // ===========================================================================
@@ -1830,15 +1830,15 @@ function deleteAllHousePickups() {
// =========================================================================== // ===========================================================================
function createHouseBlips(houseId) { function createHouseBlips(houseId) {
createHouseEntranceBlip(houseId); spawnHouseEntranceBlip(houseId);
createHouseExitBlip(houseId); spawnHouseExitBlip(houseId);
} }
// =========================================================================== // ===========================================================================
function createHousePickups(houseId) { function createHousePickups(houseId) {
createHouseEntrancePickup(houseId); spawnHouseEntrancePickup(houseId);
createHouseExitPickup(houseId); spawnHouseExitPickup(houseId);
} }
// =========================================================================== // ===========================================================================

View File

@@ -356,13 +356,13 @@ function createGroundItem(itemTypeId, value, position, dimension = 0) {
let itemIndex = createItem(itemTypeId, value, V_ITEM_OWNER_GROUND, 0); let itemIndex = createItem(itemTypeId, value, V_ITEM_OWNER_GROUND, 0);
getItemData(itemIndex).position = position; getItemData(itemIndex).position = position;
getItemData(itemIndex).dimension = dimension; getItemData(itemIndex).dimension = dimension;
createGroundItemObject(itemIndex); spawnGroundItemObject(itemIndex);
return itemIndex; return itemIndex;
} }
// =========================================================================== // ===========================================================================
function createGroundItemObject(itemId) { function spawnGroundItemObject(itemId) {
if (!getItemData(itemId)) { if (!getItemData(itemId)) {
return false; return false;
} }
@@ -1772,7 +1772,7 @@ function playerDropItem(client, hotBarSlot) {
getItemData(itemId).position = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), getItemTypeData(getItemData(itemId).itemTypeIndex).dropFrontDistance); getItemData(itemId).position = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), getItemTypeData(getItemData(itemId).itemTypeIndex).dropFrontDistance);
getItemData(itemId).dimension = getPlayerDimension(client); getItemData(itemId).dimension = getPlayerDimension(client);
//getItemData(itemId).interior = getPlayerInterior(client); //getItemData(itemId).interior = getPlayerInterior(client);
createGroundItemObject(itemId); spawnGroundItemObject(itemId);
getItemData(itemId).needsSaved = true; getItemData(itemId).needsSaved = true;
getServerData().groundItemCache.push(itemId); getServerData().groundItemCache.push(itemId);
} }
@@ -2137,9 +2137,9 @@ function cacheAllGroundItems() {
// =========================================================================== // ===========================================================================
function createAllGroundItemObjects() { function spawnAllGroundItemObjects() {
for (let i in getServerData().groundItemCache) { for (let i in getServerData().groundItemCache) {
createGroundItemObject(getServerData().groundItemCache[i]); spawnGroundItemObject(getServerData().groundItemCache[i]);
} }
} }
@@ -3294,3 +3294,14 @@ function cacheItemItems(itemId) {
} }
// =========================================================================== // ===========================================================================
function despawnAllGroundItemObjects() {
for (let i in getServerData().groundItemCache) {
if (getItemData(getServerData().groundItemCache[i]).object != null) {
destroyGameElement(getItemData(getServerData().groundItemCache[i]).object);
getItemData(getServerData().groundItemCache[i]).object = null;
}
}
}
// ===========================================================================

View File

@@ -782,7 +782,7 @@ function loadJobEquipmentItemsFromDatabase(jobEquipmentDatabaseId) {
// =========================================================================== // ===========================================================================
function createAllJobBlips() { function spawnAllJobBlips() {
if (!getServerConfig().createJobBlips) { if (!getServerConfig().createJobBlips) {
return false; return false;
} }
@@ -790,7 +790,7 @@ function createAllJobBlips() {
logToConsole(LOG_DEBUG, `[V.RP.Job] Spawning all job location blips ...`); logToConsole(LOG_DEBUG, `[V.RP.Job] Spawning all job location blips ...`);
for (let i in getServerData().jobs) { for (let i in getServerData().jobs) {
for (let j in getServerData().jobs[i].locations) { for (let j in getServerData().jobs[i].locations) {
createJobLocationBlip(i, j); spawnJobLocationBlip(i, j);
} }
} }
logToConsole(LOG_DEBUG, `[V.RP.Job] All job location blips spawned!`); logToConsole(LOG_DEBUG, `[V.RP.Job] All job location blips spawned!`);
@@ -798,7 +798,7 @@ function createAllJobBlips() {
// =========================================================================== // ===========================================================================
function createAllJobPickups() { function spawnAllJobPickups() {
if (!getServerConfig().createJobPickups) { if (!getServerConfig().createJobPickups) {
return false; return false;
} }
@@ -943,6 +943,11 @@ function takeJobCommand(command, params, client) {
let closestJobLocation = getClosestJobLocation(getPlayerPosition(client), getPlayerDimension(client)); let closestJobLocation = getClosestJobLocation(getPlayerPosition(client), getPlayerDimension(client));
let jobData = getJobData(closestJobLocation.jobIndex); let jobData = getJobData(closestJobLocation.jobIndex);
if (closestJobLocation == false) {
messagePlayerError(client, getLocaleString(client, "NoJobLocationCloseEnough"));
return false;
}
if (closestJobLocation.position.distance(getPlayerPosition(client)) > getGlobalConfig().takeJobDistance) { if (closestJobLocation.position.distance(getPlayerPosition(client)) > getGlobalConfig().takeJobDistance) {
messagePlayerError(client, getLocaleString(client, "NoJobLocationCloseEnough")); messagePlayerError(client, getLocaleString(client, "NoJobLocationCloseEnough"));
return false; return false;
@@ -1550,8 +1555,8 @@ function reloadAllJobsCommand(command, params, client) {
Promise.resolve().then(() => { Promise.resolve().then(() => {
getServerData().jobs = loadJobsFromDatabase(); getServerData().jobs = loadJobsFromDatabase();
createAllJobPickups(); spawnAllJobPickups();
createAllJobBlips(); spawnAllJobBlips();
}); });
announceAdminAction("AllJobsReloaded"); announceAdminAction("AllJobsReloaded");
@@ -3223,7 +3228,7 @@ function createJobLocationPickup(jobId, locationId) {
// =========================================================================== // ===========================================================================
function createJobLocationBlip(jobId, locationId) { function spawnJobLocationBlip(jobId, locationId) {
if (!getServerConfig().createJobBlips) { if (!getServerConfig().createJobBlips) {
return false; return false;
} }
@@ -3425,14 +3430,14 @@ function respawnPlayerLastJobVehicle(client) {
function resetAllJobBlips() { function resetAllJobBlips() {
deleteAllJobBlips(); deleteAllJobBlips();
createAllJobBlips(); spawnAllJobBlips();
} }
// =========================================================================== // ===========================================================================
function resetAllJobPickups() { function resetAllJobPickups() {
deleteAllJobPickups(); deleteAllJobPickups();
createAllJobPickups(); spawnAllJobPickups();
} }
// =========================================================================== // ===========================================================================

View File

@@ -757,3 +757,20 @@ function createNPC(skinIndex, position, heading, interior, dimension) {
} }
// =========================================================================== // ===========================================================================
function despawnAllNPCs() {
for (let i in getServerData().npcs) {
destroyGameElement(getServerData().npc[i].npc);
getServerData().npc[i].npc = null;
}
}
// ===========================================================================
function spawnAllNPCs() {
for (let i in getServerData().npcs) {
spawnNPC(i);
}
}
// ===========================================================================

View File

@@ -49,8 +49,9 @@ async function initServerScripts() {
setAllServerDataIndexes(); setAllServerDataIndexes();
checkServerGameTime(); checkServerGameTime();
createAllServerElements(); spawnAllServerElements();
addAllNetworkEventHandlers(); addAllNetworkEventHandlers();
addAllCommandHandlers();
initAllClients(); initAllClients();
initTimers(); initTimers();
@@ -175,17 +176,16 @@ function setAllServerDataIndexes() {
// =========================================================================== // ===========================================================================
function createAllServerElements() { function spawnAllServerElements() {
createAllBusinessPickups(); spawnAllBusinessPickups();
createAllBusinessBlips(); spawnAllBusinessBlips();
createAllHousePickups(); spawnAllHousePickups();
createAllHouseBlips(); spawnAllHouseBlips();
createAllJobPickups(); spawnAllJobPickups();
createAllJobBlips(); spawnAllJobBlips();
createAllGroundItemObjects(); spawnAllGroundItemObjects();
spawnAllVehicles(); spawnAllVehicles();
spawnAllNPCs(); spawnAllNPCs();
addAllCommandHandlers();
// Using client-side spheres since server-side ones don't show on GTAC atm (bug) // Using client-side spheres since server-side ones don't show on GTAC atm (bug)
//createAllJobRouteLocationMarkers(); //createAllJobRouteLocationMarkers();

View File

@@ -246,7 +246,13 @@ function checkServerGameTime() {
saveServerDataToDatabase(); saveServerDataToDatabase();
logToConsole(LOG_INFO | LOG_WARN, `[V.RP.Timers] Changing server map to night`); logToConsole(LOG_INFO | LOG_WARN, `[V.RP.Timers] Changing server map to night`);
messageDiscordEventChannel("🌙 Changing server map to night"); messageDiscordEventChannel("🌙 Changing server map to night");
despawnAllVehicles();
despawnAllNPCs();
despawnAllGroundItemObjects();
game.changeMap(getGameConfig().mainWorldScene[getGame()]); game.changeMap(getGameConfig().mainWorldScene[getGame()]);
spawnAllVehicles();
spawnAllNPCs();
spawnAllGroundItemObjects();
} }
} else if (getGameConfig().mainWorldScene[getGame()] == "FREERIDENOC") { } else if (getGameConfig().mainWorldScene[getGame()] == "FREERIDENOC") {
if (isServerGoingToChangeMapsSoon(getServerConfig().hour, getServerConfig().minute)) { if (isServerGoingToChangeMapsSoon(getServerConfig().hour, getServerConfig().minute)) {
@@ -260,7 +266,13 @@ function checkServerGameTime() {
saveServerDataToDatabase(); saveServerDataToDatabase();
logToConsole(LOG_INFO | LOG_WARN, `[V.RP.Timers] Changing server map to day`); logToConsole(LOG_INFO | LOG_WARN, `[V.RP.Timers] Changing server map to day`);
messageDiscordEventChannel("🌞 Changing server map to day"); messageDiscordEventChannel("🌞 Changing server map to day");
despawnAllVehicles();
despawnAllNPCs();
despawnAllGroundItemObjects();
game.changeMap(getGameConfig().mainWorldScene[getGame()]); game.changeMap(getGameConfig().mainWorldScene[getGame()]);
spawnAllVehicles();
spawnAllNPCs();
spawnAllGroundItemObjects();
} }
} }
} }