Test
This commit is contained in:
@@ -53,7 +53,7 @@ function loadBusinessesFromDatabase() {
|
|||||||
let tempBusinessData = new serverClasses.businessData(dbAssoc);
|
let tempBusinessData = new serverClasses.businessData(dbAssoc);
|
||||||
tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId);
|
tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId);
|
||||||
tempBusinesses.push(tempBusinessData);
|
tempBusinesses.push(tempBusinessData);
|
||||||
console.log(`[Asshat.Business]: Business '${tempBusinessData.name}' (ID ${tempBusinessData.databaseId}) loaded from database successfully!`);
|
console.log(`[Asshat.Business]: Business '${tempBusinessData.name}' (ID ${tempBusinessData.databaseId}) loaded from database successfully`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
freeDatabaseQuery(dbQuery);
|
freeDatabaseQuery(dbQuery);
|
||||||
@@ -68,7 +68,7 @@ function loadBusinessesFromDatabase() {
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function loadBusinessLocationsFromDatabase(businessId) {
|
function loadBusinessLocationsFromDatabase(businessId) {
|
||||||
//console.log("[Asshat.Business]: Loading locations from database ...");
|
console.log(`[Asshat.Business]: Loading locations for business '${getBusinessData(businessId).name}' from database ...`);
|
||||||
|
|
||||||
let tempBusinessLocations = [];
|
let tempBusinessLocations = [];
|
||||||
let dbConnection = connectToDatabase();
|
let dbConnection = connectToDatabase();
|
||||||
@@ -76,13 +76,13 @@ function loadBusinessLocationsFromDatabase(businessId) {
|
|||||||
let dbAssoc;
|
let dbAssoc;
|
||||||
|
|
||||||
if(dbConnection) {
|
if(dbConnection) {
|
||||||
dbQuery = queryDatabase(dbConnection, "SELECT * FROM `biz_loc` WHERE `biz_loc_biz` = " + toString(businessId));
|
dbQuery = queryDatabase(dbConnection, `SELECT * FROM biz_loc WHERE biz_loc_biz=${businessId}`);
|
||||||
if(dbQuery) {
|
if(dbQuery) {
|
||||||
if(dbQuery.numRows > 0) {
|
if(dbQuery.numRows > 0) {
|
||||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
let tempBusinessLocationData = new serverClasses.businessLocationData(dbAssoc);
|
let tempBusinessLocationData = new serverClasses.businessLocationData(dbAssoc);
|
||||||
tempBusinessLocations.push(tempBusinessLocationData);
|
tempBusinessLocations.push(tempBusinessLocationData);
|
||||||
//console.log(`[Asshat.Business]: Location '${tempBusinessLocationData.name}' loaded from database successfully!`);
|
console.log(`[Asshat.Business]: Location for business '${getBusinessData(businessId).name}' loaded from database successfully!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
freeDatabaseQuery(dbQuery);
|
freeDatabaseQuery(dbQuery);
|
||||||
@@ -90,7 +90,7 @@ function loadBusinessLocationsFromDatabase(businessId) {
|
|||||||
disconnectFromDatabase(dbConnection);
|
disconnectFromDatabase(dbConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.log(`[Asshat.Business]: ${tempBusinessLocations.length} location for business ${businessId} loaded from database successfully!`);
|
console.log(`[Asshat.Business]: ${tempBusinessLocations.length} locations for business '${getBusinessData(businessId).name}' loaded from database successfully`);
|
||||||
return tempBusinessLocations;
|
return tempBusinessLocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,8 +644,10 @@ function saveBusinessToDatabase(businessId) {
|
|||||||
|
|
||||||
function createAllBusinessPickups() {
|
function createAllBusinessPickups() {
|
||||||
for(let i in getServerData().businesses) {
|
for(let i in getServerData().businesses) {
|
||||||
createBusinessEntrancePickup(i);
|
for(let j in getServerData().businesses[i].locations) {
|
||||||
createBusinessExitPickup(i);
|
createBusinessLocationEntrancePickup(i, j);
|
||||||
|
createBusinessLocationExitPickup(i, j);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,98 +655,97 @@ function createAllBusinessPickups() {
|
|||||||
|
|
||||||
function createAllBusinessBlips() {
|
function createAllBusinessBlips() {
|
||||||
for(let i in getServerData().businesses) {
|
for(let i in getServerData().businesses) {
|
||||||
createBusinessEntranceBlip(i);
|
for(let j in getServerData().businesses[i].locations) {
|
||||||
createBusinessExitBlip(i);
|
createBusinessLocationEntranceBlip(i, j);
|
||||||
|
createBusinessLocationExitBlip(i, j);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function createBusinessEntrancePickup(businessId) {
|
function createBusinessLocationEntrancePickup(businessId, locationId) {
|
||||||
if(getBusinessData(businessId).entrancePickupModel != -1) {
|
if(getBusinessData(businessId).locations[locationId].entrancePickupModel != -1) {
|
||||||
let pickupModelId = getGameConfig().pickupModels[getServerGame()].business;
|
let pickupModelId = getGameConfig().pickupModels[getServerGame()].business;
|
||||||
|
|
||||||
if(getServerData().businesses[businessId].entrancePickupModel != 0) {
|
if(getServerData().businesses[businessId].locations[locationId].entrancePickupModel != 0) {
|
||||||
pickupModelId = getBusinessData(businessId).entrancePickupModel;
|
pickupModelId = getBusinessData(businessId).locations[locationId].entrancePickupModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
getBusinessData(businessId).entrancePickup = gta.createPickup(pickupModelId, getBusinessData(businessId).entrancePosition);
|
getBusinessData(businessId).locations[locationId].entrancePickup = gta.createPickup(pickupModelId, getBusinessData(businessId).locations[locationId].entrancePosition);
|
||||||
getBusinessData(businessId).entrancePickup.onAllDimensions = false;
|
getBusinessData(businessId).locations[locationId].entrancePickup.onAllDimensions = false;
|
||||||
getBusinessData(businessId).entrancePickup.dimension = getBusinessData(businessId).entranceDimension;
|
getBusinessData(businessId).locations[locationId].entrancePickup.dimension = getBusinessData(businessId).locations[locationId].entranceDimension;
|
||||||
//getBusinessData(businessId).entrancePickup.interior = getBusinessData(businessId).entranceInterior;
|
getBusinessData(businessId).locations[locationId].entrancePickup.setData("ag.owner.type", AG_PICKUP_BUSINESS_ENTRANCE, false);
|
||||||
getBusinessData(businessId).entrancePickup.setData("ag.owner.type", AG_PICKUP_BUSINESS_ENTRANCE, false);
|
getBusinessData(businessId).locations[locationId].entrancePickup.setData("ag.owner.id", businessId, false);
|
||||||
getBusinessData(businessId).entrancePickup.setData("ag.owner.id", businessId, false);
|
getBusinessData(businessId).locations[locationId].entrancePickup.setData("ag.label.type", AG_LABEL_BUSINESS, true);
|
||||||
getBusinessData(businessId).entrancePickup.setData("ag.label.type", AG_LABEL_BUSINESS, true);
|
getBusinessData(businessId).locations[locationId].entrancePickup.setData("ag.label.name", getBusinessData(businessId).name, true);
|
||||||
getBusinessData(businessId).entrancePickup.setData("ag.label.name", getBusinessData(businessId).name, true);
|
getBusinessData(businessId).locations[locationId].entrancePickup.setData("ag.label.locked", getBusinessData(businessId).locked, true);
|
||||||
getBusinessData(businessId).entrancePickup.setData("ag.label.locked", getBusinessData(businessId).locked, true);
|
|
||||||
if(getBusinessData(businessId).buyPrice > 0) {
|
if(getBusinessData(businessId).buyPrice > 0) {
|
||||||
getBusinessData(businessId).entrancePickup.setData("ag.label.price", getBusinessData(businessId).buyPrice, true);
|
getBusinessData(businessId).locations[locationId].entrancePickup.setData("ag.label.price", getBusinessData(businessId).buyPrice, true);
|
||||||
}
|
}
|
||||||
addToWorld(getBusinessData(businessId).entrancePickup);
|
addToWorld(getBusinessData(businessId).locations[locationId].entrancePickup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function createBusinessEntranceBlip(businessId) {
|
function createBusinessLocationEntranceBlip(businessId, locationId) {
|
||||||
if(getBusinessData(businessId).entranceBlipModel != -1) {
|
if(getBusinessData(businessId).locations[locationId].entranceBlipModel != -1) {
|
||||||
let blipModelId = getGameConfig().blipSprites[getServerGame()].business;
|
let blipModelId = getGameConfig().blipSprites[getServerGame()].business;
|
||||||
|
|
||||||
if(getServerData().businesses[businessId].entranceBlipModel != 0) {
|
if(getServerData().businesses[businessId].entranceBlipModel != 0) {
|
||||||
blipModelId = getBusinessData(businessId).entranceBlipModel;
|
blipModelId = getBusinessData(businessId).locations[locationId].entranceBlipModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
getBusinessData(businessId).entranceBlip = gta.createBlip(getBusinessData(businessId).entrancePosition, blipModelId, 1, getColourByName("businessBlue"));
|
getBusinessData(businessId).locations[locationId].entranceBlip = gta.createBlip(getBusinessData(businessId).locations[locationId].entrancePosition, blipModelId, 1, getColourByName("businessBlue"));
|
||||||
getBusinessData(businessId).entranceBlip.onAllDimensions = false;
|
getBusinessData(businessId).locations[locationId].entranceBlip.onAllDimensions = false;
|
||||||
getBusinessData(businessId).entranceBlip.dimension = getBusinessData(businessId).entranceDimension;
|
getBusinessData(businessId).locations[locationId].entranceBlip.dimension = getBusinessData(businessId).locations[locationId].entranceDimension;
|
||||||
//getBusinessData(businessId).entranceBlip.interior = getBusinessData(businessId).entranceInterior;
|
getBusinessData(businessId).locations[locationId].entranceBlip.setData("ag.owner.type", AG_BLIP_BUSINESS_ENTRANCE, false);
|
||||||
getBusinessData(businessId).entranceBlip.setData("ag.owner.type", AG_BLIP_BUSINESS_ENTRANCE, false);
|
getBusinessData(businessId).locations[locationId].entranceBlip.setData("ag.owner.id", businessId, false);
|
||||||
getBusinessData(businessId).entranceBlip.setData("ag.owner.id", businessId, false);
|
addToWorld(getBusinessData(businessId).locations[locationId].entranceBlip);
|
||||||
addToWorld(getBusinessData(businessId).entranceBlip);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function createBusinessExitPickup(businessId) {
|
function createBusinessLocationExitPickup(businessId, locationId) {
|
||||||
if(getBusinessData(businessId).hasInterior) {
|
if(getBusinessData(businessId).hasInterior) {
|
||||||
if(getBusinessData(businessId).exitPickupModel != -1) {
|
if(getBusinessData(businessId).locations[locationId].exitPickupModel != -1) {
|
||||||
let pickupModelId = getGameConfig().pickupModels[getServerGame()].exit;
|
let pickupModelId = getGameConfig().pickupModels[getServerGame()].exit;
|
||||||
|
|
||||||
if(getServerData().businesses[businessId].exitPickupModel != 0) {
|
if(getServerData().businesses[businessId].locations[locationId].exitPickupModel != 0) {
|
||||||
pickupModelId = getBusinessData(businessId).exitPickupModel;
|
pickupModelId = getBusinessData(businessId).locations[locationId].exitPickupModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
getBusinessData(businessId).exitPickup = gta.createPickup(pickupModelId, getBusinessData(businessId).exitPosition);
|
getBusinessData(businessId).locations[locationId].exitPickup = gta.createPickup(pickupModelId, getBusinessData(businessId).locations[locationId].exitPosition);
|
||||||
getBusinessData(businessId).exitPickup.onAllDimensions = false;
|
getBusinessData(businessId).locations[locationId].exitPickup.onAllDimensions = false;
|
||||||
getBusinessData(businessId).exitPickup.dimension = getBusinessData(businessId).exitDimension;
|
getBusinessData(businessId).locations[locationId].exitPickup.dimension = getBusinessData(businessId).locations[locationId].exitDimension;
|
||||||
//getBusinessData(businessId).exitPickup.interior = getBusinessData(businessId).exitInterior;
|
getBusinessData(businessId).locations[locationId].exitPickup.setData("ag.owner.type", AG_PICKUP_BUSINESS_EXIT, false);
|
||||||
getBusinessData(businessId).exitPickup.setData("ag.owner.type", AG_PICKUP_BUSINESS_EXIT, false);
|
getBusinessData(businessId).locations[locationId].exitPickup.setData("ag.owner.id", businessId, false);
|
||||||
getBusinessData(businessId).exitPickup.setData("ag.owner.id", businessId, false);
|
getBusinessData(businessId).locations[locationId].exitPickup.setData("ag.label.type", AG_LABEL_EXIT, true);
|
||||||
getBusinessData(businessId).exitPickup.setData("ag.label.type", AG_LABEL_EXIT, true);
|
addToWorld(getBusinessData(businessId).locations[locationId].exitPickup);
|
||||||
addToWorld(getBusinessData(businessId).exitPickup);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function createBusinessExitBlip(businessId) {
|
function createBusinessLocationExitBlip(businessId, locationId) {
|
||||||
if(getBusinessData(businessId).hasInterior) {
|
if(getBusinessData(businessId).hasInterior) {
|
||||||
if(getBusinessData(businessId).exitBlipModel != -1) {
|
if(getBusinessData(businessId).locations[locationId].exitBlipModel != -1) {
|
||||||
let blipModelId = getGameConfig().blipSprites[getServerGame()].business;
|
let blipModelId = getGameConfig().blipSprites[getServerGame()].business;
|
||||||
|
|
||||||
if(getServerData().businesses[businessId].exitBlipModel != 0) {
|
if(getServerData().businesses[businessId].locations[locationId].exitBlipModel != 0) {
|
||||||
blipModelId = getBusinessData(businessId).exitBlipModel;
|
blipModelId = getBusinessData(businessId).locations[locationId].exitBlipModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
getBusinessData(businessId).exitBlip = gta.createBlip(getBusinessData(businessId).exitPosition, blipModelId, 1, getColourByName("businessBlue"));
|
getBusinessData(businessId).locations[locationId].exitBlip = gta.createBlip(getBusinessData(businessId).locations[locationId].exitPosition, blipModelId, 1, getColourByName("businessBlue"));
|
||||||
getBusinessData(businessId).exitBlip.onAllDimensions = false;
|
getBusinessData(businessId).locations[locationId].exitBlip.onAllDimensions = false;
|
||||||
getBusinessData(businessId).exitBlip.dimension = getBusinessData(businessId).entranceDimension;
|
getBusinessData(businessId).locations[locationId].exitBlip.dimension = getBusinessData(businessId).locations[locationId].entranceDimension;
|
||||||
//getBusinessData(businessId).exitBlip.interior = getBusinessData(businessId).exitInterior;
|
//getBusinessData(businessId).exitBlip.interior = getBusinessData(businessId).exitInterior;
|
||||||
getBusinessData(businessId).exitBlip.setData("ag.owner.type", AG_BLIP_BUSINESS_EXIT, false);
|
getBusinessData(businessId).locations[locationId].exitBlip.setData("ag.owner.type", AG_BLIP_BUSINESS_EXIT, false);
|
||||||
getBusinessData(businessId).exitBlip.setData("ag.owner.id", businessId, false);
|
getBusinessData(businessId).locations[locationId].exitBlip.setData("ag.owner.id", businessId, false);
|
||||||
addToWorld(getBusinessData(businessId).exitBlip);
|
addToWorld(getBusinessData(businessId).locations[locationId].exitBlip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -762,14 +763,19 @@ function deleteBusiness(businessId, deletedBy = 0) {
|
|||||||
if(dbQuery) {
|
if(dbQuery) {
|
||||||
freeDatabaseQuery(dbQuery);
|
freeDatabaseQuery(dbQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbQuery = queryDatabase(dbConnection, `DELETE FROM biz_loc WHERE biz_loc_biz = ${tempBusinessData.databaseId}`);
|
||||||
|
if(dbQuery) {
|
||||||
|
freeDatabaseQuery(dbQuery);
|
||||||
|
}
|
||||||
disconnectFromDatabase(dbConnection);
|
disconnectFromDatabase(dbConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteBusinessEntrancePickup(businessId);
|
deleteBusinessEntrancePickups(businessId);
|
||||||
deleteBusinessExitPickup(businessId);
|
deleteBusinessExitPickups(businessId);
|
||||||
|
|
||||||
deleteBusinessEntranceBlip(businessId);
|
deleteBusinessEntranceBlips(businessId);
|
||||||
deleteBusinessExitBlip(businessId);
|
deleteBusinessExitBlips(businessId);
|
||||||
|
|
||||||
removePlayersFromBusiness(businessId);
|
removePlayersFromBusiness(businessId);
|
||||||
|
|
||||||
@@ -849,63 +855,69 @@ function doesBusinessHaveInterior(businessId) {
|
|||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function sendAllBusinessLabelsToPlayer(client) {
|
function deleteBusinessEntrancePickups(businessId) {
|
||||||
let tempBusinessLabels = [];
|
for(let i in getServerData().businesses[businessId].locations) {
|
||||||
let totalBusinesses = getServerData().businesses.length;
|
deleteBusinessLocationEntrancePickup(businessId, i);
|
||||||
let businessesPerNetworkEvent = 100;
|
|
||||||
let totalNetworkEvents = Math.ceil(totalBusinesses/businessesPerNetworkEvent);
|
|
||||||
for(let i = 0 ; i < totalNetworkEvents ; i++) {
|
|
||||||
for(let j = 0 ; j < businessesPerNetworkEvent ; j++) {
|
|
||||||
let tempBusinessId = (i*businessesPerNetworkEvent)+j;
|
|
||||||
if(typeof getServerData().businesses[tempBusinessId] != "undefined") {
|
|
||||||
let tempBusinessLabels = [];
|
|
||||||
tempBusinessLabels.push([tempBusinessId, getServerData().businesses[tempBusinessId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().businesses[tempBusinessId].description, getServerData().businesses[tempBusinessId].locked, false]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
triggerNetworkEvent("ag.bizlabel.all", client, tempBusinessLabels);
|
|
||||||
tempBusinessLabels = [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function sendBusinessLabelToPlayers(businessId) {
|
function deleteBusinessEntranceBlips(businessId) {
|
||||||
triggerNetworkEvent("ag.bizlabel.add", null, businessId, getServerData().businesses[businessId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().businesses[businessId].name, getServerData().businesses[businessId].locked, false);
|
for(let i in getServerData().businesses[businessId].locations) {
|
||||||
}
|
deleteBusinessLocationEntranceBlip(businessId, i);
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function deleteBusinessEntrancePickup(businessId) {
|
|
||||||
if(getBusinessData(businessId).entrancePickup) {
|
|
||||||
destroyElement(getBusinessData(businessId).entrancePickup);
|
|
||||||
getBusinessData(businessId).entrancePickup = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function deleteBusinessExitPickup(businessId) {
|
function deleteBusinessExitPickups(businessId) {
|
||||||
if(getBusinessData(businessId).exitPickup) {
|
for(let i in getServerData().businesses[businessId].locations) {
|
||||||
destroyElement(getBusinessData(businessId).exitPickup);
|
deleteBusinessLocationExitPickup(businessId, i);
|
||||||
getBusinessData(businessId).exitPickup = false;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
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 deleteBusinessEntranceBlip(businessId) {
|
function deleteBusinessLocationEntranceBlip(businessId, locationId) {
|
||||||
if(getBusinessData(businessId).entranceBlip) {
|
if(getBusinessData(businessId).locations[locationId].entranceBlip) {
|
||||||
destroyElement(getBusinessData(businessId).entranceBlip);
|
destroyElement(getBusinessData(businessId).locations[locationId].entranceBlip);
|
||||||
getBusinessData(businessId).entranceBlip = false;
|
getBusinessData(businessId).locations[locationId].entranceBlip = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function deleteBusinessExitBlip(businessId) {
|
function deleteBusinessLocationExitBlip(businessId, locationId) {
|
||||||
if(getBusinessData(businessId).exitBlip) {
|
if(getBusinessData(businessId).locations[locationId].exitBlip) {
|
||||||
destroyElement(getBusinessData(businessId).exitBlip);
|
destroyElement(getBusinessData(businessId).locations[locationId].exitBlip);
|
||||||
getBusinessData(businessId).exitBlip = false;
|
getBusinessData(businessId).locations[locationId].exitBlip = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -294,22 +294,101 @@ function initClassTable() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
businessLocationData: class {
|
businessLocationData: class {
|
||||||
constructor(businessLocationAssoc) {
|
constructor(dbAssoc) {
|
||||||
if(!businessLocationAssoc) {
|
this.databaseId = 0;
|
||||||
return;
|
this.name = "Unnamed";
|
||||||
|
this.business = 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("biz_loc_id"));
|
||||||
|
this.name = toString(dbAssoc("biz_loc_name"));
|
||||||
|
this.type = toInteger(dbAssoc("biz_loc_type"));
|
||||||
|
this.business = toInteger(dbAssoc("biz_loc_biz"));
|
||||||
|
this.enabled = intToBool(toInteger(dbAssoc("biz_loc_enabled")));
|
||||||
|
|
||||||
|
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"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.databaseId = toInteger(businessLocationAssoc("biz_loc_id"));
|
|
||||||
this.name = toString(businessLocationAssoc("biz_loc_name"));
|
|
||||||
this.type = toInteger(businessLocationAssoc("biz_loc_type"));
|
|
||||||
this.business = toInteger(businessLocationAssoc("biz_loc_biz"));
|
|
||||||
this.enabled = intToBool(toInteger(businessLocationAssoc("biz_loc_enabled")));
|
|
||||||
|
|
||||||
this.position = toVector3(toFloat(businessLocationAssoc("biz_loc_pos_x")), toFloat(businessLocationAssoc("biz_loc_pos_y")), toFloat(businessLocationAssoc("biz_loc_pos_z")));
|
|
||||||
this.interior = toInteger(businessLocationAssoc["biz_loc_int"]);
|
|
||||||
this.dimension = toInteger(businessLocationAssoc["biz_loc_vw"]);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
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"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
houseData: class {
|
houseData: class {
|
||||||
constructor(houseAssoc) {
|
constructor(houseAssoc) {
|
||||||
this.databaseId = 0
|
this.databaseId = 0
|
||||||
@@ -353,8 +432,6 @@ function initClassTable() {
|
|||||||
this.entranceDimension = toInteger(houseAssoc["house_entrance_vw"]);
|
this.entranceDimension = toInteger(houseAssoc["house_entrance_vw"]);
|
||||||
this.entrancePickupModel = toInteger(houseAssoc["house_entrance_pickup"]);
|
this.entrancePickupModel = toInteger(houseAssoc["house_entrance_pickup"]);
|
||||||
this.entranceBlipModel = toInteger(houseAssoc["house_entrance_blip"]);
|
this.entranceBlipModel = toInteger(houseAssoc["house_entrance_blip"]);
|
||||||
this.entrancePickup = null;
|
|
||||||
this.entranceBlip = null;
|
|
||||||
|
|
||||||
this.exitPosition = toVector3(toFloat(houseAssoc["house_exit_pos_x"]), toFloat(houseAssoc["house_exit_pos_y"]), toFloat(houseAssoc["house_exit_pos_z"]));
|
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.exitRotation = toFloat(houseAssoc["house_exit_rot_z"]);
|
||||||
@@ -362,8 +439,6 @@ function initClassTable() {
|
|||||||
this.exitDimension = toInteger(houseAssoc["house_exit_vw"]);
|
this.exitDimension = toInteger(houseAssoc["house_exit_vw"]);
|
||||||
this.exitPickupModel = toInteger(houseAssoc["house_exit_pickup"]);
|
this.exitPickupModel = toInteger(houseAssoc["house_exit_pickup"]);
|
||||||
this.exitBlipModel = toInteger(houseAssoc["house_exit_blip"]);
|
this.exitBlipModel = toInteger(houseAssoc["house_exit_blip"]);
|
||||||
this.exitPickup = null;
|
|
||||||
this.exitBlip = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -524,6 +599,7 @@ function initClassTable() {
|
|||||||
this.blipModel = jobAssoc["job_blip"];
|
this.blipModel = jobAssoc["job_blip"];
|
||||||
this.pickupModel = jobAssoc["job_pickup"];
|
this.pickupModel = jobAssoc["job_pickup"];
|
||||||
this.colour = toColour(jobAssoc["job_colour_r"], jobAssoc["job_colour_g"], jobAssoc["job_colour_b"], 255);
|
this.colour = toColour(jobAssoc["job_colour_r"], jobAssoc["job_colour_g"], jobAssoc["job_colour_b"], 255);
|
||||||
|
this.colourArray = [jobAssoc["job_colour_r"], jobAssoc["job_colour_g"], jobAssoc["job_colour_b"]];
|
||||||
this.whiteListEnabled = jobAssoc["job_whitelist"];
|
this.whiteListEnabled = jobAssoc["job_whitelist"];
|
||||||
this.blackListEnabled = jobAssoc["job_blacklist"];
|
this.blackListEnabled = jobAssoc["job_blacklist"];
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ function loadHousesFromDatabase() {
|
|||||||
if(dbQuery.numRows > 0) {
|
if(dbQuery.numRows > 0) {
|
||||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
let tempHouseData = new serverClasses.houseData(dbAssoc);
|
let tempHouseData = new serverClasses.houseData(dbAssoc);
|
||||||
|
tempHouseData.locations = loadHouseLocationsFromDatabase(tempHouseData.databaseId);
|
||||||
tempHouses.push(tempHouseData);
|
tempHouses.push(tempHouseData);
|
||||||
console.log(`[Asshat.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`);
|
console.log(`[Asshat.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`);
|
||||||
}
|
}
|
||||||
@@ -45,6 +46,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) {
|
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), getPlayerVirtualWorld(client));
|
let tempHouseData = createHouse(params, getPlayerPosition(client), toVector3(0.0, 0.0, 0.0), getGameConfig().pickupModels[getServerGame()].house, getGameConfig().blipSprites[getServerGame()].house, getPlayerInterior(client), getPlayerVirtualWorld(client));
|
||||||
getServerData().houses.push(tempHouseData);
|
getServerData().houses.push(tempHouseData);
|
||||||
@@ -378,10 +408,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() {
|
function createAllHousePickups() {
|
||||||
for(let i in getServerData().houses) {
|
for(let i in getServerData().houses) {
|
||||||
createHouseEntrancePickup(i);
|
for(let j in getServerData().houses[i].locations) {
|
||||||
createHouseExitPickup(i);
|
createHouseLocationEntrancePickup(i, j);
|
||||||
|
createHouseLocationExitPickup(i, j);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,98 +445,96 @@ function createAllHousePickups() {
|
|||||||
|
|
||||||
function createAllHouseBlips() {
|
function createAllHouseBlips() {
|
||||||
for(let i in getServerData().houses) {
|
for(let i in getServerData().houses) {
|
||||||
createHouseEntranceBlip(i);
|
for(let j in getServerData().houses[i].locations) {
|
||||||
createHouseExitBlip(i);
|
createHouseLocationEntranceBlip(i, j);
|
||||||
|
createHouseLocationExitBlip(i, j);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function createHouseEntrancePickup(houseId) {
|
function createHouseEntrancePickup(houseId, locationId) {
|
||||||
if(getHouseData(houseId).entrancePickupModel != -1) {
|
if(getHouseData(houseId).locations[locationId].entrancePickupModel != -1) {
|
||||||
let pickupModelId = getGameConfig().pickupModels[getServerGame()].house;
|
let pickupModelId = getGameConfig().pickupModels[getServerGame()].house;
|
||||||
|
|
||||||
if(getServerData().houses[houseId].entrancePickupModel != 0) {
|
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).locations[locationId].entrancePickup = gta.createPickup(pickupModelId, getHouseData(houseId).locations[locationId].entrancePosition);
|
||||||
getHouseData(houseId).entrancePickup.onAllDimensions = false;
|
getHouseData(houseId).locations[locationId].entrancePickup.onAllDimensions = false;
|
||||||
getHouseData(houseId).entrancePickup.dimension = getHouseData(houseId).entranceDimension;
|
getHouseData(houseId).locations[locationId].entrancePickup.dimension = getHouseData(houseId).locations[locationId].entranceDimension;
|
||||||
//getHouseData(houseId).entrancePickup.interior = getHouseData(houseId).entranceInterior;
|
getHouseData(houseId).locations[locationId].entrancePickup.setData("ag.owner.type", AG_PICKUP_HOUSE_ENTRANCE, false);
|
||||||
getHouseData(houseId).entrancePickup.setData("ag.owner.type", AG_PICKUP_HOUSE_ENTRANCE, false);
|
getHouseData(houseId).locations[locationId].entrancePickup.setData("ag.owner.id", houseId, false);
|
||||||
getHouseData(houseId).entrancePickup.setData("ag.owner.id", houseId, false);
|
getHouseData(houseId).locations[locationId].entrancePickup.setData("ag.label.type", AG_LABEL_HOUSE, true);
|
||||||
getHouseData(houseId).entrancePickup.setData("ag.label.type", AG_LABEL_HOUSE, true);
|
getHouseData(houseId).locations[locationId].entrancePickup.setData("ag.label.name", getHouseData(houseId).description, true);
|
||||||
getHouseData(houseId).entrancePickup.setData("ag.label.name", getHouseData(houseId).description, true);
|
getHouseData(houseId).locations[locationId].entrancePickup.setData("ag.label.locked", getHouseData(houseId).locked, true);
|
||||||
getHouseData(houseId).entrancePickup.setData("ag.label.locked", getHouseData(houseId).locked, true);
|
|
||||||
if(getHouseData(houseId).buyPrice > 0) {
|
if(getHouseData(houseId).buyPrice > 0) {
|
||||||
getHouseData(houseId).entrancePickup.setData("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) {
|
function createHouseEntranceBlip(houseId, locationId) {
|
||||||
if(getHouseData(houseId).entranceBlipModel != -1) {
|
if(getHouseData(houseId).locations[locationId].entranceBlipModel != -1) {
|
||||||
let blipModelId = getGameConfig().blipSprites[getServerGame()].house;
|
let blipModelId = getGameConfig().blipSprites[getServerGame()].house;
|
||||||
|
|
||||||
if(getServerData().houses[houseId].entranceBlipModel != 0) {
|
if(getServerData().houses[houseId].locations[locationId].entranceBlipModel != 0) {
|
||||||
blipModelId = getHouseData(houseId).entranceBlipModel;
|
blipModelId = getHouseData(houseId).locations[locationId].entranceBlipModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
getHouseData(houseId).entranceBlip = gta.createBlip(getHouseData(houseId).entrancePosition, blipModelId, 1, getColourByName("houseGreen"));
|
getHouseData(houseId).locations[locationId].entranceBlip = gta.createBlip(getHouseData(houseId).locations[locationId].entrancePosition, blipModelId, 1, getColourByName("houseGreen"));
|
||||||
getHouseData(houseId).entranceBlip.onAllDimensions = false;
|
getHouseData(houseId).locations[locationId].entranceBlip.onAllDimensions = false;
|
||||||
getHouseData(houseId).entranceBlip.dimension = getHouseData(houseId).entranceDimension;
|
getHouseData(houseId).locations[locationId].entranceBlip.dimension = getHouseData(houseId).locations[locationId].entranceDimension;
|
||||||
//getHouseData(houseId).entranceBlip.interior = getHouseData(houseId).entranceInterior;
|
getHouseData(houseId).locations[locationId].entranceBlip.setData("ag.owner.type", AG_BLIP_HOUSE_ENTRANCE, false);
|
||||||
getHouseData(houseId).entranceBlip.setData("ag.owner.type", AG_BLIP_HOUSE_ENTRANCE, false);
|
getHouseData(houseId).locations[locationId].entranceBlip.setData("ag.owner.id", houseId, false);
|
||||||
getHouseData(houseId).entranceBlip.setData("ag.owner.id", houseId, false);
|
addToWorld(getHouseData(houseId).locations[locationId].entranceBlip);
|
||||||
addToWorld(getHouseData(houseId).entranceBlip);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function createHouseExitPickup(houseId) {
|
function createHouseExitPickup(houseId, locationId) {
|
||||||
if(getHouseData(houseId).hasInterior) {
|
if(getHouseData(houseId).hasInterior) {
|
||||||
if(getHouseData(houseId).exitPickupModel != -1) {
|
if(getHouseData(houseId).locations[locationId].exitPickupModel != -1) {
|
||||||
let pickupModelId = getGameConfig().pickupModels[getServerGame()].exit;
|
let pickupModelId = getGameConfig().pickupModels[getServerGame()].exit;
|
||||||
|
|
||||||
if(getServerData().houses[houseId].exitPickupModel != 0) {
|
if(getServerData().houses[houseId].locations[locationId].exitPickupModel != 0) {
|
||||||
pickupModelId = getHouseData(houseId).exitPickupModel;
|
pickupModelId = getHouseData(houseId).locations[locationId].exitPickupModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
getHouseData(houseId).exitPickup = gta.createPickup(pickupModelId, getHouseData(houseId).exitPosition);
|
getHouseData(houseId).locations[locationId].exitPickup = gta.createPickup(pickupModelId, getHouseData(houseId).locations[locationId].exitPosition);
|
||||||
getHouseData(houseId).exitPickup.onAllDimensions = false;
|
getHouseData(houseId).locations[locationId].exitPickup.onAllDimensions = false;
|
||||||
getHouseData(houseId).exitPickup.dimension = getHouseData(houseId).exitDimension;
|
getHouseData(houseId).locations[locationId].exitPickup.dimension = getHouseData(houseId).locations[locationId].exitDimension;
|
||||||
//getHouseData(houseId).exitPickup.interior = getHouseData(houseId).exitInterior;
|
getHouseData(houseId).locations[locationId].exitPickup.setData("ag.owner.type", AG_PICKUP_HOUSE_EXIT, false);
|
||||||
getHouseData(houseId).exitPickup.setData("ag.owner.type", AG_PICKUP_HOUSE_EXIT, false);
|
getHouseData(houseId).locations[locationId].exitPickup.setData("ag.owner.id", houseId, false);
|
||||||
getHouseData(houseId).exitPickup.setData("ag.owner.id", houseId, false);
|
getHouseData(houseId).locations[locationId].exitPickup.setData("ag.label.type", AG_LABEL_EXIT, true);
|
||||||
getHouseData(houseId).exitPickup.setData("ag.label.type", AG_LABEL_EXIT, true);
|
addToWorld(getHouseData(houseId).locations[locationId].exitPickup);
|
||||||
addToWorld(getHouseData(houseId).exitPickup);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function createHouseExitBlip(houseId) {
|
function createHouseExitBlip(houseId, locationId) {
|
||||||
if(getHouseData(houseId).hasInterior) {
|
if(getHouseData(houseId).hasInterior) {
|
||||||
if(getHouseData(houseId).exitBlipModel != -1) {
|
if(getHouseData(houseId).locations[locationId].exitBlipModel != -1) {
|
||||||
let blipModelId = getGameConfig().blipSprites[getServerGame()].house;
|
let blipModelId = getGameConfig().locations[locationId].blipSprites[getServerGame()].house;
|
||||||
|
|
||||||
if(getServerData().houses[houseId].exitBlipModel != 0) {
|
if(getServerData().houses[houseId].exitBlipModel != 0) {
|
||||||
blipModelId = getHouseData(houseId).exitBlipModel;
|
blipModelId = getHouseData(houseId).locations[locationId].exitBlipModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
getHouseData(houseId).exitBlip = gta.createBlip(getHouseData(houseId).exitPosition, blipModelId, 1, getColourByName("houseGreen"));
|
getHouseData(houseId).locations[locationId].exitBlip = gta.createBlip(getHouseData(houseId).locations[locationId].exitPosition, blipModelId, 1, getColourByName("houseGreen"));
|
||||||
getHouseData(houseId).exitBlip.onAllDimensions = false;
|
getHouseData(houseId).locations[locationId].exitBlip.onAllDimensions = false;
|
||||||
getHouseData(houseId).exitBlip.dimension = getHouseData(houseId).entranceDimension;
|
getHouseData(houseId).locations[locationId].exitBlip.dimension = getHouseData(houseId).locations[locationId].entranceDimension;
|
||||||
//getHouseData(houseId).exitBlip.interior = getHouseData(houseId).exitInterior;
|
getHouseData(houseId).locations[locationId].exitBlip.setData("ag.owner.type", AG_BLIP_HOUSE_EXIT, false);
|
||||||
getHouseData(houseId).exitBlip.setData("ag.owner.type", AG_BLIP_HOUSE_EXIT, false);
|
getHouseData(houseId).locations[locationId].exitBlip.setData("ag.owner.id", houseId, false);
|
||||||
getHouseData(houseId).exitBlip.setData("ag.owner.id", houseId, false);
|
addToWorld(getHouseData(houseId).locations[locationId].exitBlip);
|
||||||
addToWorld(getHouseData(houseId).exitBlip);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -572,62 +626,37 @@ function doesHouseHaveInterior(houseId) {
|
|||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function sendAllHouseLabelsToPlayer(client) {
|
function deleteHouseLocationEntrancePickup(houseId) {
|
||||||
let tempHouseLabels = [];
|
if(getHouseData(houseId).locations[locationId].entrancePickup != null) {
|
||||||
let totalHouses = getServerData().houses.length;
|
destroyElement(getHouseData(houseId).locations[locationId].entrancePickup);
|
||||||
let housesPerNetworkEvent = 100;
|
getHouseData(houseId).locations[locationId].entrancePickup = null;
|
||||||
let totalNetworkEvents = Math.ceil(totalHouses/housesPerNetworkEvent);
|
|
||||||
for(let i = 0 ; i < totalNetworkEvents ; i++) {
|
|
||||||
for(let j = 0 ; j < housesPerNetworkEvent ; j++) {
|
|
||||||
let tempHouseId = (i*housesPerNetworkEvent)+j;
|
|
||||||
if(typeof getServerData().houses[tempHouseId] != "undefined") {
|
|
||||||
tempHouseLabels.push([tempHouseId, getServerData().houses[tempHouseId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().houses[tempHouseId].description, getServerData().houses[tempHouseId].locked, false]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
triggerNetworkEvent("ag.houselabel.all", client, tempHouseLabels);
|
|
||||||
tempHouseLabels = [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function sendHouseLabelToPlayers(houseId) {
|
function deleteHouseLocationExitPickup(houseId, locationId) {
|
||||||
triggerNetworkEvent("ag.houselabel.add", null, houseId, getServerData().houses[houseId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().houses[houseId].description, getServerData().houses[houseId].locked, false);
|
if(getHouseData(houseId).locations[locationId].exitPickup != null) {
|
||||||
}
|
destroyElement(getHouseData(houseId).locations[locationId].exitPickup);
|
||||||
|
getHouseData(houseId).locations[locationId].exitPickup = null;
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function deleteHouseEntrancePickup(houseId) {
|
|
||||||
if(getHouseData(houseId).entrancePickup != null) {
|
|
||||||
destroyElement(getHouseData(houseId).entrancePickup);
|
|
||||||
getHouseData(houseId).entrancePickup = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function deleteHouseExitPickup(houseId) {
|
|
||||||
if(getHouseData(houseId).exitPickup != null) {
|
|
||||||
destroyElement(getHouseData(houseId).exitPickup);
|
|
||||||
getHouseData(houseId).exitPickup = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function deleteHouseEntranceBlip(houseId) {
|
function deleteHouseLocationEntranceBlip(houseId, locationId) {
|
||||||
if(getHouseData(houseId).entranceBlip != null) {
|
if(getHouseData(houseId).locations[locationId].entranceBlip != null) {
|
||||||
destroyElement(getHouseData(houseId).entranceBlip);
|
destroyElement(getHouseData(houseId).locations[locationId].entranceBlip);
|
||||||
getHouseData(houseId).entranceBlip = null;
|
getHouseData(houseId).locations[locationId].entranceBlip = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function deleteHouseExitBlip(houseId) {
|
function deleteHouseLocationExitBlip(houseId, locationId) {
|
||||||
if(getHouseData(houseId).exitBlip != null) {
|
if(getHouseData(houseId).locations[locationId].exitBlip != null) {
|
||||||
destroyElement(getHouseData(houseId).exitBlip);
|
destroyElement(getHouseData(houseId).locations[locationId].exitBlip);
|
||||||
getHouseData(houseId).exitBlip = null;
|
getHouseData(houseId).locations[locationId].exitBlip = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,10 +671,10 @@ function reloadAllHousesCommand(command, params, client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(let i in getServerData().houses) {
|
for(let i in getServerData().houses) {
|
||||||
deleteHouseExitBlip(i);
|
deleteHouseExitBlips(i);
|
||||||
deleteHouseEntranceBlip(i);
|
deleteHouseEntranceBlips(i);
|
||||||
deleteHouseExitPickup(i);
|
deleteHouseExitPickups(i);
|
||||||
deleteHouseEntrancePickup(i);
|
deleteHouseEntrancePickups(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
getServerData().houses = null;
|
getServerData().houses = null;
|
||||||
|
|||||||
@@ -1243,9 +1243,38 @@ function createJobLocation(job, position, interior, dimension) {
|
|||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
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) {
|
function saveJobLocationToDatabase(jobLocationData) {
|
||||||
if(jobLocationData == null) {
|
if(jobLocationData == null) {
|
||||||
// Invalid vehicle data
|
// Invalid job location data
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1253,20 +1282,130 @@ function saveJobLocationToDatabase(jobLocationData) {
|
|||||||
let dbConnection = connectToDatabase();
|
let dbConnection = connectToDatabase();
|
||||||
if(dbConnection) {
|
if(dbConnection) {
|
||||||
// If job location hasn't been added to database, ID will be 0
|
// If job location hasn't been added to database, ID will be 0
|
||||||
if(vehicleData.databaseId == 0) {
|
if(jobLocationData.databaseId == 0) {
|
||||||
let dbQueryString = `INSERT INTO job_loc (job_loc_job, job_loc_enabled, job_loc_pos_x, job_loc_pos_y, job_loc_pos_z, job_loc_int, job_loc_vw) VALUES (${jobLocationData.job}, ${boolToInt(jobLocationData.enabled)}, ${jobLocationData.position.x}, ${jobLocationData.position.y}, ${jobLocationData.position.z}, ${jobLocationData.interior}, ${jobLocationData.dimension})`;
|
let dbQueryString = `INSERT INTO job_loc (job_loc_job, job_loc_enabled, job_loc_pos_x, job_loc_pos_y, job_loc_pos_z, job_loc_int, job_loc_vw) VALUES (${jobLocationData.job}, ${boolToInt(jobLocationData.enabled)}, ${jobLocationData.position.x}, ${jobLocationData.position.y}, ${jobLocationData.position.z}, ${jobLocationData.interior}, ${jobLocationData.dimension})`;
|
||||||
queryDatabase(dbConnection, dbQueryString);
|
queryDatabase(dbConnection, dbQueryString);
|
||||||
jobLocationData.databaseId = getDatabaseInsertId(dbConnection);
|
jobLocationData.databaseId = getDatabaseInsertId(dbConnection);
|
||||||
} else {
|
} else {
|
||||||
let dbQueryString = `UPDATE job_loc SET job_loc_job=${jobLocationData.job}, job_loc_enabled=${boolToInt(jobLocationData.enabled)}, job_loc_pos_x=${jobLocationData.position.x}, job_loc_pos_y=${jobLocationData.jobLocationData.y}, job_loc_pos_z=${jobLocationData.jobLocationData.z}, job_loc_int=${jobLocationData.interior}, job_loc_vw=${jobLocationData.dimension} WHERE job_loc_id=${jobLocationData.databaseId}`;
|
let dbQueryString = `UPDATE job_loc SET job_loc_job=${jobLocationData.job}, job_loc_enabled=${boolToInt(jobLocationData.enabled)}, job_loc_pos_x=${jobLocationData.position.x}, job_loc_pos_y=${jobLocationData.position.y}, job_loc_pos_z=${jobLocationData.position.z}, job_loc_int=${jobLocationData.interior}, job_loc_vw=${jobLocationData.dimension} WHERE job_loc_id=${jobLocationData.databaseId}`;
|
||||||
queryDatabase(dbConnection, dbQueryString);
|
queryDatabase(dbConnection, dbQueryString);
|
||||||
}
|
}
|
||||||
disconnectFromDatabase(dbConnection);
|
disconnectFromDatabase(dbConnection);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
console.log(`[Asshat.Job]: Saved job location ${jobLocationData.vehicle.id} to database!`);
|
console.log(`[Asshat.Job]: Saved job location ${jobLocationData.databaseId} to database`);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function saveJobEquipmentToDatabase(jobEquipmentData) {
|
||||||
|
if(jobEquipmentData == null) {
|
||||||
|
// Invalid job equipment data
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[Asshat.Job]: Saving job equipment ${jobEquipmentData.databaseId} to database ...`);
|
||||||
|
let dbConnection = connectToDatabase();
|
||||||
|
if(dbConnection) {
|
||||||
|
let safeName = escapeDatabaseString(dbConnection, jobEquipmentData.name);
|
||||||
|
// If job equipment hasn't been added to database, ID will be 0
|
||||||
|
if(jobEquipmentData.databaseId == 0) {
|
||||||
|
let dbQueryString = `INSERT INTO job_equip (job_equip_job, job_equip_enabled, job_equip_minrank, job_equip_name) VALUES (${jobEquipmentData.job}, ${boolToInt(jobEquipmentData.enabled)}, ${jobEquipmentData.requiredRank}, '${safeName}')`;
|
||||||
|
queryDatabase(dbConnection, dbQueryString);
|
||||||
|
jobEquipmentData.databaseId = getDatabaseInsertId(dbConnection);
|
||||||
|
} else {
|
||||||
|
let dbQueryString = `UPDATE job_equip SET job_equip_job=${jobEquipmentData.job}, job_equip_enabled=${boolToInt(jobEquipmentData.enabled)}, job_equip_minrank=${jobEquipmentData.requiredRank}, job_equip_name='${safeName}' WHERE job_equip_id=${jobEquipmentData.databaseId}`;
|
||||||
|
queryDatabase(dbConnection, dbQueryString);
|
||||||
|
}
|
||||||
|
disconnectFromDatabase(dbConnection);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
console.log(`[Asshat.Job]: Saved job equipment ${jobEquipmentData.databaseId} to database`);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function saveJobEquipmentWeaponToDatabase(jobEquipmentWeaponData) {
|
||||||
|
if(jobEquipmentWeaponData == null) {
|
||||||
|
// Invalid job equipment weapon data
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[Asshat.Job]: Saving job equipment weapon ${jobEquipmentWeaponData.databaseId} to database ...`);
|
||||||
|
let dbConnection = connectToDatabase();
|
||||||
|
if(dbConnection) {
|
||||||
|
// If job equipment weapon hasn't been added to database, ID will be 0
|
||||||
|
if(jobEquipmentWeaponData.databaseId == 0) {
|
||||||
|
let dbQueryString = `INSERT INTO job_equip_wep (job_equip_wep_equip, job_equip_wep_enabled, job_equip_wep_wep, job_equip_wep_ammo) VALUES (${jobEquipmentWeaponData.equipmentId}, ${boolToInt(jobEquipmentWeaponData.enabled)}, ${jobEquipmentWeaponData.weaponId}, ${jobEquipmentWeaponData.ammo})`;
|
||||||
|
queryDatabase(dbConnection, dbQueryString);
|
||||||
|
jobEquipmentWeaponData.databaseId = getDatabaseInsertId(dbConnection);
|
||||||
|
} else {
|
||||||
|
let dbQueryString = `UPDATE job_equip_wep SET job_equip_wep_equip=${jobEquipmentWeaponData.equipmentId}, job_equip_wep_enabled=${boolToInt(jobEquipmentWeaponData.enabled)}, job_equip_wep_wep=${jobEquipmentWeaponData.weaponId}, job_equip_wep_ammo=${jobEquipmentWeaponData.ammo} WHERE job_equip_wep_id=${jobEquipmentWeaponData.databaseId}`;
|
||||||
|
queryDatabase(dbConnection, dbQueryString);
|
||||||
|
}
|
||||||
|
disconnectFromDatabase(dbConnection);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
console.log(`[Asshat.Job]: Saved job equipment weapon ${jobEquipmentWeaponData.databaseId} to database`);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function saveJobUniformToDatabase(jobUniformData) {
|
||||||
|
if(jobUniformData == null) {
|
||||||
|
// Invalid job uniform data
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[Asshat.Job]: Saving job uniform ${jobUniformData.databaseId} to database ...`);
|
||||||
|
let dbConnection = connectToDatabase();
|
||||||
|
if(dbConnection) {
|
||||||
|
let safeName = escapeDatabaseString(dbConnection, jobUniformData.name);
|
||||||
|
// If job uniform hasn't been added to database, ID will be 0
|
||||||
|
if(jobUniformData.databaseId == 0) {
|
||||||
|
let dbQueryString = `INSERT INTO job_uniform (job_uniform_job, job_uniform_enabled, job_uniform_minrank, job_uniform_name) VALUES (${jobUniformData.job}, ${boolToInt(jobUniformData.enabled)}, ${jobUniformData.requiredRank}, '${safeName}')`;
|
||||||
|
queryDatabase(dbConnection, dbQueryString);
|
||||||
|
jobUniformData.databaseId = getDatabaseInsertId(dbConnection);
|
||||||
|
} else {
|
||||||
|
let dbQueryString = `UPDATE job_uniform SET job_uniform_job=${jobUniformData.job}, job_uniform_enabled=${boolToInt(jobUniformData.enabled)}, job_uniform_minrank=${jobUniformData.requiredRank}, job_uniform_name='${safeName}', job_uniform_skin=${jobUniformData.skin} WHERE job_uniform_id=${jobUniformData.databaseId}`;
|
||||||
|
queryDatabase(dbConnection, dbQueryString);
|
||||||
|
}
|
||||||
|
disconnectFromDatabase(dbConnection);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
console.log(`[Asshat.Job]: Saved job uniform ${jobUniformData.databaseId} to database`);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function saveAllJobsToDatabase() {
|
||||||
|
for(let i in getServerData().jobs) {
|
||||||
|
saveJobToDatabase(getServerData().jobs[i]);
|
||||||
|
|
||||||
|
for(let j in getServerData().jobs[i].locations) {
|
||||||
|
saveJobLocationToDatabase(getServerData().jobs[i].locations[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(let k in getServerData().jobs[i].uniforms) {
|
||||||
|
saveJobUniformToDatabase(getServerData().jobs[i].uniforms[k]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(let m in getServerData().jobs[i].equipment) {
|
||||||
|
saveJobEquipmentToDatabase(getServerData().jobs[i].equipment[m]);
|
||||||
|
|
||||||
|
for(let n in getServerData().jobs[i].equipment[m].weapons) {
|
||||||
|
saveJobEquipmentWeaponToDatabase(getServerData().jobs[i].equipment[m].weapons[n]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -25,6 +25,7 @@ function saveAllServerDataToDatabase() {
|
|||||||
saveAllBusinessesToDatabase();
|
saveAllBusinessesToDatabase();
|
||||||
saveServerConfigToDatabase(getServerConfig());
|
saveServerConfigToDatabase(getServerConfig());
|
||||||
saveAllVehiclesToDatabase();
|
saveAllVehiclesToDatabase();
|
||||||
|
saveAllJobsToDatabase();
|
||||||
saveAllClientsToDatabase();
|
saveAllClientsToDatabase();
|
||||||
console.log("[Asshat.Utilities]: Saved all server data to database!");
|
console.log("[Asshat.Utilities]: Saved all server data to database!");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user