Use entity data utils
This commit is contained in:
@@ -200,7 +200,7 @@ function setBusinessNameCommand(command, params, client) {
|
||||
|
||||
let oldBusinessName = getBusinessData(businessId).name;
|
||||
getBusinessData(businessId).name = newBusinessName;
|
||||
getBusinessData(businessId).entrancePickup.setData("ag.label.name", getBusinessData(businessId).name, true);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "ag.label.name", getBusinessData(businessId).name, true);
|
||||
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]renamed business [#0099FF]${oldBusinessName} [#FFFFFF]to [#0099FF]${newBusinessName}`);
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ function lockBusinessCommand(command, params, client) {
|
||||
}
|
||||
|
||||
getBusinessData(businessId).locked = !getBusinessData(businessId).locked;
|
||||
getBusinessData(businessId).entrancePickup.setData("ag.label.locked", getBusinessData(businessId).locked, true);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "ag.label.locked", getBusinessData(businessId).locked, true);
|
||||
messagePlayerSuccess(client, `${getLockedUnlockedEmojiFromBool((getBusinessData(businessId).locked))} Business [#0099FF]${getBusinessData(businessId).name} [#FFFFFF]${getLockedUnlockedTextFromBool((getBusinessData(businessId).locked))}!`);
|
||||
}
|
||||
|
||||
@@ -785,14 +785,13 @@ function createBusinessEntrancePickup(businessId) {
|
||||
getBusinessData(businessId).entrancePickup = gta.createPickup(pickupModelId, getBusinessData(businessId).entrancePosition);
|
||||
getBusinessData(businessId).entrancePickup.onAllDimensions = false;
|
||||
getBusinessData(businessId).entrancePickup.dimension = getBusinessData(businessId).entranceDimension;
|
||||
//getBusinessData(businessId).entrancePickup.interior = getBusinessData(businessId).entranceInterior;
|
||||
getBusinessData(businessId).entrancePickup.setData("ag.owner.type", AG_PICKUP_BUSINESS_ENTRANCE, false);
|
||||
getBusinessData(businessId).entrancePickup.setData("ag.owner.id", businessId, false);
|
||||
getBusinessData(businessId).entrancePickup.setData("ag.label.type", AG_LABEL_BUSINESS, true);
|
||||
getBusinessData(businessId).entrancePickup.setData("ag.label.name", getBusinessData(businessId).name, true);
|
||||
getBusinessData(businessId).entrancePickup.setData("ag.label.locked", getBusinessData(businessId).locked, true);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "ag.owner.type", AG_PICKUP_BUSINESS_ENTRANCE, false);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "ag.owner.id", businessId, false);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "ag.label.type", AG_LABEL_BUSINESS, true);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "ag.label.name", getBusinessData(businessId).name, true);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "ag.label.locked", getBusinessData(businessId).locked, true);
|
||||
if(getBusinessData(businessId).buyPrice > 0) {
|
||||
getBusinessData(businessId).entrancePickup.setData("ag.label.price", getBusinessData(businessId).buyPrice, true);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "ag.label.price", getBusinessData(businessId).buyPrice, true);
|
||||
}
|
||||
addToWorld(getBusinessData(businessId).entrancePickup);
|
||||
}
|
||||
@@ -812,8 +811,8 @@ function createBusinessEntranceBlip(businessId) {
|
||||
getBusinessData(businessId).entranceBlip.onAllDimensions = false;
|
||||
getBusinessData(businessId).entranceBlip.dimension = getBusinessData(businessId).entranceDimension;
|
||||
//getBusinessData(businessId).entranceBlip.interior = getBusinessData(businessId).entranceInterior;
|
||||
getBusinessData(businessId).entranceBlip.setData("ag.owner.type", AG_BLIP_BUSINESS_ENTRANCE, false);
|
||||
getBusinessData(businessId).entranceBlip.setData("ag.owner.id", businessId, false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -833,9 +832,9 @@ function createBusinessExitPickup(businessId) {
|
||||
getBusinessData(businessId).exitPickup.onAllDimensions = false;
|
||||
getBusinessData(businessId).exitPickup.dimension = getBusinessData(businessId).exitDimension;
|
||||
//getBusinessData(businessId).exitPickup.interior = getBusinessData(businessId).exitInterior;
|
||||
getBusinessData(businessId).exitPickup.setData("ag.owner.type", AG_PICKUP_BUSINESS_EXIT, false);
|
||||
getBusinessData(businessId).exitPickup.setData("ag.owner.id", businessId, false);
|
||||
getBusinessData(businessId).exitPickup.setData("ag.label.type", AG_LABEL_EXIT, true);
|
||||
setEntityData(getBusinessData(businessId).exitPickup, "ag.owner.type", AG_PICKUP_BUSINESS_EXIT, false);
|
||||
setEntityData(getBusinessData(businessId).exitPickup, "ag.owner.id", businessId, false);
|
||||
setEntityData(getBusinessData(businessId).exitPickup, "ag.label.type", AG_LABEL_EXIT, true);
|
||||
addToWorld(getBusinessData(businessId).exitPickup);
|
||||
}
|
||||
}
|
||||
@@ -856,8 +855,8 @@ function createBusinessExitBlip(businessId) {
|
||||
getBusinessData(businessId).exitBlip.onAllDimensions = false;
|
||||
getBusinessData(businessId).exitBlip.dimension = getBusinessData(businessId).entranceDimension;
|
||||
//getBusinessData(businessId).exitBlip.interior = getBusinessData(businessId).exitInterior;
|
||||
getBusinessData(businessId).exitBlip.setData("ag.owner.type", AG_BLIP_BUSINESS_EXIT, false);
|
||||
getBusinessData(businessId).exitBlip.setData("ag.owner.id", businessId, false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ function lockUnlockHouseCommand(command, params, client) {
|
||||
}
|
||||
|
||||
getHouseData(houseId).locked = !getHouseData(houseId).locked;
|
||||
getHouseData(houseId).entrancePickup.setData("ag.label.locked", getHouseData(houseId).locked, true);
|
||||
setEntityData(getHouseData(houseId).entrancePickup, "ag.label.locked", getHouseData(houseId).locked, true);
|
||||
messagePlayerSuccess(client, `House '${getHouseData(houseId).description}' ${getLockedUnlockedTextFromBool((getHouseData(houseId).locked))}!`);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ function setHouseDescriptionCommand(command, params, client) {
|
||||
|
||||
let oldDescription = getHouseData(houseId).description;
|
||||
getHouseData(houseId).description = newHouseDescription;
|
||||
getHouseData(houseId).entrancePickup.setData("ag.label.name", getHouseData(houseId).description, true);
|
||||
setEntityData(getHouseData(houseId).entrancePickup, "ag.label.name", getHouseData(houseId).description, true);
|
||||
messageAdmins(`${client.name} renamed house [#11CC11]${oldDescription} [#FFFFFF]to [#11CC11]${getHouseData(houseId).description}`);
|
||||
}
|
||||
|
||||
@@ -468,14 +468,13 @@ function createHouseEntrancePickup(houseId) {
|
||||
getHouseData(houseId).entrancePickup = gta.createPickup(pickupModelId, getHouseData(houseId).entrancePosition);
|
||||
getHouseData(houseId).entrancePickup.onAllDimensions = false;
|
||||
getHouseData(houseId).entrancePickup.dimension = getHouseData(houseId).entranceDimension;
|
||||
//getHouseData(houseId).entrancePickup.interior = getHouseData(houseId).entranceInterior;
|
||||
getHouseData(houseId).entrancePickup.setData("ag.owner.type", AG_PICKUP_HOUSE_ENTRANCE, false);
|
||||
getHouseData(houseId).entrancePickup.setData("ag.owner.id", houseId, false);
|
||||
getHouseData(houseId).entrancePickup.setData("ag.label.type", AG_LABEL_HOUSE, true);
|
||||
getHouseData(houseId).entrancePickup.setData("ag.label.name", getHouseData(houseId).description, true);
|
||||
getHouseData(houseId).entrancePickup.setData("ag.label.locked", getHouseData(houseId).locked, true);
|
||||
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);
|
||||
if(getHouseData(houseId).buyPrice > 0) {
|
||||
getHouseData(houseId).entrancePickup.setData("ag.label.price", getHouseData(houseId).buyPrice, true);
|
||||
setEntityData(getHouseData(houseId).entrancePickup, "ag.label.price", getHouseData(houseId).buyPrice, true);
|
||||
}
|
||||
addToWorld(getHouseData(houseId).entrancePickup);
|
||||
}
|
||||
@@ -494,9 +493,8 @@ function createHouseEntranceBlip(houseId) {
|
||||
getHouseData(houseId).entranceBlip = gta.createBlip(getHouseData(houseId).entrancePosition, blipModelId, 1, getColourByName("houseGreen"));
|
||||
getHouseData(houseId).entranceBlip.onAllDimensions = false;
|
||||
getHouseData(houseId).entranceBlip.dimension = getHouseData(houseId).entranceDimension;
|
||||
//getHouseData(houseId).entranceBlip.interior = getHouseData(houseId).entranceInterior;
|
||||
getHouseData(houseId).entranceBlip.setData("ag.owner.type", AG_BLIP_HOUSE_ENTRANCE, false);
|
||||
getHouseData(houseId).entranceBlip.setData("ag.owner.id", houseId, false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -515,10 +513,9 @@ function createHouseExitPickup(houseId) {
|
||||
getHouseData(houseId).exitPickup = gta.createPickup(pickupModelId, getHouseData(houseId).exitPosition);
|
||||
getHouseData(houseId).exitPickup.onAllDimensions = false;
|
||||
getHouseData(houseId).exitPickup.dimension = getHouseData(houseId).exitDimension;
|
||||
//getHouseData(houseId).exitPickup.interior = getHouseData(houseId).exitInterior;
|
||||
getHouseData(houseId).exitPickup.setData("ag.owner.type", AG_PICKUP_HOUSE_EXIT, false);
|
||||
getHouseData(houseId).exitPickup.setData("ag.owner.id", houseId, false);
|
||||
getHouseData(houseId).exitPickup.setData("ag.label.type", AG_LABEL_EXIT, true);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -538,9 +535,8 @@ function createHouseExitBlip(houseId) {
|
||||
getHouseData(houseId).exitBlip = gta.createBlip(blipModelId, getHouseData(houseId).exitPosition, 1, getColourByName("houseGreen"));
|
||||
getHouseData(houseId).exitBlip.onAllDimensions = false;
|
||||
getHouseData(houseId).exitBlip.dimension = getHouseData(houseId).entranceDimension;
|
||||
//getHouseData(houseId).exitBlip.interior = getHouseData(houseId).exitInterior;
|
||||
getHouseData(houseId).exitBlip.setData("ag.owner.type", AG_BLIP_HOUSE_EXIT, false);
|
||||
getHouseData(houseId).exitBlip.setData("ag.owner.id", houseId, false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,12 +216,11 @@ function createAllJobPickups() {
|
||||
pickupCount++;
|
||||
getServerData().jobs[i].locations[j].pickup = gta.createPickup(getServerData().jobs[i].pickupModel, getServerData().jobs[i].locations[j].position);
|
||||
getServerData().jobs[i].locations[j].pickup.onAllDimensions = false;
|
||||
getServerData().jobs[i].locations[j].pickup.setData("ag.owner.type", AG_PICKUP_JOB, false);
|
||||
getServerData().jobs[i].locations[j].pickup.setData("ag.owner.id", i, false);
|
||||
getServerData().jobs[i].locations[j].pickup.setData("ag.label.type", AG_LABEL_JOB, true);
|
||||
getServerData().jobs[i].locations[j].pickup.setData("ag.label.name", getServerData().jobs[i].name, true);
|
||||
getServerData().jobs[i].locations[j].pickup.setData("ag.label.jobType", getServerData().jobs[i].databaseId, true);
|
||||
//getServerData().jobs[i].locations[j].pickup.interior = getServerData().jobs[i].locations[j].interior;
|
||||
setEntityData(getServerData().jobs[i].locations[j].pickup, "ag.owner.type", AG_PICKUP_JOB, false);
|
||||
setEntityData(getServerData().jobs[i].locations[j].pickup, "ag.owner.id", j, false);
|
||||
setEntityData(getServerData().jobs[i].locations[j].pickup, "ag.label.type", AG_LABEL_JOB, true);
|
||||
setEntityData(getServerData().jobs[i].locations[j].pickup, "ag.label.name", getServerData().jobs[i].name, true);
|
||||
setEntityData(getServerData().jobs[i].locations[j].pickup, "ag.label.jobType", getServerData().jobs[i].databaseId, true);
|
||||
getServerData().jobs[i].locations[j].pickup.dimension = getServerData().jobs[i].locations[j].dimension;
|
||||
addToWorld(getServerData().jobs[i].locations[j].pickup);
|
||||
|
||||
@@ -486,7 +485,7 @@ function givePlayerJobEquipment(client, equipmentId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let jobId = getPlayerCurrentSubAccount(client).job;
|
||||
let jobId = getPlayerJob(client);
|
||||
let equipments = getJobData(jobId).equipment;
|
||||
|
||||
for(let i in equipments[equipmentId].weapons) {
|
||||
@@ -573,7 +572,17 @@ function stopWorking(client) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function jobUniformCommand(command, params, client) {
|
||||
let jobId = getPlayerCurrentSubAccount(client).job;
|
||||
if(!getPlayerJob(client)) {
|
||||
messagePlayerError(client, "You don't have a job!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerWorking(client)) {
|
||||
messagePlayerError(client, "You are not working! Use /startwork at your job location.");
|
||||
return false;
|
||||
}
|
||||
|
||||
let jobId = getPlayerJob(client);
|
||||
let uniforms = getJobData(jobId).uniforms;
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
@@ -605,7 +614,17 @@ function jobUniformCommand(command, params, client) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function jobEquipmentCommand(command, params, client) {
|
||||
let jobId = getPlayerCurrentSubAccount(client).job;
|
||||
if(!getPlayerJob(client)) {
|
||||
messagePlayerError(client, "You don't have a job!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerWorking(client)) {
|
||||
messagePlayerError(client, "You are not working! Use /startwork at your job location.");
|
||||
return false;
|
||||
}
|
||||
|
||||
let jobId = getPlayerJob(client);
|
||||
let equipments = getJobData(jobId).equipment;
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
@@ -681,12 +700,6 @@ function doesPlayerHaveJobType(client, jobType) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function getJobData(jobId) {
|
||||
//for(let i in getServerData().jobs) {
|
||||
// if(getServerData().jobs[i].databaseId == jobId) {
|
||||
// return getServerData().jobs[i];
|
||||
// }
|
||||
//}
|
||||
|
||||
if(typeof getServerData().jobs[jobId] != "undefined") {
|
||||
return getServerData().jobs[jobId];
|
||||
}
|
||||
@@ -1264,11 +1277,12 @@ function createJobLocation(jobId, position, interior, dimension) {
|
||||
jobLocationData.interior = interior;
|
||||
jobLocationData.dimension = dimension;
|
||||
jobLocationData.enabled = true;
|
||||
jobLocationData.jobIndex = jobId;
|
||||
|
||||
getServerData().jobs[jobId].locations.push(jobLocationData);
|
||||
|
||||
createJobLocationPickup(jobId, getServerData().jobs[jobId].locations.length-1);
|
||||
|
||||
let newSlot = getServerData().jobs[jobId].locations.length-1;
|
||||
getServerData().jobs[jobId].locations[newSlot].index = newSlot;
|
||||
createJobLocationPickup(jobId, newSlot);
|
||||
saveJobLocationToDatabase(jobLocationData);
|
||||
}
|
||||
|
||||
@@ -1471,6 +1485,11 @@ function createJobLocationPickup(jobId, locationId) {
|
||||
getJobData(jobId).locations[locationId].pickup = gta.createPickup(pickupModelId, getJobData(jobId).locations[locationId].position, getGameConfig().pickupTypes[getServerGame()].job);
|
||||
getJobData(jobId).locations[locationId].pickup.dimension = getJobData(jobId).locations[locationId].dimension;
|
||||
addToWorld(getJobData(jobId).locations[locationId].pickup);
|
||||
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "ag.owner.type", AG_PICKUP_JOB, false);
|
||||
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, locationId, false);
|
||||
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, AG_LABEL_JOB, true);
|
||||
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, getServerData().jobs[jobId].name, true);
|
||||
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, getServerData().jobs[jobId].databaseId, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1491,4 +1510,17 @@ function createJobLocationBlip(jobId, locationId) {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function getPlayerJob(client) {
|
||||
let jobDatabaseId = getPlayerCurrentSubAccount(client).job;
|
||||
for(let i in getServerData().jobs) {
|
||||
if(jobDatabaseId == getServerData().jobs[i].databaseId) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user