Add interior-in-interior stuff

This commit is contained in:
Vortrex
2021-09-18 08:41:02 -05:00
parent 80eeaa14c5
commit b19b35368d
5 changed files with 214 additions and 274 deletions

View File

@@ -208,7 +208,7 @@ function createBusiness(name, entrancePosition, exitPosition, entrancePickupMode
// ===========================================================================
function deleteBusinessCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!areParamsEmpty(params)) {
businessId = getBusinessFromParams(params);
@@ -236,7 +236,7 @@ function deleteBusinessLocationCommand(command, params, client) {
function setBusinessNameCommand(command, params, client) {
let newBusinessName = toString(params);
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -253,7 +253,6 @@ function setBusinessNameCommand(command, params, client) {
let oldBusinessName = getBusinessData(businessId).name;
getBusinessData(businessId).name = newBusinessName;
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.name", getBusinessData(businessId).name, true);
getBusinessData(businessId).needsSaved = true;
messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}renamed business ${getInlineChatColourByType("businessBlue")}${oldBusinessName} ${getInlineChatColourByName("white")}to ${getInlineChatColourByType("businessBlue")}${newBusinessName}`);
}
@@ -262,7 +261,7 @@ function setBusinessNameCommand(command, params, client) {
function setBusinessOwnerCommand(command, params, client) {
let newBusinessOwner = getPlayerFromParams(params);
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!newBusinessOwner) {
messagePlayerError(client, "Player not found!");
@@ -291,7 +290,7 @@ function setBusinessOwnerCommand(command, params, client) {
// ===========================================================================
function setBusinessClanCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError("Business not found!");
@@ -331,10 +330,10 @@ function setBusinessClanCommand(command, params, client) {
*
*/
function setBusinessRankCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError("House not found!");
messagePlayerError("Business not found!");
return false;
}
@@ -353,7 +352,7 @@ function setBusinessClanCommand(command, params, client) {
}
if(doesPlayerHaveClanPermission(client, getClanFlagValue("manageBusinesses"))) {
messagePlayerError(client, "You can't set clan house ranks!");
messagePlayerError(client, "You can't set clan business ranks!");
return false;
}
@@ -371,7 +370,7 @@ function setBusinessClanCommand(command, params, client) {
// ===========================================================================
function setBusinessJobCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!areParamsEmpty(params)) {
businessId = getBusinessFromParams(params);
@@ -404,7 +403,7 @@ function setBusinessJobCommand(command, params, client) {
// ===========================================================================
function setBusinessPublicCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!areParamsEmpty(params)) {
businessId = getBusinessFromParams(params);
@@ -425,7 +424,7 @@ function setBusinessPublicCommand(command, params, client) {
// ===========================================================================
function lockUnlockBusinessCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!areParamsEmpty(params)) {
businessId = getBusinessFromParams(params);
@@ -462,7 +461,7 @@ function lockUnlockBusinessCommand(command, params, client) {
*
*/
function toggleBusinessInteriorLightsCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -488,7 +487,7 @@ function lockUnlockBusinessCommand(command, params, client) {
function setBusinessEntranceFeeCommand(command, params, client) {
let splitParams = params.split(" ");
let entranceFee = toInteger(splitParams[0]) || 0;
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -510,7 +509,7 @@ function setBusinessEntranceFeeCommand(command, params, client) {
// ===========================================================================
function getBusinessInfoCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!areParamsEmpty(params)) {
businessId = getBusinessFromParams(params);
@@ -553,9 +552,8 @@ function getBusinessInfoCommand(command, params, client) {
function setBusinessPickupCommand(command, params, client) {
let splitParams = params.split(" ");
let typeParam = splitParams[0] || "business";
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
if(!getBusinessData(businessId)) {
if(!getBusinessnData(businessId)) {
messagePlayerError(client, "Business not found!");
return false;
}
@@ -587,7 +585,7 @@ function setBusinessPickupCommand(command, params, client) {
function setBusinessInteriorTypeCommand(command, params, client) {
let splitParams = params.split(" ");
let typeParam = splitParams[0] || "business";
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -595,12 +593,10 @@ function setBusinessInteriorTypeCommand(command, params, client) {
}
if(isNaN(typeParam)) {
let tempBusinessLocation = new BusinessLocationData(false);
if(toLowerCase(typeParam) == "none") {
tempBusinessLocation.exitPosition = toVector3(0.0, 0.0, 0.0);
tempBusinessLocation.exitDimension = 0;
tempBusinessLocation.exitInterior = -1;
getBusinessData(businessId).exitPosition = toVector3(0.0, 0.0, 0.0);
getBusinessData(businessId).exitDimension = 0;
getBusinessData(businessId).exitInterior = -1;
getBusinessData(businessId).hasInterior = false;
messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}removed business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}interior`);
return false;
@@ -618,10 +614,11 @@ function setBusinessInteriorTypeCommand(command, params, client) {
getBusinessData(businessId).hasInterior = true;
}
deleteHouseEntrancePickup(businessId);
deleteHouseExitPickup(businessId);
createHouseEntrancePickup(businessId);
createHouseExitPickup(businessId);
deleteBusinessExitPickup(businessId);
deleteBusinessExitBlip(businessId);
createBusinessExitBlip(businessId);
createBusinessExitPickup(businessId);
getBusinessData(businessId).needsSaved = true;
@@ -634,7 +631,7 @@ function setBusinessBlipCommand(command, params, client) {
let splitParams = params.split(" ");
let typeParam = splitParams[0] || "business";
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -665,7 +662,7 @@ function giveDefaultItemsToBusinessCommand(command, params, client) {
let splitParams = params.split(" ");
let typeParam = splitParams[0] || "business";
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -701,7 +698,7 @@ function deleteBusinessFloorItemsCommand(command, params, client) {
let splitParams = params.split(" ");
let typeParam = splitParams[0] || "business";
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -723,7 +720,7 @@ function deleteBusinessStorageItemsCommand(command, params, client) {
let splitParams = params.split(" ");
let typeParam = splitParams[0] || "business";
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -750,7 +747,7 @@ function withdrawFromBusinessCommand(command, params, client) {
let splitParams = params.split(" ");
let amount = toInteger(splitParams[0]) || 0;
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -788,7 +785,7 @@ function setBusinessBuyPriceCommand(command, params, client) {
let splitParams = params.split(" ");
let amount = toInteger(splitParams[0]) || 0;
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -818,7 +815,7 @@ function depositIntoBusinessCommand(command, params, client) {
let splitParams = params.split(" ");
let amount = toInteger(splitParams[0]) || 0;
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -863,7 +860,7 @@ function orderItemForBusinessCommand(command, params, client) {
let amount = toInteger(splitParams.slice(-2, -1)) || 1;
let value = toInteger(splitParams.slice(-1)) || getItemTypeData(itemType).capacity;
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
logToConsole(LOG_DEBUG, `[VRR.Business] ${getPlayerDisplayForConsole(client)} is ordering ${amount} ${splitParams.slice(0,-2).join(" ")} (${value})`);
@@ -902,7 +899,7 @@ function orderItemForBusiness(businessId, itemType, amount) {
// ===========================================================================
function viewBusinessTillAmountCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!areParamsEmpty(params)) {
businessId = getBusinessFromParams(params);
@@ -919,7 +916,7 @@ function viewBusinessTillAmountCommand(command, params, client) {
// ===========================================================================
function buyBusinessCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -949,7 +946,7 @@ function buyBusinessCommand(command, params, client) {
// ===========================================================================
function moveBusinessEntranceCommand(command, params, client) {
let businessId = toInteger((isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)));
let businessId = getPlayerBusiness(client);
if(!areParamsEmpty(params)) {
businessId = getBusinessFromParams(params);
@@ -978,7 +975,7 @@ function moveBusinessEntranceCommand(command, params, client) {
// ===========================================================================
function moveBusinessExitCommand(command, params, client) {
let businessId = toInteger((isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)));
let businessId = getPlayerBusiness(client);
if(!areParamsEmpty(params)) {
businessId = getBusinessFromParams(params);
@@ -1016,11 +1013,13 @@ function getBusinessDataFromDatabaseId(databaseId) {
// ===========================================================================
function getClosestBusinessEntrance(position) {
function getClosestBusinessEntrance(position, dimension) {
let closest = 0;
for(let i in getServerData().businesses) {
if(getDistance(position, getServerData().businesses[i].entrancePosition) <= getDistance(position, getServerData().businesses[closest].entrancePosition)) {
closest = i;
if(getServerData().businesses[i].entranceDimension == dimension) {
if(getDistance(position, getServerData().businesses[i].entrancePosition) <= getDistance(position, getServerData().businesses[closest].entrancePosition)) {
closest = i;
}
}
}
return closest;
@@ -1028,11 +1027,13 @@ function getClosestBusinessEntrance(position) {
// ===========================================================================
function getClosestBusinessExit(position) {
function getClosestBusinessExit(position, dimension) {
let closest = 0;
for(let i in getServerData().businesses) {
if(getDistance(position, getServerData().businesses[i].exitPosition) <= getDistance(position, getServerData().businesses[closest].exitPosition)) {
closest = i;
if(getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == dimension) {
if(getDistance(position, getServerData().businesses[i].exitPosition) <= getDistance(position, getServerData().businesses[closest].exitPosition)) {
closest = i;
}
}
}
return closest;
@@ -1041,8 +1042,10 @@ function getClosestBusinessExit(position) {
// ===========================================================================
function isPlayerInAnyBusiness(client) {
if(doesEntityDataExist(client, "vrr.inBusiness")) {
return true;
for(let i in getServerData().businesses) {
if(getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == getPlayerDimension(client)) {
return i;
}
}
return false;
@@ -1051,8 +1054,15 @@ function isPlayerInAnyBusiness(client) {
// ===========================================================================
function getPlayerBusiness(client) {
if(doesEntityDataExist(client, "vrr.inBusiness")) {
return getEntityData(client, "vrr.inBusiness");
let closestEntrance = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client));
if(getDistance(getPlayerPosition(client), getBusinessData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
return getBusinessData(closestEntrance).index;
}
for(let i in getServerData().businesses) {
if(getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == getPlayerDimension(client)) {
return i;
}
}
return -1;
@@ -1258,11 +1268,11 @@ function deleteBusiness(businessId, deletedBy = 0) {
disconnectFromDatabase(dbConnection);
}
deleteBusinessEntrancePickup(businessId);
deleteBusinessExitPickup(businessId);
deleteBusinessEntrancePickups(businessId);
deleteBusinessExitPickups(businessId);
deleteBusinessEntranceBlip(businessId);
deleteBusinessExitBlip(businessId);
deleteBusinessEntranceBlips(businessId);
deleteBusinessExitBlips(businessId);
removePlayersFromBusiness(businessId);
@@ -1412,15 +1422,15 @@ function setAllBusinessIndexes() {
for(let i in getServerData().businesses) {
getServerData().businesses[i].index = i;
for(let j in getServerData().businesses[i].locations) {
getServerData().businesses[i].locations[j].index = j;
getServerData().businesses[i].locations[j].businessIndex = i;
}
//for(let j in getServerData().businesses[i].locations) {
// getServerData().businesses[i].locations[j].index = j;
// getServerData().businesses[i].locations[j].businessIndex = i;
//}
for(let j in getServerData().businesses[i].gameScripts) {
getServerData().businesses[i].gameScripts[j].index = j;
getServerData().businesses[i].gameScripts[j].businessIndex = i;
}
//for(let j in getServerData().businesses[i].gameScripts) {
// getServerData().businesses[i].gameScripts[j].index = j;
// getServerData().businesses[i].gameScripts[j].businessIndex = i;
//}
}
}
@@ -1445,7 +1455,7 @@ function addToBusinessInventory(businessId, itemType, amount, buyPrice) {
// ===========================================================================
function buyFromBusinessCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(areParamsEmpty(params)) {
showBusinessFloorInventoryToPlayer(client, businessId);
@@ -1543,7 +1553,7 @@ function buyFromBusinessCommand(command, params, client) {
function setBusinessItemSellPriceCommand(command, params, client) {
let splitParams = params.split(" ");
let businessId = getBusinessFromParams(splitParams[2]) || (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getBusinessFromParams(splitParams[2]) || getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -1578,7 +1588,7 @@ function setBusinessItemSellPriceCommand(command, params, client) {
function storeItemInBusinessStorageCommand(command, params, client) {
let splitParams = params.split(" ");
let businessId = getBusinessFromParams(splitParams[2]) || (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getBusinessFromParams(splitParams[2]) || getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -1614,7 +1624,7 @@ function storeItemInBusinessStorageCommand(command, params, client) {
function stockItemOnBusinessFloorCommand(command, params, client) {
let splitParams = params.split(" ");
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
@@ -1699,7 +1709,7 @@ function cacheBusinessItems(businessId) {
// ===========================================================================
function getHouseIdFromDatabaseId(databaseId) {
function getBusinessIdFromDatabaseId(databaseId) {
for(let i in getServerData().businesses) {
if(getBusinessData(i).databaseId == databaseId) {
return i;

View File

@@ -98,8 +98,8 @@ function loadCommands() {
commandData("bizitemprice", setBusinessItemSellPriceCommand, "<item slot> <sell price>", getStaffFlagValue("none"), true, true, "Sets the purchase price of a business item"),
commandData("bizname", setBusinessNameCommand, "<name>", getStaffFlagValue("none"), true, true, "Changes a business name"),
commandData("bizowner", setBusinessOwnerCommand, "<player name/id>", getStaffFlagValue("none"), true, true, "Changes the owner of a business"),
commandData("bizclan", setBusinessClanCommand, "", getStaffFlagValue("none"), true, true, "Changes the owner of a business"),
commandData("bizbuyprice", setBusinessBuyPriceCommand, "<amount>", getStaffFlagValue("none"), true, true, "Changes the owner of a business"),
commandData("bizclan", setBusinessClanCommand, "", getStaffFlagValue("none"), true, true, "Gives a business to a clan"),
commandData("bizbuyprice", setBusinessBuyPriceCommand, "<amount>", getStaffFlagValue("none"), true, true, "Changes the price to buy the business"),
commandData("bizblip", setBusinessBlipCommand, "<type name/model id>", getStaffFlagValue("manageBusinesses"), true, true, "Sets the business blip display"),
commandData("bizpickup", setBusinessPickupCommand, "<type name/model id>", getStaffFlagValue("manageBusinesses"), true, true, "Sets the business pickup display"),
commandData("bizinfo", getBusinessInfoCommand, "[id]", getStaffFlagValue("none"), true, true, "Shows business information"),

View File

@@ -81,6 +81,7 @@ function createHouseCommand(command, params, client) {
let houseId = getServerData().houses.push(tempHouseData);
saveHouseToDatabase(houseId-1);
setAllHouseIndexes();
createHouseEntrancePickup(houseId-1);
createHouseExitPickup(houseId-1);
@@ -104,7 +105,7 @@ function createHouseCommand(command, params, client) {
*
*/
function lockUnlockHouseCommand(command, params, client) {
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError("House not found!");
@@ -137,7 +138,7 @@ function lockUnlockHouseCommand(command, params, client) {
*
*/
function toggleHouseInteriorLightsCommand(command, params, client) {
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError("House not found!");
@@ -166,7 +167,7 @@ function lockUnlockHouseCommand(command, params, client) {
function setHouseDescriptionCommand(command, params, client) {
let newHouseDescription = toString(params);
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError("House not found!");
@@ -202,7 +203,7 @@ function setHouseDescriptionCommand(command, params, client) {
*/
function setHouseOwnerCommand(command, params, client) {
let newHouseOwner = getPlayerFromParams(params);
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
let houseId = getPlayerHouse(client);
if(!newHouseOwner) {
messagePlayerError("Player not found!");
@@ -240,7 +241,7 @@ function setHouseOwnerCommand(command, params, client) {
*
*/
function setHouseClanCommand(command, params, client) {
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError("House not found!");
@@ -280,7 +281,7 @@ function setHouseClanCommand(command, params, client) {
*
*/
function setHouseRankCommand(command, params, client) {
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError("House not found!");
@@ -329,7 +330,7 @@ function setHouseClanCommand(command, params, client) {
*/
function setHousePickupCommand(command, params, client) {
let typeParam = params || "house";
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError(client, "House not found!");
@@ -374,7 +375,7 @@ function setHousePickupCommand(command, params, client) {
function setHouseInteriorTypeCommand(command, params, client) {
let splitParams = params.split(" ");
let typeParam = splitParams[0] || "none";
let houseId = getHouseFromParams(splitParams[1]) || (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError(client, "House not found!");
@@ -427,7 +428,7 @@ function setHouseInteriorTypeCommand(command, params, client) {
*/
function setHouseBlipCommand(command, params, client) {
let typeParam = params || "house";
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError(client, "House not found!");
@@ -473,7 +474,7 @@ function setHouseBlipCommand(command, params, client) {
*
*/
function moveHouseEntranceCommand(command, params, client) {
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayer(client, "You need to be near or inside a house!");
@@ -511,7 +512,7 @@ function moveHouseEntranceCommand(command, params, client) {
*
*/
function moveHouseExitCommand(command, params, client) {
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayer(client, "You need to be near or inside a house!");
@@ -551,7 +552,7 @@ function moveHouseExitCommand(command, params, client) {
*
*/
function deleteHouseCommand(command, params, client) {
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError("House not found!");
@@ -637,8 +638,6 @@ function createHouse(description, entranceLocation) {
tempHouseData.exitInterior = entranceLocation.exitInterior;
tempHouseData.entranceDimension = entranceLocation.entranceDimension;
tempHouseData.locations.push(entranceLocation);
return tempHouseData;
}
@@ -654,12 +653,13 @@ function getHouseDataFromDatabaseId(databaseId) {
// ===========================================================================
function getClosestHouseEntrance(position) {
let houses = getServerData().houses;
function getClosestHouseEntrance(position, dimension) {
let closest = 0;
for(let i in houses) {
if(getDistance(houses[i].entrancePosition, position) <= getDistance(houses[closest].entrancePosition, position)) {
closest = i;
for(let i in getServerData().houses) {
if(getServerData().houses[i].entranceDimension == dimension) {
if(getDistance(getServerData().houses[i].entrancePosition, position) <= getDistance(getServerData().houses[closest].entrancePosition, position)) {
closest = i;
}
}
}
return closest;
@@ -667,12 +667,13 @@ function getClosestHouseEntrance(position) {
// ===========================================================================
function getClosestHouseExit(position) {
let houses = getServerData().houses;
function getClosestHouseExit(position, dimension) {
let closest = 0;
for(let i in houses) {
if(getDistance(houses[i].exitPosition, position) <= getDistance(houses[closest].exitPosition, position)) {
closest = i;
for(let i in getServerData().houses) {
if(getServerData().houses[i].entranceDimension == dimension) {
if(getDistance(getServerData().houses[i].exitPosition, position) <= getDistance(getServerData().houses[closest].exitPosition, position)) {
closest = i;
}
}
}
return closest;
@@ -681,8 +682,15 @@ function getClosestHouseExit(position) {
// ===========================================================================
function getPlayerHouse(client) {
if(doesEntityDataExist(client, "vrr.inHouse")) {
return getEntityData(client, "vrr.inHouse");
let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
return getHouseData(closestEntrance).index
}
for(let i in getServerData().houses) {
if(getServerData().houses[i].exitDimension == getPlayerDimension(client)) {
return i;
}
}
return -1;
@@ -963,7 +971,7 @@ function getHouseOwnerTypeText(ownerType) {
// ===========================================================================
function getHouseInfoCommand(command, params, client) {
let houseId = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
let houseId = getPlayerHouse(client);
if(!areParamsEmpty(params)) {
houseId = toInteger(params);
@@ -1012,10 +1020,10 @@ function setHouseBuyPriceCommand(command, params, client) {
let splitParams = params.split(" ");
let amount = toInteger(splitParams[0]) || 0;
let houseId = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError(client, "Business not found!");
messagePlayerError(client, "House not found!");
return false;
}
@@ -1026,7 +1034,7 @@ function setHouseBuyPriceCommand(command, params, client) {
getHouseData(houseId).buyPrice = amount;
setEntityData(getHouseData(houseId).entrancePickup, "vrr.label.price", getHouseData(houseId).buyPrice, true);
messagePlayerSuccess(client, `${getInlineChatColourByName("white")}You set business ${getInlineChatColourByType("houseGreen")}${getHouseData(houseId).description}'s ${getInlineChatColourByName("white")}for-sale price to ${getInlineChatColourByName("lightGrey")}$${makeLargeNumberReadable(amount)}`);
messagePlayerSuccess(client, `${getInlineChatColourByName("white")}You set house ${getInlineChatColourByType("houseGreen")}${getHouseData(houseId).description}'s ${getInlineChatColourByName("white")}for-sale price to ${getInlineChatColourByName("lightGrey")}$${makeLargeNumberReadable(amount)}`);
}
// ===========================================================================
@@ -1040,10 +1048,10 @@ function setHouseRentPriceCommand(command, params, client) {
let splitParams = params.split(" ");
let amount = toInteger(splitParams[0]) || 0;
let houseId = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError(client, "Business not found!");
messagePlayerError(client, "House not found!");
return false;
}
@@ -1054,13 +1062,13 @@ function setHouseRentPriceCommand(command, params, client) {
getHouseData(houseId).rentPrice = amount;
setEntityData(getHouseData(houseId).entrancePickup, "vrr.label.price", `Rent: ${getHouseData(houseId).rentPrice}`, true);
messagePlayerSuccess(client, `${getInlineChatColourByName("white")}You set business ${getInlineChatColourByType("houseGreen")}${getHouseData(houseId).description}'s ${getInlineChatColourByName("white")}rent price to ${getInlineChatColourByName("lightGrey")}$${makeLargeNumberReadable(amount)}`);
messagePlayerSuccess(client, `${getInlineChatColourByName("white")}You set house ${getInlineChatColourByType("houseGreen")}${getHouseData(houseId).description}'s ${getInlineChatColourByName("white")}rent price to ${getInlineChatColourByName("lightGrey")}$${makeLargeNumberReadable(amount)}`);
}
// ===========================================================================
function buyHouseCommand(command, params, client) {
let houseId = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError(client, "House not found!");
@@ -1073,7 +1081,7 @@ function buyHouseCommand(command, params, client) {
}
if(getPlayerCurrentSubAccount(client).cash < getHouseData(houseId).buyPrice) {
messagePlayerError(client, `You don't have enough money to buy business ${getInlineChatColourByType("houseGreen")}${getHouseData(houseId).name}!`);
messagePlayerError(client, `You don't have enough money to buy house ${getInlineChatColourByType("houseGreen")}${getHouseData(houseId).name}!`);
return false;
}
@@ -1189,15 +1197,15 @@ function setAllHouseIndexes() {
for(let i in getServerData().houses) {
getServerData().houses[i].index = i;
for(let j in getServerData().houses[i].locations) {
getServerData().houses[i].locations[j].index = j;
getServerData().houses[i].locations[j].houseIndex = i;
}
//for(let j in getServerData().houses[i].locations) {
// getServerData().houses[i].locations[j].index = j;
// getServerData().houses[i].locations[j].houseIndex = i;
//}
for(let j in getServerData().houses[i].gameScripts) {
getServerData().houses[i].gameScripts[j].index = j;
getServerData().houses[i].gameScripts[j].houseIndex = i;
}
//for(let j in getServerData().houses[i].gameScripts) {
// getServerData().houses[i].gameScripts[j].index = j;
// getServerData().houses[i].gameScripts[j].houseIndex = i;
//}
}
}

View File

@@ -122,16 +122,88 @@ function submitBugReportCommand(command, params, client) {
// ===========================================================================
function enterExitPropertyCommand(command, params, client) {
if(isPlayerInAnyHouse(client)) {
let inHouse = getServerData().houses[getPlayerHouse(client)];
if(getDistance(inHouse.exitPosition, getPlayerPosition(client)) <= getGlobalConfig().exitPropertyDistance) {
if(inHouse.locked) {
meActionToNearbyPlayers(client, "tries to open the house door but fails because it's locked");
let closestBusinessEntrance = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client));
let closestBusinessExit = getClosestBusinessExit(getPlayerPosition(client), getPlayerDimension(client));
let closestHouseEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
let closestHouseExit = getClosestHouseExit(getPlayerPosition(client), getPlayerDimension(client));
let closestEntrance = null;
let closestExit = null;
let closestProperty = null;
let isEntrance = false;
let isBusiness = false;
if(getDistance(getPlayerPosition(client), getBusinessData(closestBusinessEntrance).entrancePosition) <= getDistance(getPlayerPosition(client), getHouseData(closestHouseEntrance).entrancePosition)) {
closestEntrance = getBusinessData(closestBusinessEntrance);
} else {
closestEntrance = getHouseData(closestHouseEntrance);
}
if(getDistance(getPlayerPosition(client), getBusinessData(closestBusinessExit).exitPosition) <= getDistance(getPlayerPosition(client), getHouseData(closestHouseExit).exitPosition)) {
closestExit = getBusinessData(closestBusinessExit);
} else {
closestExit = getHouseData(closestHouseExit);
}
if(getDistance(getPlayerPosition(client), closestEntrance.entrancePosition) <= getDistance(getPlayerPosition(client), closestExit.exitPosition)) {
closestProperty = closestEntrance;
isEntrance = true;
} else {
closestProperty = closestExit;
isEntrance = false;
}
if(closestProperty instanceof HouseData) {
isBusiness = false;
} else {
isBusiness = true;
}
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s closest door is ${(isBusiness) ? closestProperty.name : closestProperty.description} ${(isEntrance) ? "entrance" : "exit"}`);
if(isEntrance) {
if(getDistance(closestProperty.entrancePosition, getPlayerPosition(client)) <= getGlobalConfig().enterPropertyDistance) {
if(closestProperty.locked) {
meActionToNearbyPlayers(client, `tries to open the ${(isBusiness) ? "business" : "house"} door but fails because it's locked`);
return false;
}
clearPlayerStateToEnterExitProperty(client);
getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGPROPERTY;
meActionToNearbyPlayers(client, `opens the door and enters the ${(isBusiness) ? "business" : "house"}`);
if(isFadeCameraSupported()) {
fadeCamera(client, false, 1.0);
}
setTimeout(function() {
setPlayerPosition(client, closestProperty.exitPosition);
setPlayerHeading(client, closestProperty.exitRotation);
setPlayerDimension(client, closestProperty.exitDimension);
setPlayerInterior(client, closestProperty.exitInterior);
setTimeout(function() {
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updateInteriorLightsForPlayer(client, closestProperty.interiorLights);
}, 1000);
}, 1100);
if(closestProperty.streamingRadioStation != -1) {
if(getRadioStationData(closestProperty.streamingRadioStation)) {
playRadioStreamForPlayer(client, getRadioStationData(closestProperty.streamingRadioStation).url);
getPlayerData(client).streamingRadioStation = closestProperty.streamingRadioStation;
}
}
return true;
}
} else {
if(getDistance(closestProperty.exitPosition, getPlayerPosition(client)) <= getGlobalConfig().exitPropertyDistance) {
if(closestProperty.locked) {
meActionToNearbyPlayers(client, `tries to open the ${(isBusiness) ? "business" : "house"} door but fails because it's locked`);
return false;
}
getPlayerData(client).pedState = VRR_PEDSTATE_EXITINGPROPERTY;
meActionToNearbyPlayers(client, "opens the door and exits the house");
clearPlayerStateToEnterExitProperty(client)
meActionToNearbyPlayers(client, `opens the door and exits the ${(isBusiness) ? "business" : "house"}`);
if(isFadeCameraSupported()) {
fadeCamera(client, false, 1.0);
@@ -139,169 +211,20 @@ function enterExitPropertyCommand(command, params, client) {
disableCityAmbienceForPlayer(client, true);
setTimeout(function() {
setPlayerPosition(client, inHouse.entrancePosition);
setPlayerHeading(client, inHouse.entranceRotation);
setPlayerDimension(client, inHouse.entranceDimension);
setPlayerInterior(client, inHouse.entranceInterior);
setPlayerPosition(client, closestProperty.entrancePosition);
setPlayerHeading(client, closestProperty.entranceRotation);
setPlayerDimension(client, closestProperty.entranceDimension);
setPlayerInterior(client, closestProperty.entranceInterior);
setTimeout(function() {
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
setTimeout(function() {
enableCityAmbienceForPlayer(client);
clearPlayerOwnedPeds(client);
clearPlayerHouseGameScripts(client, inHouse.index);
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
}, 2000);
updateInteriorLightsForPlayer(client, true);
}, 1000);
}, 1100);
removeEntityData(client, "vrr.inHouse");
playRadioStreamForPlayer(client, "");
stopRadioStreamForPlayer(client);
getPlayerData(client).streamingRadioStation = -1;
logToConsole(LOG_DEBUG, `[VRR.Misc] ${getPlayerDisplayForConsole(client)} exited house ${inHouse.description}[${inHouse.index}/${inHouse.databaseId}]`);
return true;
}
}
if(isPlayerInAnyBusiness(client)) {
let inBusiness = getServerData().businesses[getPlayerBusiness(client)];
if(getDistance(inBusiness.exitPosition, getPlayerPosition(client)) <= getGlobalConfig().exitPropertyDistance) {
if(inBusiness.locked) {
meActionToNearbyPlayers(client, "tries to open the business door but fails because it's locked");
return false;
}
getPlayerData(client).pedState = VRR_PEDSTATE_EXITINGPROPERTY;
clearPlayerStateToEnterExitProperty(client)
meActionToNearbyPlayers(client, "opens the door and exits the business");
if(isFadeCameraSupported()) {
fadeCamera(client, false, 1.0);
}
disableCityAmbienceForPlayer(client, true);
setTimeout(function() {
setPlayerPosition(client, inBusiness.entrancePosition);
setPlayerHeading(client, inBusiness.entranceRotation);
setPlayerDimension(client, inBusiness.entranceDimension);
setPlayerInterior(client, inBusiness.entranceInterior);
setTimeout(function() {
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
setTimeout(function() {
enableCityAmbienceForPlayer(client);
clearPlayerOwnedPeds(client);
clearPlayerBusinessGameScripts(client, inBusiness.index);
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
}, 2000);
updateInteriorLightsForPlayer(client, true);
}, 1000);
}, 1100);
removeEntityData(client, "vrr.inBusiness");
playRadioStreamForPlayer(client, "");
getPlayerData(client).streamingRadioStation = -1;
logToConsole(LOG_DEBUG, `[VRR.Misc] ${getPlayerDisplayForConsole(client)} exited business ${inBusiness.name}[${inBusiness.index}/${inBusiness.databaseId}]`);
return true;
}
}
if(getServerData().businesses.length > 0) {
let closestBusinessId = getClosestBusinessEntrance(getPlayerPosition(client));
let closestBusiness = getBusinessData(closestBusinessId);
if(getDistance(closestBusiness.entrancePosition, getPlayerPosition(client)) <= getGlobalConfig().enterPropertyDistance) {
if(!doesBusinessHaveInterior(closestBusinessId)) {
messagePlayerAlert(client, "This business does not have an interior.");
messagePlayerTip(client, "You can use business commands at the door.");
return false;
}
if(closestBusiness.locked) {
meActionToNearbyPlayers(client, "tries to open the business door but fails because it's locked");
return false;
}
clearPlayerStateToEnterExitProperty(client)
meActionToNearbyPlayers(client, "opens the door and enters the business");
getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGPROPERTY;
if(isFadeCameraSupported()) {
fadeCamera(client, false, 1.0);
}
disableCityAmbienceForPlayer(client);
setTimeout(function() {
setPlayerPosition(client, closestBusiness.exitPosition);
setPlayerHeading(client, closestBusiness.exitRotation);
setPlayerDimension(client, closestBusiness.exitDimension);
setPlayerInterior(client, closestBusiness.exitInterior);
sendPlayerBusinessGameScripts(client, closestBusiness.index);
setTimeout(function() {
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
if(doesBusinessHaveAnyItemsToBuy(closestBusinessId)) {
messagePlayerInfo(client, "Use /buy to purchase items from this business");
}
updateInteriorLightsForPlayer(client, closestBusiness.interiorLights);
setTimeout(function() {
if(closestBusiness.streamingRadioStation != -1) {
if(getPlayerData(client).streamingRadioStation != closestBusiness.streamingRadioStation) {
playRadioStreamForPlayer(client, radioStations[closestBusiness.streamingRadioStation].url, true, getPlayerStreamingRadioVolume(client));
}
}
}, 1250);
}, 1000);
}, 1100);
setEntityData(client, "vrr.inBusiness", closestBusinessId, true);
return true;
}
}
if(getServerData().houses.length > 0) {
let closestHouseId = getClosestHouseEntrance(getPlayerPosition(client));
let closestHouse = getHouseData(closestHouseId);
//let distance = getDistance(closestHouse.entrancePosition, getPlayerPosition(client));
if(getDistance(closestHouse.entrancePosition, getPlayerPosition(client)) <= getGlobalConfig().enterPropertyDistance) {
if(!doesHouseHaveInterior(closestHouseId)) {
messagePlayerAlert(client, "This house does not have an interior.");
messagePlayerTip(client, "You can use house commands at the door.");
return false;
}
if(closestHouse.locked) {
meActionToNearbyPlayers(client, "tries to open the house door but fails because it's locked");
return false;
}
clearPlayerStateToEnterExitProperty(client)
meActionToNearbyPlayers(client, "opens the door and enters the house");
getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGPROPERTY;
if(isFadeCameraSupported()) {
fadeCamera(client, false, 1.0);
}
disableCityAmbienceForPlayer(client);
setTimeout(function() {
setPlayerDimension(client, closestHouse.exitDimension);
setPlayerInterior(client, closestHouse.exitInterior);
setPlayerPosition(client, closestHouse.exitPosition);
setPlayerHeading(client, closestHouse.exitRotation);
sendPlayerHouseGameScripts(client, closestHouse.index);
setTimeout(function() {
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
updateInteriorLightsForPlayer(client, closestHouse.interiorLights);
setTimeout(function() {
if(closestHouse.streamingRadioStation != -1) {
if(getPlayerData(client).streamingRadioStation != closestHouse.streamingRadioStation) {
playRadioStreamForPlayer(client, radioStations[closestHouse.streamingRadioStation].url, true, getPlayerStreamingRadioVolume(client));
}
}
}, 1250);
}, 1000);
}, 1100);
setEntityData(client, "vrr.inHouse", closestHouseId, true)
//logToConsole(LOG_DEBUG, `[VRR.Misc] ${getPlayerDisplayForConsole(client)} exited business ${inBusiness.name}[${inBusiness.index}/${inBusiness.databaseId}]`);
return true;
}
}

View File

@@ -3755,11 +3755,10 @@ let gameData = {
gunRange: [toVector3(-667.79, 1217.51, 11.10), 10],
bank: [toVector3(-894.52, -341.16, 13.45), 3],
stripClub: [toVector3(97.53, -1472.06, 10.43), 5],
rosenberg: [toVector3(120.82, -827.98, 10.62), 6],
rosenberg: [toVector3(137.29, -1370.20, 13.18), 6],
arena: [toVector3(-1080.49, 1331.16, 13.91), 15],
ghettoShack: [toVector3(-962.74, 146.96, 9.40), 12],
hotelRoom: [toVector3(226.47, -1274.98, 19.271), 2.933],
hotelRoom: [toVector3(226.47, -1274.98, 19.271), 2],
},
{ // GTA SA