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
This commit is contained in:
Resxt 2023-06-16 20:03:08 +02:00
parent 384b32f33a
commit 84e69a87f7

View File

@ -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);
}
}
}