From 4581de603b197193348db9bddd61cf5fcb1fa5f0 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:24:50 -0600 Subject: [PATCH] Add search cmd handler --- scripts/server/item.js | 48 ++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/scripts/server/item.js b/scripts/server/item.js index 2e73a2ec..968efd8c 100644 --- a/scripts/server/item.js +++ b/scripts/server/item.js @@ -2400,26 +2400,46 @@ function getBestItemToTake(client, slot) { * */ function listPlayerInventoryCommand(command, params, client) { - //let targetClient = client; - //if(!areParamsEmpty(client)) { - // if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) { - // if(targetClient == false) { - // sendMessageToPlayer(client, getLocaleString(client, "InvalidPlayer")); - // return false; - // } - // - // targetClient = getPlayerFromParams(params); - // } - //} - //showPlayerInventoryToPlayer(client, targetClient); - showPlayerInventoryToPlayer(client, client); - markPlayerActionTipSeen(client, "ViewInventory"); } // =========================================================================== +/** + * This is a command handler function. + * + * @param {string} command - The command name used by the player + * @param {string} params - The parameters/args string used with the command by the player + * @param {Client} client - The client/player that used the command + * @return {bool} Whether or not the command was successful + * + */ +function listOtherPlayerInventoryCommand(command, params, client) { + if (areParamsEmpty(params)) { + messagePlayerSyntax(client, getCommandSyntaxText(client, command)); + return false; + } + + let targetClient = getPlayerFromParams(params); + + if (!targetClient) { + messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); + return false; + } + + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageItems"))) { + if (!isPlayerSurrendered(targetClient)) { + messagePlayerError(client, getLocaleString(client, "MustBeSurrendered")); + return false; + } + } + + showPlayerInventoryToPlayer(client, targetClient); +} + +// =========================================================================== + /** * This is a command handler function. *