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_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_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_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 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 { class ItemData {
constructor(dbAssoc = false) { constructor(dbAssoc = false) {
this.databaseId = 0; this.databaseId = 0;
@@ -1749,11 +1756,11 @@ function deleteItem(itemId, whoDeleted = -1) {
} }
break; break;
case VRR_ITEM_OWNER_JOBLOCKER: case VRR_ITEM_OWNER_TEMPLOCKER:
ownerTypeString = "Job Locker"; ownerTypeString = "Job Locker";
owner = getPlayerFromCharacterId(getItemData(itemId).ownerId); owner = getPlayerFromCharacterId(getItemData(itemId).ownerId);
if (getPlayerData(owner) != false) { 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; break;
@@ -2220,9 +2227,9 @@ function saveItemTypeToDatabase(itemTypeId) {
// =========================================================================== // ===========================================================================
function storePlayerItemsInJobLocker(client) { function storePlayerItemsInTempLocker(client) {
for (let i = 0; i < 9; i++) { 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; 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) { for (let i in getPlayerData(client).jobEquipmentCache) {
if (getPlayerData(client).jobEquipmentCache[i] != -1) { if (getPlayerData(client).jobEquipmentCache[i] != -1) {
deleteItem(getPlayerData(client).jobEquipmentCache[i]); deleteItem(getPlayerData(client).jobEquipmentCache[i]);
@@ -2240,12 +2247,13 @@ function restorePlayerJobLockerItems(client) {
} }
for (let i = 0; i < 9; i++) { for (let i = 0; i < 9; i++) {
getPlayerData(client).hotBarItems[i] = getPlayerData(client).jobLockerCache[i]; getPlayerData(client).hotBarItems[i] = getPlayerData(client).tempLockerCache[i];
getPlayerData(client).jobLockerCache[i] = -1; getPlayerData(client).tempLockerCache[i] = -1;
} }
cachePlayerHotBarItems(client); cachePlayerHotBarItems(client);
updatePlayerHotBar(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 Representing a job's data. Loaded and saved in the database
*/ */
class JobData { class JobData {
constructor(dbAssoc = false) { constructor(dbAssoc = false) {
this.databaseId = 0; this.databaseId = 0;
this.serverId = 0; this.serverId = 0;
@@ -57,7 +57,7 @@ const VRR_JOBROUTESTATE_ATSTOP = 4; // For bus/trash stops that fre
this.blackList = []; this.blackList = [];
this.routes = []; this.routes = [];
if(dbAssoc) { if (dbAssoc) {
this.databaseId = dbAssoc["job_id"]; this.databaseId = dbAssoc["job_id"];
this.serverId = dbAssoc["job_server"]; this.serverId = dbAssoc["job_server"];
this.type = dbAssoc["job_type"]; this.type = dbAssoc["job_type"];
@@ -103,7 +103,7 @@ class JobRouteData {
this.locationNextMessage = ""; this.locationNextMessage = "";
this.locations = []; this.locations = [];
if(dbAssoc) { if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["job_route_id"]); this.databaseId = toInteger(dbAssoc["job_route_id"]);
this.name = toString(dbAssoc["job_route_name"]); this.name = toString(dbAssoc["job_route_name"]);
this.jobId = toInteger(dbAssoc["job_route_job"]); this.jobId = toInteger(dbAssoc["job_route_job"]);
@@ -112,7 +112,7 @@ class JobRouteData {
this.pay = toInteger(dbAssoc["job_route_pay"]); this.pay = toInteger(dbAssoc["job_route_pay"]);
this.startMessage = toString(dbAssoc["job_route_start_msg"]); this.startMessage = toString(dbAssoc["job_route_start_msg"]);
this.finishMessage = toString(dbAssoc["job_route_finish_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.locationNextMessage = toString(dbAssoc["job_route_loc_next_msg"]);
this.vehicleColour1 = toInteger(dbAssoc["job_route_veh_colour1"]); this.vehicleColour1 = toInteger(dbAssoc["job_route_veh_colour1"]);
this.vehicleColour2 = toInteger(dbAssoc["job_route_veh_colour2"]); this.vehicleColour2 = toInteger(dbAssoc["job_route_veh_colour2"]);
@@ -130,14 +130,14 @@ class JobRouteLocationData {
this.routeId = 0; this.routeId = 0;
this.enabled = false; this.enabled = false;
this.index = -1; this.index = -1;
this.jobIndex = -1; this.jobIndex = -1;
this.routeIndex = -1; this.routeIndex = -1;
this.needsSaved = false; this.needsSaved = false;
this.position = toVector3(0.0, 0.0, 0.0); this.position = toVector3(0.0, 0.0, 0.0);
this.stopDelay = 0; this.stopDelay = 0;
this.pay = 0; this.pay = 0;
if(dbAssoc) { if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["job_route_loc_id"]); this.databaseId = toInteger(dbAssoc["job_route_loc_id"]);
this.name = toString(dbAssoc["job_route_loc_name"]); this.name = toString(dbAssoc["job_route_loc_name"]);
this.routeId = toInteger(dbAssoc["job_route_loc_route"]); this.routeId = toInteger(dbAssoc["job_route_loc_route"]);
@@ -166,7 +166,7 @@ class JobEquipmentData {
this.needsSaved = false; this.needsSaved = false;
this.items = []; this.items = [];
if(dbAssoc) { if (dbAssoc) {
this.databaseId = dbAssoc["job_equip_id"]; this.databaseId = dbAssoc["job_equip_id"];
this.job = dbAssoc["job_equip_job"]; this.job = dbAssoc["job_equip_job"];
this.name = dbAssoc["job_equip_name"]; this.name = dbAssoc["job_equip_name"];
@@ -192,7 +192,7 @@ class JobEquipmentItemData {
this.jobIndex = -1; this.jobIndex = -1;
this.needsSaved = false; this.needsSaved = false;
if(dbAssoc) { if (dbAssoc) {
this.databaseId = dbAssoc["job_equip_item_id"]; this.databaseId = dbAssoc["job_equip_item_id"];
this.equipmentId = dbAssoc["job_equip_item_equip"]; this.equipmentId = dbAssoc["job_equip_item_equip"];
this.itemType = dbAssoc["job_equip_item_type"]; this.itemType = dbAssoc["job_equip_item_type"];
@@ -220,26 +220,26 @@ class JobUniformData {
this.needsSaved = false; this.needsSaved = false;
this.bodyParts = { this.bodyParts = {
hair: [0,0], hair: [0, 0],
head: [0,0], head: [0, 0],
upper: [0,0], upper: [0, 0],
lower: [0,0], lower: [0, 0],
}; };
this.bodyProps = { this.bodyProps = {
hair: [0,0], hair: [0, 0],
eyes: [0,0], eyes: [0, 0],
head: [0,0], head: [0, 0],
leftHand: [0,0], leftHand: [0, 0],
rightHand: [0,0], rightHand: [0, 0],
leftWrist: [0,0], leftWrist: [0, 0],
rightWrist: [0,0], rightWrist: [0, 0],
hip: [0,0], hip: [0, 0],
leftFoot: [0,0], leftFoot: [0, 0],
rightFoot: [0,0], rightFoot: [0, 0],
}; };
if(dbAssoc) { if (dbAssoc) {
this.databaseId = dbAssoc["job_uniform_id"]; this.databaseId = dbAssoc["job_uniform_id"];
this.job = dbAssoc["job_uniform_job"]; this.job = dbAssoc["job_uniform_job"];
this.name = dbAssoc["job_uniform_name"]; this.name = dbAssoc["job_uniform_name"];
@@ -290,7 +290,7 @@ class JobLocationData {
this.needsSaved = false; this.needsSaved = false;
this.routeCache = []; this.routeCache = [];
if(dbAssoc) { if (dbAssoc) {
this.databaseId = dbAssoc["job_loc_id"]; this.databaseId = dbAssoc["job_loc_id"];
this.jobId = dbAssoc["job_loc_job"]; this.jobId = dbAssoc["job_loc_job"];
this.position = toVector3(dbAssoc["job_loc_pos_x"], dbAssoc["job_loc_pos_y"], dbAssoc["job_loc_pos_z"]); 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.jobIndex = -1;
this.needsSaved = false; this.needsSaved = false;
if(dbAssoc) { if (dbAssoc) {
this.databaseId = dbAssoc["job_wl_id"]; this.databaseId = dbAssoc["job_wl_id"];
this.job = dbAssoc["job_wl_job"]; this.job = dbAssoc["job_wl_job"];
this.subAccount = dbAssoc["job_wl_sacct"] this.subAccount = dbAssoc["job_wl_sacct"]
@@ -336,7 +336,7 @@ class JobBlackListData {
this.jobIndex = -1; this.jobIndex = -1;
this.needsSaved = false; this.needsSaved = false;
if(dbAssoc) { if (dbAssoc) {
this.databaseId = dbAssoc["job_bl_id"]; this.databaseId = dbAssoc["job_bl_id"];
this.job = dbAssoc["job_bl_job"]; this.job = dbAssoc["job_bl_job"];
this.subAccount = dbAssoc["job_bl_sacct"] this.subAccount = dbAssoc["job_bl_sacct"]
@@ -861,7 +861,8 @@ function startWorking(client) {
switchPlayerActiveHotBarSlot(client, -1); switchPlayerActiveHotBarSlot(client, -1);
getPlayerCurrentSubAccount(client).skin = getPlayerSkin(client); 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"); messagePlayerInfo(client, "Your personal items have been stored in your locker while you work");
getPlayerCurrentSubAccount(client).isWorking = true; getPlayerCurrentSubAccount(client).isWorking = true;
@@ -1026,7 +1027,7 @@ function stopWorking(client) {
updatePlayerNameTag(client); updatePlayerNameTag(client);
sendPlayerWorkingState(client, false); sendPlayerWorkingState(client, false);
//cachePlayerHotBarItems(client); // Done in restorePlayerJobLockerItems //cachePlayerHotBarItems(client); // Done in restorePlayerTempLockerItems
} }
// =========================================================================== // ===========================================================================