Universal temp locker

This commit is contained in:
Vortrex
2022-06-17 09:39:27 -05:00
parent 731d0d6905
commit 53eaddbfce
2 changed files with 45 additions and 36 deletions

View File

@@ -18,7 +18,7 @@ const VRR_ITEM_OWNER_HOUSE = 6; // Item is in a house
const VRR_ITEM_OWNER_SAFE = 7; // Item is in a safe (safes can be anywhere)
const VRR_ITEM_OWNER_ITEM = 8; // Item is in another item (trashbag, briefcase, wallet, suitcase, crate/box, barrel, etc)
const VRR_ITEM_OWNER_GROUND = 9; // Item is on the ground
const VRR_ITEM_OWNER_JOBLOCKER = 10; // Item is in player's job locker
const VRR_ITEM_OWNER_TEMPLOCKER = 10; // Item is in player's temp locker (used for paintball, jobs, etc)
const VRR_ITEM_OWNER_LOCKER = 10; // Item is in player's locker
// ===========================================================================
@@ -103,6 +103,13 @@ const VRR_ITEM_ACTION_TAKE = 6; // Taking item (from trunk, das
// ===========================================================================
// Player Temporary Locker Types
const VRR_TEMP_LOCKER_TYPE_NONE = 0; // None
const VRR_TEMP_LOCKER_TYPE_JOB = 1; // Job locker
const VRR_TEMP_LOCKER_TYPE_PAINTBALL = 2; // Paintball locker
// ===========================================================================
class ItemData {
constructor(dbAssoc = false) {
this.databaseId = 0;
@@ -1749,11 +1756,11 @@ function deleteItem(itemId, whoDeleted = -1) {
}
break;
case VRR_ITEM_OWNER_JOBLOCKER:
case VRR_ITEM_OWNER_TEMPLOCKER:
ownerTypeString = "Job Locker";
owner = getPlayerFromCharacterId(getItemData(itemId).ownerId);
if (getPlayerData(owner) != false) {
getPlayerData(owner).jobLockerCache.splice(getPlayerData(owner).jobLockerCache.indexOf(itemId), 1);
getPlayerData(owner).tempLockerCache.splice(getPlayerData(owner).tempLockerCache.indexOf(itemId), 1);
}
break;
@@ -2220,9 +2227,9 @@ function saveItemTypeToDatabase(itemTypeId) {
// ===========================================================================
function storePlayerItemsInJobLocker(client) {
function storePlayerItemsInTempLocker(client) {
for (let i = 0; i < 9; i++) {
getPlayerData(client).jobLockerCache[i] = getPlayerData(client).hotBarItems[i];
getPlayerData(client).tempLockerCache[i] = getPlayerData(client).hotBarItems[i];
getPlayerData(client).hotBarItems[i] = -1;
}
@@ -2232,7 +2239,7 @@ function storePlayerItemsInJobLocker(client) {
// ===========================================================================
function restorePlayerJobLockerItems(client) {
function restorePlayerTempLockerItems(client) {
for (let i in getPlayerData(client).jobEquipmentCache) {
if (getPlayerData(client).jobEquipmentCache[i] != -1) {
deleteItem(getPlayerData(client).jobEquipmentCache[i]);
@@ -2240,12 +2247,13 @@ function restorePlayerJobLockerItems(client) {
}
for (let i = 0; i < 9; i++) {
getPlayerData(client).hotBarItems[i] = getPlayerData(client).jobLockerCache[i];
getPlayerData(client).jobLockerCache[i] = -1;
getPlayerData(client).hotBarItems[i] = getPlayerData(client).tempLockerCache[i];
getPlayerData(client).tempLockerCache[i] = -1;
}
cachePlayerHotBarItems(client);
updatePlayerHotBar(client);
getPlayerData(client).tempLockerType = VRR_TEMP_LOCKER_TYPE_NONE;
}
// ===========================================================================

View File

@@ -34,7 +34,7 @@ const VRR_JOBROUTESTATE_ATSTOP = 4; // For bus/trash stops that fre
/**
* @class Representing a job's data. Loaded and saved in the database
*/
class JobData {
class JobData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.serverId = 0;
@@ -57,7 +57,7 @@ const VRR_JOBROUTESTATE_ATSTOP = 4; // For bus/trash stops that fre
this.blackList = [];
this.routes = [];
if(dbAssoc) {
if (dbAssoc) {
this.databaseId = dbAssoc["job_id"];
this.serverId = dbAssoc["job_server"];
this.type = dbAssoc["job_type"];
@@ -103,7 +103,7 @@ class JobRouteData {
this.locationNextMessage = "";
this.locations = [];
if(dbAssoc) {
if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["job_route_id"]);
this.name = toString(dbAssoc["job_route_name"]);
this.jobId = toInteger(dbAssoc["job_route_job"]);
@@ -112,7 +112,7 @@ class JobRouteData {
this.pay = toInteger(dbAssoc["job_route_pay"]);
this.startMessage = toString(dbAssoc["job_route_start_msg"]);
this.finishMessage = toString(dbAssoc["job_route_finish_msg"]);
this.locationArriveMessage = toString(dbAssoc["job_route_loc_arrive_msg"]);
this.locationArriveMessage = toString(dbAssoc["job_route_loc_arrive_msg"]);
this.locationNextMessage = toString(dbAssoc["job_route_loc_next_msg"]);
this.vehicleColour1 = toInteger(dbAssoc["job_route_veh_colour1"]);
this.vehicleColour2 = toInteger(dbAssoc["job_route_veh_colour2"]);
@@ -130,14 +130,14 @@ class JobRouteLocationData {
this.routeId = 0;
this.enabled = false;
this.index = -1;
this.jobIndex = -1;
this.jobIndex = -1;
this.routeIndex = -1;
this.needsSaved = false;
this.position = toVector3(0.0, 0.0, 0.0);
this.stopDelay = 0;
this.pay = 0;
if(dbAssoc) {
if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["job_route_loc_id"]);
this.name = toString(dbAssoc["job_route_loc_name"]);
this.routeId = toInteger(dbAssoc["job_route_loc_route"]);
@@ -166,7 +166,7 @@ class JobEquipmentData {
this.needsSaved = false;
this.items = [];
if(dbAssoc) {
if (dbAssoc) {
this.databaseId = dbAssoc["job_equip_id"];
this.job = dbAssoc["job_equip_job"];
this.name = dbAssoc["job_equip_name"];
@@ -192,7 +192,7 @@ class JobEquipmentItemData {
this.jobIndex = -1;
this.needsSaved = false;
if(dbAssoc) {
if (dbAssoc) {
this.databaseId = dbAssoc["job_equip_item_id"];
this.equipmentId = dbAssoc["job_equip_item_equip"];
this.itemType = dbAssoc["job_equip_item_type"];
@@ -220,26 +220,26 @@ class JobUniformData {
this.needsSaved = false;
this.bodyParts = {
hair: [0,0],
head: [0,0],
upper: [0,0],
lower: [0,0],
hair: [0, 0],
head: [0, 0],
upper: [0, 0],
lower: [0, 0],
};
this.bodyProps = {
hair: [0,0],
eyes: [0,0],
head: [0,0],
leftHand: [0,0],
rightHand: [0,0],
leftWrist: [0,0],
rightWrist: [0,0],
hip: [0,0],
leftFoot: [0,0],
rightFoot: [0,0],
hair: [0, 0],
eyes: [0, 0],
head: [0, 0],
leftHand: [0, 0],
rightHand: [0, 0],
leftWrist: [0, 0],
rightWrist: [0, 0],
hip: [0, 0],
leftFoot: [0, 0],
rightFoot: [0, 0],
};
if(dbAssoc) {
if (dbAssoc) {
this.databaseId = dbAssoc["job_uniform_id"];
this.job = dbAssoc["job_uniform_job"];
this.name = dbAssoc["job_uniform_name"];
@@ -290,7 +290,7 @@ class JobLocationData {
this.needsSaved = false;
this.routeCache = [];
if(dbAssoc) {
if (dbAssoc) {
this.databaseId = dbAssoc["job_loc_id"];
this.jobId = dbAssoc["job_loc_job"];
this.position = toVector3(dbAssoc["job_loc_pos_x"], dbAssoc["job_loc_pos_y"], dbAssoc["job_loc_pos_z"]);
@@ -315,7 +315,7 @@ class JobWhiteListData {
this.jobIndex = -1;
this.needsSaved = false;
if(dbAssoc) {
if (dbAssoc) {
this.databaseId = dbAssoc["job_wl_id"];
this.job = dbAssoc["job_wl_job"];
this.subAccount = dbAssoc["job_wl_sacct"]
@@ -336,7 +336,7 @@ class JobBlackListData {
this.jobIndex = -1;
this.needsSaved = false;
if(dbAssoc) {
if (dbAssoc) {
this.databaseId = dbAssoc["job_bl_id"];
this.job = dbAssoc["job_bl_job"];
this.subAccount = dbAssoc["job_bl_sacct"]
@@ -861,7 +861,8 @@ function startWorking(client) {
switchPlayerActiveHotBarSlot(client, -1);
getPlayerCurrentSubAccount(client).skin = getPlayerSkin(client);
storePlayerItemsInJobLocker(client);
storePlayerItemsInTempLocker(client);
getPlayerData(client).tempLockerType = VRR_TEMP_LOCKER_TYPE_JOB;
messagePlayerInfo(client, "Your personal items have been stored in your locker while you work");
getPlayerCurrentSubAccount(client).isWorking = true;
@@ -1026,7 +1027,7 @@ function stopWorking(client) {
updatePlayerNameTag(client);
sendPlayerWorkingState(client, false);
//cachePlayerHotBarItems(client); // Done in restorePlayerJobLockerItems
//cachePlayerHotBarItems(client); // Done in restorePlayerTempLockerItems
}
// ===========================================================================