Merge branch 'location-overhaul' into nightly
This commit is contained in:
@@ -132,7 +132,7 @@ function createBusinessLocationCommand(command, params, client) {
|
||||
}
|
||||
|
||||
let locationType = toString(splitParams[0]);
|
||||
let businessId = (isPlayerInAnyBusiness(splitParams[1])) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
|
||||
let businessId = (isPlayerInAnyBusiness(splitParams[1])) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)).business;
|
||||
|
||||
if(!areParamsEmpty(params)) {
|
||||
businessId = getBusinessFromParams(params);
|
||||
@@ -175,7 +175,7 @@ function createBusiness(name, entrancePosition, exitPosition, entrancePickupMode
|
||||
// ===========================================================================
|
||||
|
||||
function deleteBusinessCommand(command, params, client) {
|
||||
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
|
||||
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)).business;
|
||||
|
||||
if(!areParamsEmpty(params)) {
|
||||
businessId = getBusinessFromParams(params);
|
||||
@@ -203,7 +203,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 = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)).business;
|
||||
|
||||
if(!getBusinessData(businessId)) {
|
||||
messagePlayerError(client, "Business not found!");
|
||||
@@ -220,7 +220,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 = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)).business;
|
||||
|
||||
if(!newBusinessOwner) {
|
||||
messagePlayerError(client, "Player not found!");
|
||||
@@ -241,7 +241,7 @@ function setBusinessOwnerCommand(command, params, client) {
|
||||
|
||||
function setBusinessClanCommand(command, params, client) {
|
||||
let clanId = getClanFromParams(params);
|
||||
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
|
||||
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)).business;
|
||||
|
||||
if(!getBusinessData(businessId)) {
|
||||
messagePlayerError(client, "Business not found!");
|
||||
@@ -261,7 +261,7 @@ function setBusinessClanCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setBusinessJobCommand(command, params, client) {
|
||||
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
|
||||
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)).business;
|
||||
|
||||
if(!areParamsEmpty(params)) {
|
||||
businessId = getBusinessFromParams(params);
|
||||
@@ -292,7 +292,7 @@ function setBusinessJobCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setBusinessPublicCommand(command, params, client) {
|
||||
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
|
||||
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)).business;
|
||||
|
||||
if(!areParamsEmpty(params)) {
|
||||
businessId = getBusinessFromParams(params);
|
||||
@@ -311,7 +311,7 @@ function setBusinessPublicCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function lockBusinessCommand(command, params, client) {
|
||||
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
|
||||
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)).business;
|
||||
|
||||
if(!areParamsEmpty(params)) {
|
||||
businessId = getBusinessFromParams(params);
|
||||
@@ -490,10 +490,10 @@ function setBusinessBlipCommand(command, params, client) {
|
||||
getBusinessData(businessId).entranceBlipModel = toInteger(typeParam);
|
||||
}
|
||||
|
||||
deleteBusinessEntranceBlip(businessId);
|
||||
deleteBusinessExitBlip(businessId);
|
||||
createBusinessEntranceBlip(businessId);
|
||||
createBusinessExitBlip(businessId);
|
||||
deleteBusinessLocationEntranceBlip(businessId, closestEntrance.index);
|
||||
deleteBusinessLocationExitBlip(businessId, closestEntrance.index);
|
||||
createBusinessLocationEntranceBlip(businessId, closestEntrance.index);
|
||||
createBusinessLocationExitBlip(businessId, closestEntrance.index);
|
||||
|
||||
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set business [#0099FF]${getBusinessData(businessId).name} [#FFFFFF]blip display to [#AAAAAA]${toLowerCase(typeParam)}`);
|
||||
}
|
||||
@@ -727,7 +727,7 @@ function orderItemForBusiness(businessId, itemType, amount) {
|
||||
// ===========================================================================
|
||||
|
||||
function viewBusinessTillAmountCommand(command, params, client) {
|
||||
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
|
||||
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)).business;
|
||||
|
||||
if(!areParamsEmpty(params)) {
|
||||
businessId = getBusinessFromParams(params);
|
||||
@@ -773,7 +773,7 @@ function buyBusinessCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function moveBusinessEntranceCommand(command, params, client) {
|
||||
let businessId = toInteger((isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)));
|
||||
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)).business;
|
||||
|
||||
if(!areParamsEmpty(params)) {
|
||||
businessId = getBusinessFromParams(params);
|
||||
@@ -800,7 +800,7 @@ function moveBusinessEntranceCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function moveBusinessExitCommand(command, params, client) {
|
||||
let businessId = toInteger((isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)));
|
||||
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)).business;
|
||||
|
||||
if(!areParamsEmpty(params)) {
|
||||
businessId = getBusinessFromParams(params);
|
||||
@@ -837,10 +837,12 @@ function getBusinessDataFromDatabaseId(databaseId) {
|
||||
// ===========================================================================
|
||||
|
||||
function getClosestBusinessEntrance(position) {
|
||||
let closest = 0;
|
||||
for(let i in getServerData().businesses) {
|
||||
if(getDistance(position, getServerData().businesses[i].entrancePosition) <= getDistance(position, getServerData().businesses[closest].entrancePosition)) {
|
||||
closest = i;
|
||||
let closest = getServerData().businesses[0].locations[0];
|
||||
for(let i in businesses) {
|
||||
for(let j in getServerData().businesses[i].locations) {
|
||||
if(getDistance(position, businesses[i].locations[j].entrancePosition) <= getDistance(position, closest.entrancePosition)) {
|
||||
closest = getServerData().businesses[i].locations[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
@@ -984,8 +986,10 @@ function saveBusinessToDatabase(businessId) {
|
||||
|
||||
function createAllBusinessPickups() {
|
||||
for(let i in getServerData().businesses) {
|
||||
createBusinessEntrancePickup(i);
|
||||
createBusinessExitPickup(i);
|
||||
for(let j in getServerData().businesses[i].locations) {
|
||||
createBusinessLocationEntrancePickup(i, j);
|
||||
createBusinessLocationExitPickup(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -993,87 +997,86 @@ function createAllBusinessPickups() {
|
||||
|
||||
function createAllBusinessBlips() {
|
||||
for(let i in getServerData().businesses) {
|
||||
createBusinessEntranceBlip(i);
|
||||
createBusinessExitBlip(i);
|
||||
for(let j in getServerData().businesses[i].locations) {
|
||||
createBusinessLocationEntranceBlip(i, j);
|
||||
createBusinessLocationExitBlip(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createBusinessEntrancePickup(businessId) {
|
||||
if(getBusinessData(businessId).entrancePickupModel != -1) {
|
||||
function createBusinessLocationEntrancePickup(businessId, locationId) {
|
||||
if(getBusinessData(businessId).locations[locationId].entrancePickupModel != -1) {
|
||||
let pickupModelId = getGameConfig().pickupModels[getServerGame()].business;
|
||||
|
||||
if(getServerData().businesses[businessId].entrancePickupModel != 0) {
|
||||
pickupModelId = getBusinessData(businessId).entrancePickupModel;
|
||||
if(getServerData().businesses[businessId].locations[locationId].entrancePickupModel != 0) {
|
||||
pickupModelId = getBusinessData(businessId).locations[locationId].entrancePickupModel;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).entrancePickup = gta.createPickup(pickupModelId, getBusinessData(businessId).entrancePosition);
|
||||
getBusinessData(businessId).entrancePickup.onAllDimensions = false;
|
||||
getBusinessData(businessId).entrancePickup.dimension = getBusinessData(businessId).entranceDimension;
|
||||
updateBusinessPickupLabelData(businessId);
|
||||
addToWorld(getBusinessData(businessId).entrancePickup);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createBusinessEntranceBlip(businessId) {
|
||||
if(getBusinessData(businessId).entranceBlipModel != -1) {
|
||||
function createBusinessLocationEntranceBlip(businessId, locationId) {
|
||||
if(getBusinessData(businessId).locations[locationId].entranceBlipModel != -1) {
|
||||
let blipModelId = getGameConfig().blipSprites[getServerGame()].business;
|
||||
|
||||
if(getServerData().businesses[businessId].entranceBlipModel != 0) {
|
||||
blipModelId = getBusinessData(businessId).entranceBlipModel;
|
||||
blipModelId = getBusinessData(businessId).locations[locationId].entranceBlipModel;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).entranceBlip = gta.createBlip(blipModelId, getBusinessData(businessId).entrancePosition, 1, getColourByName("businessBlue"));
|
||||
getBusinessData(businessId).entranceBlip.onAllDimensions = false;
|
||||
getBusinessData(businessId).entranceBlip.dimension = getBusinessData(businessId).entranceDimension;
|
||||
//getBusinessData(businessId).entranceBlip.interior = getBusinessData(businessId).entranceInterior;
|
||||
setEntityData(getBusinessData(businessId).entranceBlip, "ag.owner.type", AG_BLIP_BUSINESS_ENTRANCE, false);
|
||||
setEntityData(getBusinessData(businessId).entranceBlip, "ag.owner.id", businessId, false);
|
||||
addToWorld(getBusinessData(businessId).entranceBlip);
|
||||
getBusinessData(businessId).locations[locationId].entranceBlip = gta.createBlip(getBusinessData(businessId).locations[locationId].entrancePosition, blipModelId, 1, getColourByName("businessBlue"));
|
||||
getBusinessData(businessId).locations[locationId].entranceBlip.onAllDimensions = false;
|
||||
getBusinessData(businessId).locations[locationId].entranceBlip.dimension = getBusinessData(businessId).locations[locationId].entranceDimension;
|
||||
getBusinessData(businessId).locations[locationId].entranceBlip.setData("ag.owner.type", AG_BLIP_BUSINESS_ENTRANCE, false);
|
||||
getBusinessData(businessId).locations[locationId].entranceBlip.setData("ag.owner.id", businessId, false);
|
||||
addToWorld(getBusinessData(businessId).locations[locationId].entranceBlip);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createBusinessExitPickup(businessId) {
|
||||
function createBusinessLocationExitPickup(businessId, locationId) {
|
||||
if(getBusinessData(businessId).hasInterior) {
|
||||
if(getBusinessData(businessId).exitPickupModel != -1) {
|
||||
if(getBusinessData(businessId).locations[locationId].exitPickupModel != -1) {
|
||||
let pickupModelId = getGameConfig().pickupModels[getServerGame()].exit;
|
||||
|
||||
if(getServerData().businesses[businessId].exitPickupModel != 0) {
|
||||
pickupModelId = getBusinessData(businessId).exitPickupModel;
|
||||
if(getServerData().businesses[businessId].locations[locationId].exitPickupModel != 0) {
|
||||
pickupModelId = getBusinessData(businessId).locations[locationId].exitPickupModel;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).exitPickup = gta.createPickup(pickupModelId, getBusinessData(businessId).exitPosition);
|
||||
getBusinessData(businessId).exitPickup.onAllDimensions = false;
|
||||
getBusinessData(businessId).exitPickup.dimension = getBusinessData(businessId).exitDimension;
|
||||
//getBusinessData(businessId).exitPickup.interior = getBusinessData(businessId).exitInterior;
|
||||
addToWorld(getBusinessData(businessId).exitPickup);
|
||||
getBusinessData(businessId).locations[locationId].exitPickup = gta.createPickup(pickupModelId, getBusinessData(businessId).locations[locationId].exitPosition);
|
||||
getBusinessData(businessId).locations[locationId].exitPickup.onAllDimensions = false;
|
||||
getBusinessData(businessId).locations[locationId].exitPickup.dimension = getBusinessData(businessId).locations[locationId].exitDimension;
|
||||
getBusinessData(businessId).locations[locationId].exitPickup.setData("ag.owner.type", AG_PICKUP_BUSINESS_EXIT, false);
|
||||
getBusinessData(businessId).locations[locationId].exitPickup.setData("ag.owner.id", businessId, false);
|
||||
getBusinessData(businessId).locations[locationId].exitPickup.setData("ag.label.type", AG_LABEL_EXIT, true);
|
||||
addToWorld(getBusinessData(businessId).locations[locationId].exitPickup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createBusinessExitBlip(businessId) {
|
||||
function createBusinessLocationExitBlip(businessId, locationId) {
|
||||
if(getBusinessData(businessId).hasInterior) {
|
||||
if(getBusinessData(businessId).exitBlipModel != -1) {
|
||||
if(getBusinessData(businessId).locations[locationId].exitBlipModel != -1) {
|
||||
let blipModelId = getGameConfig().blipSprites[getServerGame()].business;
|
||||
|
||||
if(getServerData().businesses[businessId].exitBlipModel != 0) {
|
||||
blipModelId = getBusinessData(businessId).exitBlipModel;
|
||||
if(getServerData().businesses[businessId].locations[locationId].exitBlipModel != 0) {
|
||||
blipModelId = getBusinessData(businessId).locations[locationId].exitBlipModel;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).exitBlip = gta.createBlip(blipModelId, getBusinessData(businessId).exitPosition, 1, getColourByName("businessBlue"));
|
||||
getBusinessData(businessId).exitBlip.onAllDimensions = false;
|
||||
getBusinessData(businessId).exitBlip.dimension = getBusinessData(businessId).entranceDimension;
|
||||
getBusinessData(businessId).locations[locationId].exitBlip = gta.createBlip(getBusinessData(businessId).locations[locationId].exitPosition, blipModelId, 1, getColourByName("businessBlue"));
|
||||
getBusinessData(businessId).locations[locationId].exitBlip.onAllDimensions = false;
|
||||
getBusinessData(businessId).locations[locationId].exitBlip.dimension = getBusinessData(businessId).locations[locationId].entranceDimension;
|
||||
//getBusinessData(businessId).exitBlip.interior = getBusinessData(businessId).exitInterior;
|
||||
setEntityData(getBusinessData(businessId).exitBlip, "ag.owner.type", AG_BLIP_BUSINESS_EXIT, false);
|
||||
setEntityData(getBusinessData(businessId).exitBlip, "ag.owner.id", businessId, false);
|
||||
addToWorld(getBusinessData(businessId).exitBlip);
|
||||
getBusinessData(businessId).locations[locationId].exitBlip.setData("ag.owner.type", AG_BLIP_BUSINESS_EXIT, false);
|
||||
getBusinessData(businessId).locations[locationId].exitBlip.setData("ag.owner.id", businessId, false);
|
||||
addToWorld(getBusinessData(businessId).locations[locationId].exitBlip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1091,14 +1094,19 @@ function deleteBusiness(businessId, deletedBy = 0) {
|
||||
if(dbQuery) {
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
|
||||
dbQuery = queryDatabase(dbConnection, `DELETE FROM biz_loc WHERE biz_loc_biz = ${tempBusinessData.databaseId}`);
|
||||
if(dbQuery) {
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
deleteBusinessEntrancePickup(businessId);
|
||||
deleteBusinessExitPickup(businessId);
|
||||
deleteBusinessEntrancePickups(businessId);
|
||||
deleteBusinessExitPickups(businessId);
|
||||
|
||||
deleteBusinessEntranceBlip(businessId);
|
||||
deleteBusinessExitBlip(businessId);
|
||||
deleteBusinessEntranceBlips(businessId);
|
||||
deleteBusinessExitBlips(businessId);
|
||||
|
||||
removePlayersFromBusiness(businessId);
|
||||
|
||||
@@ -1176,43 +1184,69 @@ function doesBusinessHaveInterior(businessId) {
|
||||
return getBusinessData(businessId).hasInterior;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteBusinessEntrancePickup(businessId) {
|
||||
if(getBusinessData(businessId).entrancePickup != null) {
|
||||
//removeFromWorld(getBusinessData(businessId).entrancePickup);
|
||||
deleteGameElement(getBusinessData(businessId).entrancePickup);
|
||||
getBusinessData(businessId).entrancePickup = null;
|
||||
function deleteBusinessEntrancePickups(businessId) {
|
||||
for(let i in getServerData().businesses[businessId].locations) {
|
||||
deleteBusinessLocationEntrancePickup(businessId, i);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteBusinessExitPickup(businessId) {
|
||||
if(getBusinessData(businessId).exitPickup != null) {
|
||||
//removeFromWorld(getBusinessData(businessId).exitPickup);
|
||||
deleteGameElement(getBusinessData(businessId).exitPickup);
|
||||
getBusinessData(businessId).exitPickup = null;
|
||||
function deleteBusinessEntranceBlips(businessId) {
|
||||
for(let i in getServerData().businesses[businessId].locations) {
|
||||
deleteBusinessLocationEntranceBlip(businessId, i);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteBusinessEntranceBlip(businessId) {
|
||||
if(getBusinessData(businessId).entranceBlip != null) {
|
||||
//removeFromWorld(getBusinessData(businessId).entranceBlip);
|
||||
deleteGameElement(getBusinessData(businessId).entranceBlip);
|
||||
getBusinessData(businessId).entranceBlip = null;
|
||||
function deleteBusinessExitPickups(businessId) {
|
||||
for(let i in getServerData().businesses[businessId].locations) {
|
||||
deleteBusinessLocationExitPickup(businessId, i);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteBusinessExitBlip(businessId) {
|
||||
if(getBusinessData(businessId).exitBlip != null) {
|
||||
//removeFromWorld(getBusinessData(businessId).exitBlip);
|
||||
deleteGameElement(getBusinessData(businessId).exitBlip);
|
||||
getBusinessData(businessId).exitBlip = null;
|
||||
function deleteBusinessExitBlips(businessId) {
|
||||
for(let i in getServerData().businesses[businessId].locations) {
|
||||
deleteBusinessLocationExitBlip(businessId, i);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteBusinessLocationEntrancePickup(businessId, locationId) {
|
||||
if(getBusinessData(businessId).locations[locationId].entrancePickup) {
|
||||
destroyElement(getBusinessData(businessId).locations[locationId].entrancePickup);
|
||||
getBusinessData(businessId).locations[locationId].entrancePickup = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteBusinessLocationExitPickup(businessId, locationId) {
|
||||
if(getBusinessData(businessId).locations[locationId].exitPickup) {
|
||||
destroyElement(getBusinessData(businessId).locations[locationId].exitPickup);
|
||||
getBusinessData(businessId).locations[locationId].exitPickup = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteBusinessLocationEntranceBlip(businessId, locationId) {
|
||||
if(getBusinessData(businessId).locations[locationId].entranceBlip) {
|
||||
destroyElement(getBusinessData(businessId).locations[locationId].entranceBlip);
|
||||
getBusinessData(businessId).locations[locationId].entranceBlip = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteBusinessLocationExitBlip(businessId, locationId) {
|
||||
if(getBusinessData(businessId).locations[locationId].exitBlip) {
|
||||
destroyElement(getBusinessData(businessId).locations[locationId].exitBlip);
|
||||
getBusinessData(businessId).locations[locationId].exitBlip = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -514,16 +514,27 @@ function initClassTable() {
|
||||
businessLocationData: class {
|
||||
constructor(dbAssoc) {
|
||||
this.databaseId = 0;
|
||||
this.name = "";
|
||||
this.type = 0;
|
||||
this.name = "Unnamed";
|
||||
this.business = 0;
|
||||
this.enabled = false;
|
||||
this.index = -1;
|
||||
this.needsSaved = false;
|
||||
|
||||
this.position = toVector3(0.0, 0.0, 0.0);
|
||||
this.interior = 0;
|
||||
this.dimension = 0;
|
||||
this.entrancePosition = false;
|
||||
this.entranceRotation = 0.0;
|
||||
this.entranceInterior = 0;
|
||||
this.entranceDimension = 0;
|
||||
this.entrancePickupModel = -1;
|
||||
this.entranceBlipModel = -1;
|
||||
this.entrancePickup = null;
|
||||
this.entranceBlip = null;
|
||||
|
||||
this.exitPosition = false;
|
||||
this.exitRotation = 0.0;
|
||||
this.exitInterior = 0;
|
||||
this.exitDimension = -1;
|
||||
this.exitPickupModel = -1;
|
||||
this.exitBlipModel = -1;
|
||||
this.exitPickup = null;
|
||||
this.exitBlip = null;
|
||||
|
||||
if(dbAssoc) {
|
||||
this.databaseId = toInteger(dbAssoc("biz_loc_id"));
|
||||
@@ -531,11 +542,68 @@ function initClassTable() {
|
||||
this.type = toInteger(dbAssoc("biz_loc_type"));
|
||||
this.business = toInteger(dbAssoc("biz_loc_biz"));
|
||||
this.enabled = intToBool(toInteger(dbAssoc("biz_loc_enabled")));
|
||||
this.index = -1;
|
||||
|
||||
this.position = toVector3(toFloat(dbAssoc["biz_loc_pos_x"]), toFloat(dbAssoc["biz_loc_pos_y"]), toFloat(dbAssoc["biz_loc_pos_z"]));
|
||||
this.interior = toInteger(dbAssoc["biz_loc_int"]);
|
||||
this.dimension = toInteger(dbAssoc["biz_loc_vw"]);
|
||||
this.entrancePosition = toVector3(toFloat(dbAssoc["biz_loc_entrance_pos_x"]), toFloat(dbAssoc["biz_loc_entrance_pos_y"]), toFloat(dbAssoc["biz_loc_entrance_pos_z"]));
|
||||
this.entranceRotation = toFloat(dbAssoc["biz_loc_entrance_rot_z"]);
|
||||
this.entranceInterior = toInteger(dbAssoc["biz_loc_entrance_int"]);
|
||||
this.entranceDimension = toInteger(dbAssoc["biz_loc_entrance_vw"]);
|
||||
this.entrancePickupModel = toInteger(dbAssoc["biz_loc_entrance_pickup"]);
|
||||
this.entranceBlipModel = toInteger(dbAssoc["biz_loc_entrance_blip"]);
|
||||
|
||||
this.exitPosition = toVector3(toFloat(dbAssoc["biz_loc_exit_pos_x"]), toFloat(dbAssoc["biz_loc_exit_pos_y"]), toFloat(dbAssoc["biz_loc_exit_pos_z"]));
|
||||
this.exitRotation = toFloat(dbAssoc["biz_loc_exit_rot_z"]);
|
||||
this.exitInterior = toInteger(dbAssoc["biz_loc_exit_int"]);
|
||||
this.exitDimension = toInteger(dbAssoc["biz_loc_exit_vw"]);
|
||||
this.exitPickupModel = toInteger(dbAssoc["biz_loc_exit_pickup"]);
|
||||
this.exitBlipModel = toInteger(dbAssoc["biz_loc_exit_blip"]);
|
||||
}
|
||||
}
|
||||
},
|
||||
houseLocationData: class {
|
||||
constructor(dbAssoc) {
|
||||
this.databaseId = 0;
|
||||
this.name = "Unnamed";
|
||||
this.house = 0;
|
||||
this.enabled = false;
|
||||
|
||||
this.entrancePosition = false;
|
||||
this.entranceRotation = 0.0;
|
||||
this.entranceInterior = 0;
|
||||
this.entranceDimension = 0;
|
||||
this.entrancePickupModel = -1;
|
||||
this.entranceBlipModel = -1;
|
||||
this.entrancePickup = null;
|
||||
this.entranceBlip = null;
|
||||
|
||||
this.exitPosition = false;
|
||||
this.exitRotation = 0.0;
|
||||
this.exitInterior = 0;
|
||||
this.exitDimension = -1;
|
||||
this.exitPickupModel = -1;
|
||||
this.exitBlipModel = -1;
|
||||
this.exitPickup = null;
|
||||
this.exitBlip = null;
|
||||
|
||||
if(dbAssoc) {
|
||||
this.databaseId = toInteger(dbAssoc("house_loc_id"));
|
||||
this.name = toString(dbAssoc("house_loc_name"));
|
||||
this.type = toInteger(dbAssoc("house_loc_type"));
|
||||
this.business = toInteger(dbAssoc("house_loc_biz"));
|
||||
this.enabled = intToBool(toInteger(dbAssoc("house_loc_enabled")));
|
||||
|
||||
this.entrancePosition = toVector3(toFloat(dbAssoc["house_loc_entrance_pos_x"]), toFloat(dbAssoc["house_loc_entrance_pos_y"]), toFloat(dbAssoc["house_loc_entrance_pos_z"]));
|
||||
this.entranceRotation = toFloat(dbAssoc["house_loc_entrance_rot_z"]);
|
||||
this.entranceInterior = toInteger(dbAssoc["house_loc_entrance_int"]);
|
||||
this.entranceDimension = toInteger(dbAssoc["house_loc_entrance_vw"]);
|
||||
this.entrancePickupModel = toInteger(dbAssoc["house_loc_entrance_pickup"]);
|
||||
this.entranceBlipModel = toInteger(dbAssoc["house_loc_entrance_blip"]);
|
||||
|
||||
this.exitPosition = toVector3(toFloat(dbAssoc["house_loc_exit_pos_x"]), toFloat(dbAssoc["house_loc_exit_pos_y"]), toFloat(dbAssoc["house_loc_exit_pos_z"]));
|
||||
this.exitRotation = toFloat(dbAssoc["house_loc_exit_rot_z"]);
|
||||
this.exitInterior = toInteger(dbAssoc["house_loc_exit_int"]);
|
||||
this.exitDimension = toInteger(dbAssoc["house_loc_exit_vw"]);
|
||||
this.exitPickupModel = toInteger(dbAssoc["house_loc_exit_pickup"]);
|
||||
this.exitBlipModel = toInteger(dbAssoc["house_loc_exit_blip"]);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -573,30 +641,28 @@ function initClassTable() {
|
||||
this.exitPickup = null;
|
||||
this.exitBlip = null;
|
||||
|
||||
if(dbAssoc) {
|
||||
this.databaseId = toInteger(dbAssoc["house_id"]);
|
||||
this.description = toString(dbAssoc["house_description"]);
|
||||
this.ownerType = toInteger(dbAssoc["house_owner_type"]);
|
||||
this.ownerId = toInteger(dbAssoc["house_owner_id"]);
|
||||
this.buyPrice = toInteger(dbAssoc["house_buy_price"]);
|
||||
this.rentPrice = toInteger(dbAssoc["house_rent_price"]);
|
||||
this.renter = toInteger(dbAssoc["house_renter"]);
|
||||
this.locked = intToBool(toInteger(dbAssoc["house_locked"]));
|
||||
this.hasInterior = intToBool(toInteger(dbAssoc["house_has_interior"]));
|
||||
if(houseAssoc != false) {
|
||||
this.databaseId = toInteger(houseAssoc["house_id"]);
|
||||
this.description = toString(houseAssoc["house_description"]);
|
||||
this.ownerType = toInteger(houseAssoc["house_owner_type"]);
|
||||
this.ownerId = toInteger(houseAssoc["house_owner_id"]);
|
||||
this.buyPrice = toInteger(houseAssoc["house_buy_price"]);
|
||||
this.locked = intToBool(toInteger(houseAssoc["house_locked"]));
|
||||
this.hasInterior = intToBool(toInteger(houseAssoc["house_has_interior"]));
|
||||
|
||||
this.entrancePosition = toVector3(toFloat(dbAssoc["house_entrance_pos_x"]), toFloat(dbAssoc["house_entrance_pos_y"]), toFloat(dbAssoc["house_entrance_pos_z"]));
|
||||
this.entranceRotation = toFloat(dbAssoc["house_entrance_rot_z"]);
|
||||
this.entranceInterior = toInteger(dbAssoc["house_entrance_int"]);
|
||||
this.entranceDimension = toInteger(dbAssoc["house_entrance_vw"]);
|
||||
this.entrancePickupModel = toInteger(dbAssoc["house_entrance_pickup"]);
|
||||
this.entranceBlipModel = toInteger(dbAssoc["house_entrance_blip"]);
|
||||
this.entrancePosition = toVector3(toFloat(houseAssoc["house_entrance_pos_x"]), toFloat(houseAssoc["house_entrance_pos_y"]), toFloat(houseAssoc["house_entrance_pos_z"]));
|
||||
this.entranceRotation = toFloat(houseAssoc["house_entrance_rot_z"]);
|
||||
this.entranceInterior = toInteger(houseAssoc["house_entrance_int"]);
|
||||
this.entranceDimension = toInteger(houseAssoc["house_entrance_vw"]);
|
||||
this.entrancePickupModel = toInteger(houseAssoc["house_entrance_pickup"]);
|
||||
this.entranceBlipModel = toInteger(houseAssoc["house_entrance_blip"]);
|
||||
|
||||
this.exitPosition = toVector3(toFloat(dbAssoc["house_exit_pos_x"]), toFloat(dbAssoc["house_exit_pos_y"]), toFloat(dbAssoc["house_exit_pos_z"]));
|
||||
this.exitRotation = toFloat(dbAssoc["house_exit_rot_z"]);
|
||||
this.exitInterior = toInteger(dbAssoc["house_exit_int"]);
|
||||
this.exitDimension = toInteger(dbAssoc["house_exit_vw"]);
|
||||
this.exitPickupModel = toInteger(dbAssoc["house_exit_pickup"]);
|
||||
this.exitBlipModel = toInteger(dbAssoc["house_exit_blip"]);
|
||||
this.exitPosition = toVector3(toFloat(houseAssoc["house_exit_pos_x"]), toFloat(houseAssoc["house_exit_pos_y"]), toFloat(houseAssoc["house_exit_pos_z"]));
|
||||
this.exitRotation = toFloat(houseAssoc["house_exit_rot_z"]);
|
||||
this.exitInterior = toInteger(houseAssoc["house_exit_int"]);
|
||||
this.exitDimension = toInteger(houseAssoc["house_exit_vw"]);
|
||||
this.exitPickupModel = toInteger(houseAssoc["house_exit_pickup"]);
|
||||
this.exitBlipModel = toInteger(houseAssoc["house_exit_blip"]);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -913,7 +979,6 @@ function initClassTable() {
|
||||
this.whiteListEnabled = dbAssoc["job_wl"];
|
||||
this.blackListEnabled = dbAssoc["job_bl"];
|
||||
this.walkieTalkieFrequency = dbAssoc["job_walkietalkiefreq"];
|
||||
|
||||
this.equipment = [];
|
||||
this.uniforms = [];
|
||||
this.locations = [];
|
||||
|
||||
@@ -39,6 +39,7 @@ function loadHousesFromDatabase() {
|
||||
if(dbQuery.numRows > 0) {
|
||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
let tempHouseData = new serverClasses.houseData(dbAssoc);
|
||||
tempHouseData.locations = loadHouseLocationsFromDatabase(tempHouseData.databaseId);
|
||||
tempHouses.push(tempHouseData);
|
||||
logToConsole(LOG_VERBOSE, `[Asshat.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`);
|
||||
}
|
||||
@@ -53,6 +54,35 @@ function loadHousesFromDatabase() {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadHouseLocationsFromDatabase(houseId) {
|
||||
console.log(`[Asshat.House]: Loading locations for business '${getBusinessData(businessId).name}' from database ...`);
|
||||
|
||||
let tempHouseLocations = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc;
|
||||
|
||||
if(dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM house_loc WHERE house_loc_house=${houseId}`);
|
||||
if(dbQuery) {
|
||||
if(dbQuery.numRows > 0) {
|
||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
let tempHouseLocationData = new serverClasses.houseLocationData(dbAssoc);
|
||||
tempHouseLocations.push(tempHouseLocationData);
|
||||
console.log(`[Asshat.House]: Location for house '${getHouseData(houseId).name}' loaded from database successfully!`);
|
||||
}
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
console.log(`[Asshat.House]: ${tempHouseLocations.length} locations for house '${getHouseData(houseId).name}' loaded from database successfully`);
|
||||
return tempHouseLocations;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function createHouseCommand(command, params, client) {
|
||||
let tempHouseData = createHouse(params, getPlayerPosition(client), toVector3(0.0, 0.0, 0.0), getGameConfig().pickupModels[getServerGame()].house, getGameConfig().blipSprites[getServerGame()].house, getPlayerInterior(client), getPlayerDimension(client));
|
||||
getServerData().houses.push(tempHouseData);
|
||||
@@ -69,7 +99,6 @@ function createHouseCommand(command, params, client) {
|
||||
|
||||
function lockUnlockHouseCommand(command, params, client) {
|
||||
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
|
||||
|
||||
if(!getHouseData(houseId)) {
|
||||
messagePlayerError("House not found!");
|
||||
return false;
|
||||
@@ -85,7 +114,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 = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)).house;
|
||||
|
||||
if(!getHouseData(houseId)) {
|
||||
messagePlayerError("House not found!");
|
||||
@@ -102,7 +131,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 = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)).house;
|
||||
|
||||
if(!newHouseOwner) {
|
||||
messagePlayerError("Player not found!");
|
||||
@@ -122,7 +151,7 @@ function setHouseOwnerCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setHouseClanCommand(command, params, client) {
|
||||
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
|
||||
let houseId = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)).house;
|
||||
|
||||
let clan = getClanFromParams(params);
|
||||
|
||||
@@ -145,34 +174,36 @@ 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 = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)).house;
|
||||
|
||||
if(!getHouseData(houseId)) {
|
||||
messagePlayerError(client, "House not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
let entrancePickupModel = getGameConfig().pickupModels[getServerGame()].house;
|
||||
|
||||
if(isNaN(typeParam)) {
|
||||
if(isNull(getGameConfig().pickupModels[getServerGame()][typeParam])) {
|
||||
messagePlayerError(client, "Invalid house type! Use a house type name or a pickup model ID");
|
||||
messagePlayerInfo(client, `Pickup Types: [#AAAAAA]${Object.keys(getGameConfig().pickupModels[getServerGame()]).join(", ")}`)
|
||||
messagePlayerInfo(client, `Pickup Types: [#AAAAAA]${Object.keys(getGameConfig().pickupModels[getServerGame()]).join(", ")}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
getHouseData(houseId).entrancePickupModel = getGameConfig().pickupModels[getServerGame()][typeParam];
|
||||
entrancePickupModel = getGameConfig().pickupModels[getServerGame()][typeParam];
|
||||
} else {
|
||||
getHouseData(houseId).entrancePickupModel = toInteger(typeParam);
|
||||
entrancePickupModel = toInteger(typeParam);
|
||||
}
|
||||
|
||||
if(getHouseData(houseId).entrancePickupModel != -1) {
|
||||
if(getHouseData(houseId).entrancePickup != null) {
|
||||
deleteGameElement(getHouseData(houseId).entrancePickup);
|
||||
for(let i in getHouseData(houseId).locations) {
|
||||
getHouseData(houseId).locations[i].entrancePickupModel = entrancePickupModel;
|
||||
deleteHouseLocationEntrancePickup(houseId, i);
|
||||
if(getHouseData(houseId).locations[i].entrancePickupModel != -1) {
|
||||
createHouseLocationEntrancePickup(houseId, i);
|
||||
}
|
||||
|
||||
createHouseEntrancePickup(houseId);
|
||||
}
|
||||
|
||||
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]pickup display to [#AAAAAA]${toLowerCase(typeParam)}`);
|
||||
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]pickup display to [#AAAAAA]${entrancePickupModel}`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -229,13 +260,15 @@ 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 = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)).house;
|
||||
|
||||
if(!getHouseData(houseId)) {
|
||||
messagePlayerError(client, "House not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
let entranceBlipModel = getGameConfig().blipSprites[getServerGame()].house;
|
||||
|
||||
if(isNaN(typeParam)) {
|
||||
if(isNull(getGameConfig().blipSprites[getServerGame()][typeParam])) {
|
||||
messagePlayerError(client, "Invalid house type! Use a house type name or a blip image ID");
|
||||
@@ -243,26 +276,24 @@ function setHouseBlipCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getHouseData(houseId).entranceBlipModel = getGameConfig().blipSprites[getServerGame()][typeParam];
|
||||
entranceBlipModel = getGameConfig().blipSprites[getServerGame()][typeParam];
|
||||
} else {
|
||||
getHouseData(houseId).entranceBlipModel = toInteger(typeParam);
|
||||
entranceBlipModel = toInteger(typeParam);
|
||||
}
|
||||
|
||||
if(getHouseData(houseId).entranceBlipModel != -1) {
|
||||
if(getHouseData(houseId).entranceBlip != null) {
|
||||
deleteGameElement(getHouseData(houseId).entranceBlip);
|
||||
}
|
||||
|
||||
createHouseEntranceBlip(houseId);
|
||||
}
|
||||
|
||||
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]blip display to [#AAAAAA]${toLowerCase(typeParam)}`);
|
||||
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]blip display to [#AAAAAA]${entranceBlipModel}`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function moveHouseEntranceCommand(command, params, client) {
|
||||
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
|
||||
let houseId = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)).house;
|
||||
|
||||
if(!getHouseData(houseId)) {
|
||||
messagePlayer(client, "You need to be near or inside a house!");
|
||||
@@ -285,7 +316,7 @@ function moveHouseEntranceCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function moveHouseExitCommand(command, params, client) {
|
||||
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
|
||||
let houseId = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)).house;
|
||||
|
||||
if(!getHouseData(houseId)) {
|
||||
messagePlayer(client, "You need to be near or inside a house!");
|
||||
@@ -308,7 +339,7 @@ function moveHouseExitCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function deleteHouseCommand(command, params, client) {
|
||||
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
|
||||
let houseId = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)).house;
|
||||
|
||||
if(!getHouseData(houseId)) {
|
||||
messagePlayerError("House not found!");
|
||||
@@ -391,11 +422,12 @@ function getHouseDataFromDatabaseId(databaseId) {
|
||||
// ===========================================================================
|
||||
|
||||
function getClosestHouseEntrance(position) {
|
||||
let houses = getServerData().houses;
|
||||
let closest = 0;
|
||||
let closest = getServerData().houses[0].locations[0];
|
||||
for(let i in houses) {
|
||||
if(getDistance(houses[i].entrancePosition, position) <= getDistance(houses[closest].entrancePosition, position)) {
|
||||
closest = i;
|
||||
for(let j in getServerData().houses[i].locations) {
|
||||
if(getDistance(position, houses[i].locations[j].entrancePosition) <= getDistance(position, closest.entrancePosition)) {
|
||||
closest = getServerData().houses[i].locations[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
@@ -477,10 +509,36 @@ function saveHouseToDatabase(houseId) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function saveHouseLocationToDatabase(houseId, locationId) {
|
||||
let tempHouseLocationData = getHouseData(houseId).locations[locationId];
|
||||
|
||||
console.log(`[Asshat.House]: Saving house location ${tempHouseLocationData.databaseId} to database ...`);
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
if(tempHouseLocationData.databaseId == 0) {
|
||||
let dbQueryString = `INSERT INTO house_loc (house_loc_house, house_loc_locked, house_loc_entrance_pos_x, house_loc_entrance_pos_y, house_loc_entrance_pos_z, house_loc_entrance_rot_z, house_loc_entrance_int, house_loc_entrance_vw, house_loc_exit_pos_x, house_loc_exit_pos_y, house_loc_exit_pos_z, house_loc_exit_rot_z, house_loc_exit_int, house_loc_exit_vw) VALUES (${tempHouseLocationData.databaseId}, ${boolToInt(tempHouseLocationData.locked)}, ${tempHouseLocationData.entrancePosition.x}, ${tempHouseLocationData.entrancePosition.y}, ${tempHouseLocationData.entrancePosition.z}, ${tempHouseLocationData.entranceRotation}, ${tempHouseLocationData.entranceInterior}, ${tempHouseLocationData.entranceDimension}, ${tempHouseLocationData.exitPosition.x}, ${tempHouseLocationData.exitPosition.y}, ${tempHouseLocationData.exitPosition.z}, ${tempHouseLocationData.exitRotation}, ${tempHouseLocationData.exitInterior}, ${tempHouseLocationData.exitDimension})`;
|
||||
queryDatabase(dbConnection, dbQueryString);
|
||||
tempHouseLocationData.databaseId = getDatabaseInsertId(dbConnection);
|
||||
} else {
|
||||
let dbQueryString = `UPDATE house_loc SET house_loc_house=${getHouseData(houseId).databaseId}', house_loc_locked=${tempHouseLocationData.locked}, house_loc_entrance_pos_x=${tempHouseLocationData.entrancePosition.x}, house_loc_entrance_pos_y=${tempHouseLocationData.entrancePosition.y}, house_loc_entrance_pos_z=${tempHouseLocationData.entrancePosition.z}, house_loc_entrance_rot_z=${tempHouseLocationData.entranceRotation}, house_loc_entrance_int=${tempHouseLocationData.entranceInterior}, house_loc_entrance_vw=${tempHouseLocationData.entranceDimension}, house_loc_exit_pos_x=${tempHouseLocationData.exitPosition.x}, house_loc_exit_pos_y=${tempHouseLocationData.exitPosition.y}, house_loc_exit_pos_z=${tempHouseLocationData.exitPosition.z}, house_loc_exit_rot_z=${tempHouseData.exitRotation}, house_loc_exit_int=${tempHouseLocationData.exitInterior}, house_loc_exit_vw=${tempHouseLocationData.exitDimension} WHERE house_loc_id=${tempHouseLocationData.databaseId}`;
|
||||
queryDatabase(dbConnection, dbQueryString);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
return true;
|
||||
}
|
||||
console.log(`[Asshat.house]: Saved house location ${tempHouseLocationData.databaseId} to database!`);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function createAllHousePickups() {
|
||||
for(let i in getServerData().houses) {
|
||||
createHouseEntrancePickup(i);
|
||||
createHouseExitPickup(i);
|
||||
for(let j in getServerData().houses[i].locations) {
|
||||
createHouseLocationEntrancePickup(i, j);
|
||||
createHouseLocationExitPickup(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,94 +546,96 @@ function createAllHousePickups() {
|
||||
|
||||
function createAllHouseBlips() {
|
||||
for(let i in getServerData().houses) {
|
||||
createHouseEntranceBlip(i);
|
||||
createHouseExitBlip(i);
|
||||
for(let j in getServerData().houses[i].locations) {
|
||||
createHouseLocationEntranceBlip(i, j);
|
||||
createHouseLocationExitBlip(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createHouseEntrancePickup(houseId) {
|
||||
if(getHouseData(houseId).entrancePickupModel != -1) {
|
||||
function createHouseEntrancePickup(houseId, locationId) {
|
||||
if(getHouseData(houseId).locations[locationId].entrancePickupModel != -1) {
|
||||
let pickupModelId = getGameConfig().pickupModels[getServerGame()].house;
|
||||
|
||||
if(getServerData().houses[houseId].entrancePickupModel != 0) {
|
||||
pickupModelId = getHouseData(houseId).entrancePickupModel;
|
||||
pickupModelId = getHouseData(houseId).locations[locationId].entrancePickupModel;
|
||||
}
|
||||
|
||||
getHouseData(houseId).entrancePickup = gta.createPickup(pickupModelId, getHouseData(houseId).entrancePosition);
|
||||
getHouseData(houseId).entrancePickup.onAllDimensions = false;
|
||||
getHouseData(houseId).entrancePickup.dimension = getHouseData(houseId).entranceDimension;
|
||||
setEntityData(getHouseData(houseId).entrancePickup, "ag.owner.type", AG_PICKUP_HOUSE_ENTRANCE, false);
|
||||
setEntityData(getHouseData(houseId).entrancePickup, "ag.owner.id", houseId, false);
|
||||
setEntityData(getHouseData(houseId).entrancePickup, "ag.label.type", AG_LABEL_HOUSE, true);
|
||||
setEntityData(getHouseData(houseId).entrancePickup, "ag.label.name", getHouseData(houseId).description, true);
|
||||
setEntityData(getHouseData(houseId).entrancePickup, "ag.label.locked", getHouseData(houseId).locked, true);
|
||||
getHouseData(houseId).locations[locationId].entrancePickup = gta.createPickup(pickupModelId, getHouseData(houseId).locations[locationId].entrancePosition);
|
||||
getHouseData(houseId).locations[locationId].entrancePickup.onAllDimensions = false;
|
||||
getHouseData(houseId).locations[locationId].entrancePickup.dimension = getHouseData(houseId).locations[locationId].entranceDimension;
|
||||
getHouseData(houseId).locations[locationId].entrancePickup.setData("ag.owner.type", AG_PICKUP_HOUSE_ENTRANCE, false);
|
||||
getHouseData(houseId).locations[locationId].entrancePickup.setData("ag.owner.id", houseId, false);
|
||||
getHouseData(houseId).locations[locationId].entrancePickup.setData("ag.label.type", AG_LABEL_HOUSE, true);
|
||||
getHouseData(houseId).locations[locationId].entrancePickup.setData("ag.label.name", getHouseData(houseId).description, true);
|
||||
getHouseData(houseId).locations[locationId].entrancePickup.setData("ag.label.locked", getHouseData(houseId).locked, true);
|
||||
if(getHouseData(houseId).buyPrice > 0) {
|
||||
setEntityData(getHouseData(houseId).entrancePickup, "ag.label.price", getHouseData(houseId).buyPrice, true);
|
||||
getHouseData(houseId).locations[locationId].entrancePickup.setData("ag.label.price", getHouseData(houseId).buyPrice, true);
|
||||
}
|
||||
addToWorld(getHouseData(houseId).entrancePickup);
|
||||
addToWorld(getHouseData(houseId).locations[locationId].entrancePickup);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createHouseEntranceBlip(houseId) {
|
||||
if(getHouseData(houseId).entranceBlipModel != -1) {
|
||||
function createHouseEntranceBlip(houseId, locationId) {
|
||||
if(getHouseData(houseId).locations[locationId].entranceBlipModel != -1) {
|
||||
let blipModelId = getGameConfig().blipSprites[getServerGame()].house;
|
||||
|
||||
if(getServerData().houses[houseId].entranceBlipModel != 0) {
|
||||
blipModelId = getHouseData(houseId).entranceBlipModel;
|
||||
if(getServerData().houses[houseId].locations[locationId].entranceBlipModel != 0) {
|
||||
blipModelId = getHouseData(houseId).locations[locationId].entranceBlipModel;
|
||||
}
|
||||
|
||||
getHouseData(houseId).entranceBlip = gta.createBlip(getHouseData(houseId).entrancePosition, blipModelId, 1, getColourByName("houseGreen"));
|
||||
getHouseData(houseId).entranceBlip.onAllDimensions = false;
|
||||
getHouseData(houseId).entranceBlip.dimension = getHouseData(houseId).entranceDimension;
|
||||
setEntityData(getHouseData(houseId).entranceBlip, "ag.owner.type", AG_BLIP_HOUSE_ENTRANCE, false);
|
||||
setEntityData(getHouseData(houseId).entranceBlip, "ag.owner.id", houseId, false);
|
||||
addToWorld(getHouseData(houseId).entranceBlip);
|
||||
getHouseData(houseId).locations[locationId].entranceBlip = gta.createBlip(getHouseData(houseId).locations[locationId].entrancePosition, blipModelId, 1, getColourByName("houseGreen"));
|
||||
getHouseData(houseId).locations[locationId].entranceBlip.onAllDimensions = false;
|
||||
getHouseData(houseId).locations[locationId].entranceBlip.dimension = getHouseData(houseId).locations[locationId].entranceDimension;
|
||||
getHouseData(houseId).locations[locationId].entranceBlip.setData("ag.owner.type", AG_BLIP_HOUSE_ENTRANCE, false);
|
||||
getHouseData(houseId).locations[locationId].entranceBlip.setData("ag.owner.id", houseId, false);
|
||||
addToWorld(getHouseData(houseId).locations[locationId].entranceBlip);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createHouseExitPickup(houseId) {
|
||||
function createHouseExitPickup(houseId, locationId) {
|
||||
if(getHouseData(houseId).hasInterior) {
|
||||
if(getHouseData(houseId).exitPickupModel != -1) {
|
||||
if(getHouseData(houseId).locations[locationId].exitPickupModel != -1) {
|
||||
let pickupModelId = getGameConfig().pickupModels[getServerGame()].exit;
|
||||
|
||||
if(getServerData().houses[houseId].exitPickupModel != 0) {
|
||||
pickupModelId = getHouseData(houseId).exitPickupModel;
|
||||
if(getServerData().houses[houseId].locations[locationId].exitPickupModel != 0) {
|
||||
pickupModelId = getHouseData(houseId).locations[locationId].exitPickupModel;
|
||||
}
|
||||
|
||||
getHouseData(houseId).exitPickup = gta.createPickup(pickupModelId, getHouseData(houseId).exitPosition);
|
||||
getHouseData(houseId).exitPickup.onAllDimensions = false;
|
||||
getHouseData(houseId).exitPickup.dimension = getHouseData(houseId).exitDimension;
|
||||
setEntityData(getHouseData(houseId).exitPickup, "ag.owner.type", AG_PICKUP_HOUSE_EXIT, false);
|
||||
setEntityData(getHouseData(houseId).exitPickup, "ag.owner.id", houseId, false);
|
||||
setEntityData(getHouseData(houseId).exitPickup, "ag.label.type", AG_LABEL_EXIT, true);
|
||||
addToWorld(getHouseData(houseId).exitPickup);
|
||||
getHouseData(houseId).locations[locationId].exitPickup = gta.createPickup(pickupModelId, getHouseData(houseId).locations[locationId].exitPosition);
|
||||
getHouseData(houseId).locations[locationId].exitPickup.onAllDimensions = false;
|
||||
getHouseData(houseId).locations[locationId].exitPickup.dimension = getHouseData(houseId).locations[locationId].exitDimension;
|
||||
getHouseData(houseId).locations[locationId].exitPickup.setData("ag.owner.type", AG_PICKUP_HOUSE_EXIT, false);
|
||||
getHouseData(houseId).locations[locationId].exitPickup.setData("ag.owner.id", houseId, false);
|
||||
getHouseData(houseId).locations[locationId].exitPickup.setData("ag.label.type", AG_LABEL_EXIT, true);
|
||||
addToWorld(getHouseData(houseId).locations[locationId].exitPickup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createHouseExitBlip(houseId) {
|
||||
function createHouseExitBlip(houseId, locationId) {
|
||||
if(getHouseData(houseId).hasInterior) {
|
||||
if(getHouseData(houseId).exitBlipModel != -1) {
|
||||
let blipModelId = getGameConfig().blipSprites[getServerGame()].house;
|
||||
if(getHouseData(houseId).locations[locationId].exitBlipModel != -1) {
|
||||
let blipModelId = getGameConfig().locations[locationId].blipSprites[getServerGame()].house;
|
||||
|
||||
if(getServerData().houses[houseId].exitBlipModel != 0) {
|
||||
blipModelId = getHouseData(houseId).exitBlipModel;
|
||||
blipModelId = getHouseData(houseId).locations[locationId].exitBlipModel;
|
||||
}
|
||||
|
||||
getHouseData(houseId).exitBlip = gta.createBlip(blipModelId, getHouseData(houseId).exitPosition, 1, getColourByName("houseGreen"));
|
||||
getHouseData(houseId).exitBlip.onAllDimensions = false;
|
||||
getHouseData(houseId).exitBlip.dimension = getHouseData(houseId).entranceDimension;
|
||||
setEntityData(getHouseData(houseId).exitBlip, "ag.owner.type", AG_BLIP_HOUSE_EXIT, false);
|
||||
setEntityData(getHouseData(houseId).exitBlip, "ag.owner.id", houseId, false);
|
||||
addToWorld(getHouseData(houseId).exitBlip);
|
||||
getHouseData(houseId).locations[locationId].exitBlip = gta.createBlip(getHouseData(houseId).locations[locationId].exitPosition, blipModelId, 1, getColourByName("houseGreen"));
|
||||
getHouseData(houseId).locations[locationId].exitBlip.onAllDimensions = false;
|
||||
getHouseData(houseId).locations[locationId].exitBlip.dimension = getHouseData(houseId).locations[locationId].entranceDimension;
|
||||
getHouseData(houseId).locations[locationId].exitBlip.setData("ag.owner.type", AG_BLIP_HOUSE_EXIT, false);
|
||||
getHouseData(houseId).locations[locationId].exitBlip.setData("ag.owner.id", houseId, false);
|
||||
addToWorld(getHouseData(houseId).locations[locationId].exitBlip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -607,7 +667,7 @@ function getHouseOwnerTypeText(ownerType) {
|
||||
// ===========================================================================
|
||||
|
||||
function getHouseInfoCommand(command, params, client) {
|
||||
let houseId = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
|
||||
let houseId = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)).house;
|
||||
|
||||
if(!areParamsEmpty(params)) {
|
||||
houseId = toInteger(params);
|
||||
@@ -665,43 +725,37 @@ function doesHouseHaveInterior(houseId) {
|
||||
return getHouseData(houseId).hasInterior;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteHouseEntrancePickup(houseId) {
|
||||
if(getHouseData(houseId).entrancePickup != null) {
|
||||
//removeFromWorld(getHouseData(houseId).entrancePickup);
|
||||
deleteGameElement(getHouseData(houseId).entrancePickup);
|
||||
getHouseData(houseId).entrancePickup = null;
|
||||
function deleteHouseLocationEntrancePickup(houseId) {
|
||||
if(getHouseData(houseId).locations[locationId].entrancePickup != null) {
|
||||
destroyElement(getHouseData(houseId).locations[locationId].entrancePickup);
|
||||
getHouseData(houseId).locations[locationId].entrancePickup = null;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteHouseExitPickup(houseId) {
|
||||
if(getHouseData(houseId).exitPickup != null) {
|
||||
//removeFromWorld(getHouseData(houseId).exitPickup);
|
||||
deleteGameElement(getHouseData(houseId).exitPickup);
|
||||
getHouseData(houseId).exitPickup = null;
|
||||
function deleteHouseLocationExitPickup(houseId, locationId) {
|
||||
if(getHouseData(houseId).locations[locationId].exitPickup != null) {
|
||||
destroyElement(getHouseData(houseId).locations[locationId].exitPickup);
|
||||
getHouseData(houseId).locations[locationId].exitPickup = null;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteHouseEntranceBlip(houseId) {
|
||||
if(getHouseData(houseId).entranceBlip != null) {
|
||||
//removeFromWorld(getHouseData(houseId).entranceBlip);
|
||||
deleteGameElement(getHouseData(houseId).entranceBlip);
|
||||
getHouseData(houseId).entranceBlip = null;
|
||||
function deleteHouseLocationEntranceBlip(houseId, locationId) {
|
||||
if(getHouseData(houseId).locations[locationId].entranceBlip != null) {
|
||||
destroyElement(getHouseData(houseId).locations[locationId].entranceBlip);
|
||||
getHouseData(houseId).locations[locationId].entranceBlip = null;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteHouseExitBlip(houseId) {
|
||||
if(getHouseData(houseId).exitBlip != null) {
|
||||
//removeFromWorld(getHouseData(houseId).exitBlip);
|
||||
deleteGameElement(getHouseData(houseId).exitBlip);
|
||||
getHouseData(houseId).exitBlip = null;
|
||||
function deleteHouseLocationExitBlip(houseId, locationId) {
|
||||
if(getHouseData(houseId).locations[locationId].exitBlip != null) {
|
||||
destroyElement(getHouseData(houseId).locations[locationId].exitBlip);
|
||||
getHouseData(houseId).locations[locationId].exitBlip = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -716,10 +770,10 @@ function reloadAllHousesCommand(command, params, client) {
|
||||
}
|
||||
|
||||
for(let i in getServerData().houses) {
|
||||
deleteHouseExitBlip(i);
|
||||
deleteHouseEntranceBlip(i);
|
||||
deleteHouseExitPickup(i);
|
||||
deleteHouseEntrancePickup(i);
|
||||
deleteHouseExitBlips(i);
|
||||
deleteHouseEntranceBlips(i);
|
||||
deleteHouseExitPickups(i);
|
||||
deleteHouseEntrancePickups(i);
|
||||
}
|
||||
|
||||
getServerData().houses = null;
|
||||
|
||||
@@ -1332,6 +1332,35 @@ function saveJobToDatabase(jobData) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function saveJobToDatabase(jobData) {
|
||||
if(jobData == null) {
|
||||
// Invalid job data
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log(`[Asshat.Job]: Saving job ${jobData.name} to database ...`);
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
let safeName = escapeDatabaseString(dbConnection, jobData.name);
|
||||
// If job hasn't been added to database, ID will be 0
|
||||
if(jobData.databaseId == 0) {
|
||||
let dbQueryString = `INSERT INTO job_main (job_name, job_enabled, job_pickup, job_blip, job_type, job_colour_r, job_colour_g, job_colour_b, job_whitelist, job_blacklist) VALUES ('${safeName}', ${boolToInt(jobData.enabled)}, ${jobData.pickupModel}, ${jobData.blipModel}, ${jobData.type}, ${jobData.colourArray[0]}, ${jobData.colourArray[1]}, ${jobData.colourArray[2]})`;
|
||||
queryDatabase(dbConnection, dbQueryString);
|
||||
jobData.databaseId = getDatabaseInsertId(dbConnection);
|
||||
} else {
|
||||
let dbQueryString = `UPDATE job_main SET job_name='${safeName}', job_enabled=${boolToInt(jobData.enabled)}, job_pickup=${jobData.pickupModel}, job_blip=${jobData.blipModel}, job_type=${jobData.type}, job_colour_r=${jobData.colourArray[0]}, job_colour_g=${jobData.colourArray[1]}, job_colour_b=${jobData.colourArray[2]} WHERE job_id=${jobData.databaseId}`;
|
||||
queryDatabase(dbConnection, dbQueryString);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
return true;
|
||||
}
|
||||
console.log(`[Asshat.Job]: Saved job ${jobData.name} to database!`);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function saveJobLocationToDatabase(jobLocationData) {
|
||||
if(jobLocationData == null) {
|
||||
// Invalid job location data
|
||||
|
||||
Reference in New Issue
Block a user