From 84e69a87f7f22f0082a642b960a7cb8f9870e439 Mon Sep 17 00:00:00 2001 From: Resxt <55228336+Resxt@users.noreply.github.com> Date: Fri, 16 Jun 2023 20:03:08 +0200 Subject: [PATCH] chat_command_info 1.0.1 Fixed some wrong attachments being listed. For example pistol would list "silencer_shotgun" when the expected name is "silencer". Now all listed attachments only contain the content before the first underscore, which works. Added print of the attachments to the console if the debug mode is on --- chat_commands/chat_command_info.gsc | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/chat_commands/chat_command_info.gsc b/chat_commands/chat_command_info.gsc index 4342796..ce87398 100644 --- a/chat_commands/chat_command_info.gsc +++ b/chat_commands/chat_command_info.gsc @@ -80,6 +80,7 @@ ListWeapons(displayMode) ListAttachments(weaponName) { weaponIndex = 0; + finalWeaponName = ""; if (IsDefined(weaponName)) { @@ -92,13 +93,36 @@ ListAttachments(weaponName) { return WeaponDoesNotExistError(weaponName); } - + weaponIndex = getbaseweaponitemindex(weaponName); + finalWeaponName = weaponName; } else { + finalWeaponName = self getcurrentweapon(); weaponIndex = getbaseweaponitemindex(self getcurrentweapon()); } - self thread TellPlayer(StrTok(level.tbl_weaponids[weaponIndex]["attachment"], " "), 2); + attachments = StrTok(level.tbl_weaponids[weaponIndex]["attachment"], " "); + attachmentsFinal = []; + + // remove everything after _ in attachments name as this was always returning wrong names + // for example it would return silencer_shotgun when the actual codename is just silencer etc + foreach (attachment in attachments) + { + attachmentsFinal = AddElementToArray(attachmentsFinal, StrTok(attachment, "_")[0]); + } + + self thread TellPlayer(attachmentsFinal, 2); + + if (DebugIsOn()) + { + Print("-------------------------------"); + Print("Available attachments for " + getweapondisplayname(finalWeaponName) + " (" + StrTok(finalWeaponName, "_mp")[0] + "_mp" + ")"); + + foreach (attachment in attachmentsFinal) + { + Print(attachment); + } + } } \ No newline at end of file