diff --git a/chat_commands/README.md b/chat_commands/README.md index f291e21..527330c 100644 --- a/chat_commands/README.md +++ b/chat_commands/README.md @@ -123,6 +123,28 @@ Toggles whether the targeted player is in god mode (invincible) or not. |---| | 3 | +## chat_command_info.gsc + +2 related commands in one file: + +- List available weapons +- List available attachments (MP only) + +| Name | Description | Arguments expected | Example | Permission level | +|---|---|---|---|---| +| listweapons | Prints all the available weapons. No argument prints code names, any argument will print display/human readable names instead | (1) optional, any text | `!listweapons` | 2 | +| listattachments | Prints all the available attachments for that weapon. No argument prints available attachments for the weapon you're holding, a valid weapon codename as argument will print this weapon's available attachments instead | (1) optional, valid weapon codename | `!listattachments dsr50_mp` | 2 | + +You can check [this](https://forum.plutonium.pw/topic/1909/resource-stat-modification-checks-other-structures) to get weapon/attachment names from your browser instead. + +| More examples | +|---| +| `!listweapons` | +| `!listweapons display` | +| `!listattachments` | +| `!listattachments tar21_mp` | +| `!listattachments dsr50` | + ## chat_command_invisible.gsc Toggles invisibility on the targeted player. diff --git a/chat_commands/chat_command_info.gsc b/chat_commands/chat_command_info.gsc new file mode 100644 index 0000000..4342796 --- /dev/null +++ b/chat_commands/chat_command_info.gsc @@ -0,0 +1,104 @@ +#include scripts\chat_commands; + +Init() +{ + if (IsMultiplayerMode()) + { + CreateCommand(level.chat_commands["ports"], "listattachments", "function", ::ListAttachmentsCommand, 2); + } + + CreateCommand(level.chat_commands["ports"], "listweapons", "function", ::ListWeaponsCommand, 2); +} + + + +/* Command section */ + +ListWeaponsCommand(args) +{ + self thread ListWeapons(args[0]); +} + +ListAttachmentsCommand(args) +{ + error = self thread ListAttachments(args[0]); + + if (IsDefined(error)) + { + return error; + } +} + + + +/* Logic section */ + +ListWeapons(displayMode) +{ + waitTime = 1.5; + + if (IsMultiplayerMode()) + { + if (IsDefined(displayMode)) + { + foreach (index in GetArrayKeys(level.tbl_weaponids)) + { + self thread TellPlayer(array(getweapondisplayname(level.tbl_weaponids[index]["reference"] + "_mp")), waitTime); + wait waitTime; + } + } + else + { + foreach (index in GetArrayKeys(level.tbl_weaponids)) + { + self thread TellPlayer(array(level.tbl_weaponids[index]["reference"] + "_mp"), waitTime); + wait waitTime; + } + } + } + else + { + if (IsDefined(displayMode)) + { + foreach (weapon in GetArrayKeys(level.zombie_weapons)) + { + self thread TellPlayer(array(getweapondisplayname(weapon)), waitTime); + wait waitTime; + } + } + else + { + foreach (weapon in GetArrayKeys(level.zombie_weapons)) + { + self thread TellPlayer(array(weapon), waitTime); + wait waitTime; + } + } + } +} + +ListAttachments(weaponName) +{ + weaponIndex = 0; + + if (IsDefined(weaponName)) + { + if (GetSubStr(weaponName, weaponName.size - 3, weaponName.size) != "_mp") + { + weaponName += "_mp"; + } + + if (!IsValidWeapon(weaponName)) + { + return WeaponDoesNotExistError(weaponName); + } + + weaponIndex = getbaseweaponitemindex(weaponName); + } + else + { + weaponIndex = getbaseweaponitemindex(self getcurrentweapon()); + } + + self thread TellPlayer(StrTok(level.tbl_weaponids[weaponIndex]["attachment"], " "), 2); +} \ No newline at end of file