Add server job sphere, fix some route/loc cmds

This commit is contained in:
Vortrex
2022-07-30 08:17:07 -05:00
parent ab4339c46b
commit 0b54145764

View File

@@ -127,11 +127,13 @@ class JobRouteData {
this.detail = 0; this.detail = 0;
this.startMessage = ""; this.startMessage = "";
this.finishMessage = ""; this.finishMessage = "";
//this.failedMessage = "";
this.locationArriveMessage = ""; this.locationArriveMessage = "";
this.locationGotoMessage = ""; this.locationGotoMessage = "";
this.locations = []; this.locations = [];
this.whoCreated = 0; this.whoCreated = 0;
this.whenCreated = 0; this.whenCreated = 0;
this.sphere = null;
if (dbAssoc) { if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["job_route_id"]); this.databaseId = toInteger(dbAssoc["job_route_id"]);
@@ -142,6 +144,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.finishMessage = toString(dbAssoc["job_route_failed_msg"]);
this.locationArriveMessage = toString(dbAssoc["job_route_loc_arrive_msg"]); this.locationArriveMessage = toString(dbAssoc["job_route_loc_arrive_msg"]);
this.locationGotoMessage = toString(dbAssoc["job_route_loc_goto_msg"]); this.locationGotoMessage = toString(dbAssoc["job_route_loc_goto_msg"]);
this.vehicleColour1 = toInteger(dbAssoc["job_route_veh_colour1"]); this.vehicleColour1 = toInteger(dbAssoc["job_route_veh_colour1"]);
@@ -149,6 +152,7 @@ class JobRouteData {
this.detail = toInteger(dbAssoc["job_route_detail"]); this.detail = toInteger(dbAssoc["job_route_detail"]);
this.whoCreated = dbAssoc["job_route_who_added"]; this.whoCreated = dbAssoc["job_route_who_added"];
this.whenCreated = dbAssoc["job_route_when_added"]; this.whenCreated = dbAssoc["job_route_when_added"];
this.sphere = null;
} }
} }
}; };
@@ -884,7 +888,7 @@ function jobListCommand(command, params, client) {
return false; return false;
} }
let jobList = getServerData().jobs.map(function (x) { return `${x.name}` }); let jobList = getServerData().jobs.map(function (x) { return `[${hexFromToColour(x.colour)}]${x.name}{MAINCOLOUR}` });
let chunkedList = splitArrayIntoChunks(jobList, 4); let chunkedList = splitArrayIntoChunks(jobList, 4);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderJobList"))); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderJobList")));
@@ -1637,7 +1641,7 @@ function setJobBlipCommand(command, params, client) {
return false; return false;
} }
if (!areThereEnoughParams(params, 4, " ")) { if (!areThereEnoughParams(params, 2, " ")) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -1652,17 +1656,19 @@ function setJobBlipCommand(command, params, client) {
if (toLowerCase(blipParam) == "none") { if (toLowerCase(blipParam) == "none") {
blipId = -1; blipId = -1;
} else { } else {
let blipTypes = Object.keys(getGameConfig().blipSprites[getGame()]).join(", "); if (isNull(getGameConfig().blipSprites[getGame()][typeParam])) {
let blipTypes = Object.keys(getGameConfig().blipSprites[getGame()]);
let chunkedList = splitArrayIntoChunks(blipTypes, 10); let chunkedList = splitArrayIntoChunks(blipTypes, 10);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBlipTypes"))); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBlipTypes")));
for (let i in chunkedList) { for (let i in chunkedList) {
messagePlayerInfo(client, chunkedList[i].join(", ")); messagePlayerInfo(client, chunkedList[i].join(", "));
} }
} else {
blipId = getGameConfig().blipSprites[getGame()][blipParam]; blipId = getGameConfig().blipSprites[getGame()][blipParam];
blipString = toString(blipParam); blipString = toString(blipParam);
} }
}
} else { } else {
blipId = toInteger(blipParam); blipId = toInteger(blipParam);
blipString = toString(blipId); blipString = toString(blipId);
@@ -1682,7 +1688,7 @@ function setJobPickupCommand(command, params, client) {
return false; return false;
} }
if (!areThereEnoughParams(params, 4, " ")) { if (!areThereEnoughParams(params, 2, " ")) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -1691,23 +1697,27 @@ function setJobPickupCommand(command, params, client) {
let pickupParam = getParam(params, " ", 2); let pickupParam = getParam(params, " ", 2);
let pickupId = getJobData(jobId).pickupModel; let pickupId = getJobData(jobId).pickupModel;
let pickupString = "unchanged"; let pickupString = "none";
if (isNaN(pickupParam)) { if (isNaN(pickupParam)) {
if (toLowerCase(pickupParam) == "none") { if (toLowerCase(pickupParam) == "none") {
pickupId = -1; pickupId = -1;
} else { } else {
let pickupTypes = Object.keys(getGameConfig().pickupModels[getGame()]).join(", "); if (isNull(getGameConfig().pickupModels[getGame()][pickupParam])) {
messagePlayerError(client, "Invalid pickup type! Use a pickup type name or a model ID");
let pickupTypes = Object.keys(getGameConfig().pickupModels[getGame()]);
let chunkedList = splitArrayIntoChunks(pickupTypes, 10); let chunkedList = splitArrayIntoChunks(pickupTypes, 10);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPickupTypes"))); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPickupTypes")));
for (let i in chunkedList) { for (let i in chunkedList) {
messagePlayerInfo(client, chunkedList[i].join(", ")); messagePlayerInfo(client, chunkedList[i].join(", "));
} }
return false;
} else {
pickupId = getGameConfig().pickupModels[getGame()][pickupParam]; pickupId = getGameConfig().pickupModels[getGame()][pickupParam];
pickupString = toString(pickupParam); pickupString = toString(pickupParam);
} }
}
} else { } else {
pickupId = toInteger(pickupParam); pickupId = toInteger(pickupParam);
pickupString = toString(pickupId); pickupString = toString(pickupId);
@@ -1795,7 +1805,7 @@ function setJobRouteAllLocationDelaysCommand(command, params, client) {
} }
for (let i in getJobData(jobId).routes[jobRoute].locations) { for (let i in getJobData(jobId).routes[jobRoute].locations) {
getJobData(jobId).routes[jobRoute].locations[i].stopDelay = delay; getJobData(jobId).routes[jobRoute].locations[i].stopDelay = toInteger(delay);
getJobData(jobId).routes[jobRoute].locations[i].needsSaved = true; getJobData(jobId).routes[jobRoute].locations[i].needsSaved = true;
} }
@@ -1854,14 +1864,9 @@ function setJobRouteNextLocationArriveMessageCommand(command, params, client) {
let jobId = getPlayerJob(client); let jobId = getPlayerJob(client);
let jobRoute = getPlayerJobRoute(client); let jobRoute = getPlayerJobRoute(client);
let delay = getParam(params, " ", 1); let message = params;
if (isNaN(delay)) { getPlayerData(client).jobRouteEditNextLocationArriveMessage = message;
messagePlayerError(client, getLocaleString(client, "TimeNotNumber"))
return false;
}
getPlayerData(client).jobRouteEditNextLocationArriveMessage = delay;
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set the arrival message for the next message on route {ALTCOLOUR}${getJobData(jobId).routes[jobRoute].name}{MAINCOLOUR} for the {jobYellow}${getJobData(jobId).name}{MAINCOLOUR} job to {ALTCOLOUR}${message}{MAINCOLOUR}`); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set the arrival message for the next message on route {ALTCOLOUR}${getJobData(jobId).routes[jobRoute].name}{MAINCOLOUR} for the {jobYellow}${getJobData(jobId).name}{MAINCOLOUR} job to {ALTCOLOUR}${message}{MAINCOLOUR}`);
} }
@@ -1888,11 +1893,6 @@ function setJobRouteNextLocationGotoMessageCommand(command, params, client) {
let jobRoute = getPlayerJobRoute(client); let jobRoute = getPlayerJobRoute(client);
let message = params; let message = params;
if (isNaN(delay)) {
messagePlayerError(client, getLocaleString(client, "TimeNotNumber"))
return false;
}
getPlayerData(client).jobRouteEditNextLocationGotoMessage = message; getPlayerData(client).jobRouteEditNextLocationGotoMessage = message;
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set the goto message for the next location on route {ALTCOLOUR}${getJobData(jobId).routes[jobRoute].name}{MAINCOLOUR} for the {jobYellow}${getJobData(jobId).name}{MAINCOLOUR} job to {ALTCOLOUR}"${message}"{MAINCOLOUR}`); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set the goto message for the next location on route {ALTCOLOUR}${getJobData(jobId).routes[jobRoute].name}{MAINCOLOUR} for the {jobYellow}${getJobData(jobId).name}{MAINCOLOUR} job to {ALTCOLOUR}"${message}"{MAINCOLOUR}`);
@@ -2135,7 +2135,7 @@ function setJobRoutePayCommand(command, params, client) {
return false; return false;
} }
getJobData(jobId).routes[jobRoute].pay = amount; getJobData(jobId).routes[jobRoute].pay = toInteger(amount);
getJobData(jobId).routes[jobRoute].needsSaved = true; getJobData(jobId).routes[jobRoute].needsSaved = true;
messageAdmins(`{adminOrange}${getPlayerName(client)} {MAINCOLOUR} set the pay for route {ALTCOLOUR}${getJobRouteData(jobId, jobRoute).name} {MAINCOLOUR} of the {jobYellow}${getJobData(jobId).name} {MAINCOLOUR} job to {ALTCOLOUR}${makeLargeNumberReadable(amount)} {MAINCOLOUR} `); messageAdmins(`{adminOrange}${getPlayerName(client)} {MAINCOLOUR} set the pay for route {ALTCOLOUR}${getJobRouteData(jobId, jobRoute).name} {MAINCOLOUR} of the {jobYellow}${getJobData(jobId).name} {MAINCOLOUR} job to {ALTCOLOUR}${makeLargeNumberReadable(amount)} {MAINCOLOUR} `);
} }
@@ -2422,6 +2422,8 @@ function startJobRoute(client, forceRoute = -1) {
messagePlayerNormal(client, replaceJobRouteStringsInMessage(getJobRouteData(jobId, jobRoute).startMessage, jobId, jobRoute)); messagePlayerNormal(client, replaceJobRouteStringsInMessage(getJobRouteData(jobId, jobRoute).startMessage, jobId, jobRoute));
showSmallGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationGotoMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500);
// Don't announce routes that an admin just created // Don't announce routes that an admin just created
if (forceRoute == -1) { if (forceRoute == -1) {
messageDiscordEventChannel(`💼 ${getCharacterFullName(client)} started the ${getJobRouteData(jobId, jobRoute).name} route for the ${getJobData(jobId).name} job`); messageDiscordEventChannel(`💼 ${getCharacterFullName(client)} started the ${getJobRouteData(jobId, jobRoute).name} route for the ${getJobData(jobId).name} job`);
@@ -2440,15 +2442,19 @@ function stopJobRoute(client, successful = false, alertPlayer = true) {
let jobId = getPlayerJob(client); let jobId = getPlayerJob(client);
let routeId = getPlayerJobRoute(client); let routeId = getPlayerJobRoute(client);
if (successful == true) {
if (alertPlayer) { if (alertPlayer) {
messagePlayerAlert(client, replaceJobRouteStringsInMessage(getJobRouteData(jobId, routeId).finishMessage, jobId, routeId)); messagePlayerAlert(client, replaceJobRouteStringsInMessage(getJobRouteData(jobId, routeId).finishMessage, jobId, routeId));
} }
if (successful == true) {
finishSuccessfulJobRoute(client); finishSuccessfulJobRoute(client);
return false; return false;
} }
//if (alertPlayer) {
// messagePlayerAlert(client, replaceJobRouteStringsInMessage(getJobRouteData(jobId, routeId).failedMessage, jobId, routeId));
//}
messageDiscordEventChannel(`💼 ${getCharacterFullName(client)} failed to finish the ${getJobRouteData(jobId, getPlayerJobRoute(client)).name} route for the ${getJobData(jobId).name} job and didn't earn anything.`); messageDiscordEventChannel(`💼 ${getCharacterFullName(client)} failed to finish the ${getJobRouteData(jobId, getPlayerJobRoute(client)).name} route for the ${getJobData(jobId).name} job and didn't earn anything.`);
stopReturnToJobVehicleCountdown(client); stopReturnToJobVehicleCountdown(client);
@@ -2494,7 +2500,7 @@ function startReturnToJobVehicleCountdown(client) {
clearInterval(getPlayerData(client).returnToJobVehicleTimer); clearInterval(getPlayerData(client).returnToJobVehicleTimer);
getPlayerData(client).returnToJobVehicleTimer = null; getPlayerData(client).returnToJobVehicleTimer = null;
getPlayerData(client).returnToJobVehicleTick = 0; getPlayerData(client).returnToJobVehicleTick = 0;
stopJobRoute(client, false); stopJobRoute(client, false, true);
} }
}, 1000); }, 1000);
} }
@@ -2722,7 +2728,7 @@ function saveJobRankToDatabase(jobRankData) {
["job_rank_name", safeName], ["job_rank_name", safeName],
["job_rank_flags", jobRankData.flags], ["job_rank_flags", jobRankData.flags],
["job_rank_pay", jobRankData.pay], ["job_rank_pay", jobRankData.pay],
["job_rank_level", jobRankData.pay], ["job_rank_level", jobRankData.level],
["job_rank_who_added", jobRankData.whoCreated], ["job_rank_who_added", jobRankData.whoCreated],
["job_rank_when_added", jobRankData.whenCreated], ["job_rank_when_added", jobRankData.whenCreated],
]; ];
@@ -3289,29 +3295,36 @@ function isPlayerOnJobBlackList(client, jobId) {
function playerArrivedAtJobRouteLocation(client) { function playerArrivedAtJobRouteLocation(client) {
let jobId = getPlayerJob(client); let jobId = getPlayerJob(client);
let jobRouteId = getPlayerJobRoute(client);
let jobRouteLocationId = getPlayerJobRouteLocation(client);
let jobData = getJobData(jobId);
let jobRouteData = getJobRouteData(jobId, jobRouteId);
if (!isPlayerOnJobRoute(client)) { if (!isPlayerOnJobRoute(client)) {
return false; return false;
} }
if (isLastLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client))) { if (isLastLocationOnJobRoute(jobId, jobRouteId, jobRouteLocationId)) {
finishSuccessfulJobRoute(client); finishSuccessfulJobRoute(client);
return false; return false;
} }
showSmallGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationArriveMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500); hideElementForPlayer(getJobRouteLocationData(jobId, jobRouteId, jobRouteLocationId).marker, client);
if (getJobRouteLocationData(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).stopDelay > 0) {
showSmallGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(jobRouteData.locationArriveMessage), jobId, jobRouteId), jobData.colour, 3500);
if (getJobRouteLocationData(jobId, jobRouteId, jobRouteLocationId).stopDelay > 0) {
freezePlayerJobVehicleForRouteLocation(client); freezePlayerJobVehicleForRouteLocation(client);
getPlayerData(client).jobRouteLocation = getNextLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client)); getPlayerData(client).jobRouteLocation = getNextLocationOnJobRoute(jobId, jobRouteId, jobRouteLocationId);
setTimeout(function () { setTimeout(function () {
showCurrentJobLocation(client); showCurrentJobLocation(client);
showSmallGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationNextMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500); showSmallGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(jobRouteData.locationNextMessage), jobId, jobRouteId), jobData.colour, 3500);
unFreezePlayerJobVehicleForRouteLocation(client); unFreezePlayerJobVehicleForRouteLocation(client);
}, getJobRouteLocationData(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).stopDelay); }, getJobRouteLocationData(jobId, jobRouteId, jobRouteLocationId).stopDelay);
} else { } else {
getPlayerData(client).jobRouteLocation = getNextLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client)); getPlayerData(client).jobRouteLocation = getNextLocationOnJobRoute(jobId, jobRouteId, jobRouteLocationId);
showCurrentJobLocation(client); showCurrentJobLocation(client);
showSmallGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationNextMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500); showSmallGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(jobRouteData.locationNextMessage), jobId, jobRouteId), jobData.colour, 3500);
} }
} }
@@ -3836,8 +3849,8 @@ function getPlayerJobRouteLocation(client) {
// =========================================================================== // ===========================================================================
function showCurrentJobLocation(client) { function showCurrentJobLocation(client) {
let jobId = getPlayerJob(client); sendJobRouteLocationToPlayer(client, getJobRouteLocationData(getPlayerJob(client), getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).position, getJobData(getPlayerJob(client)).colour);
sendJobRouteLocationToPlayer(client, getJobRouteLocationData(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).position, getJobData(jobId).colour); showElementForPlayer(getJobRouteLocationData(getPlayerJob(client), getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).marker, client);
} }
// =========================================================================== // ===========================================================================
@@ -3961,3 +3974,44 @@ function getLowestJobRank(jobIndex) {
} }
// =========================================================================== // ===========================================================================
function createJobRouteLocationMarker(jobIndex, jobRouteIndex, jobRouteLocationIndex) {
let marker = null;
if (isGameFeatureSupported("spheres")) {
marker = createGameSphere(getJobRouteLocationData(jobIndex, jobRouteIndex, jobRouteLocationIndex).position, getGlobalConfig().jobRouteLocationSphereRadius, getJobData(jobIndex).colour);
setElementOnAllDimensions(marker, false);
setElementShownByDefault(marker, false);
setElementDimension(marker, getGameConfig().mainWorldDimension[getGame()]);
if (isGameFeatureSupported("interior")) {
setElementInterior(marker, getGameConfig().mainWorldDimension[getGame()]);
}
} else {
marker = getJobRouteLocationData(jobIndex, jobRouteIndex, jobRouteLocationIndex).marker = createGamePickup(getGameConfig().pickupModels[getGame()].Misc, getJobRouteLocationData(jobIndex, jobRouteIndex, jobRouteLocationIndex).position, getGameConfig().pickupTypes[getGame()].job);
setElementOnAllDimensions(marker, false);
setElementShownByDefault(marker, false);
setElementDimension(marker, getGameConfig().mainWorldDimension[getGame()]);
if (isGameFeatureSupported("interior")) {
setElementInterior(marker, getGameConfig().mainWorldDimension[getGame()]);
}
}
if (marker != null) {
getJobRouteLocationData(jobIndex, jobRouteIndex, jobRouteLocationIndex).marker = marker;
}
}
// ===========================================================================
function createAllJobRouteLocationMarkers() {
for (let i in getServerData().jobs) {
for (let j in getServerData().jobs[i].routes) {
for (let k in getServerData().jobs[i].routes[j].locations) {
createJobRouteLocationMarker(i, j, k);
}
}
}
}
// ===========================================================================