From 57c60e1ff6fe175febdb1709a7f5be4861b17ed3 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sun, 15 May 2022 04:19:38 -0500 Subject: [PATCH] Add job list command --- scripts/server/command.js | 4 ++++ scripts/server/job.js | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/scripts/server/command.js b/scripts/server/command.js index f9b6da34..7bf3461e 100644 --- a/scripts/server/command.js +++ b/scripts/server/command.js @@ -298,6 +298,10 @@ function loadCommands() { new CommandData("uniform", jobUniformCommand, "[uniform]", getStaffFlagValue("None"), true, false, "Use a job uniform"), new CommandData("equip", jobEquipmentCommand, "[equipment]", getStaffFlagValue("None"), true, false, "Get equipment for your job"), + new CommandData("jobs", jobListCommand, "", getStaffFlagValue("None"), true, false, "Shows a list of all jobs"), + new CommandData("joblist", jobListCommand, "", getStaffFlagValue("None"), true, false, "Shows a list of all jobs"), + new CommandData("alljobs", jobListCommand, "", getStaffFlagValue("None"), true, false, "Shows a list of all jobs"), + // Emergency Services (Police, Fire, EMS, etc) new CommandData("department", jobDepartmentRadioCommand, "", getStaffFlagValue("None"), true, false, "Communicate with all emergency services (radio must be on and able to transmit)"), new CommandData("d", jobDepartmentRadioCommand, "", getStaffFlagValue("None"), true, false, "Communicate with all emergency services (radio must be on and able to transmit)"), diff --git a/scripts/server/job.js b/scripts/server/job.js index ea6bc39b..880aafda 100644 --- a/scripts/server/job.js +++ b/scripts/server/job.js @@ -394,6 +394,24 @@ function showJobInformationToPlayer(client, jobType) { // =========================================================================== +function jobListCommand(command, params, client) { + if(!canPlayerUseJobs(client)) { + messagePlayerError(client, "You are not allowed to use any jobs!"); + return false; + } + + let jobList = getServerData().jobs.map(function(x) { return `${x.name}`}); + let chunkedList = splitArrayIntoChunks(jobList, 4); + + messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderJobList"))); + for(let i in chunkedList) { + messagePlayerInfo(client, chunkedList[i].join(", ")); + } + return true; +} + +// =========================================================================== + function takeJobCommand(command, params, client) { if(!canPlayerUseJobs(client)) { messagePlayerError(client, "You are not allowed to use any jobs!");