From d0776fde3f6131f27579c0e43dce7f4f09731f24 Mon Sep 17 00:00:00 2001 From: Resxt <55228336+Resxt@users.noreply.github.com> Date: Sat, 28 Oct 2023 15:10:54 +0200 Subject: [PATCH] chat_command_give 1.1.0 Added giveperk command --- chat_commands/zm/README.md | 9 ++++- chat_commands/zm/chat_command_give.gsc | 56 ++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/chat_commands/zm/README.md b/chat_commands/zm/README.md index 826bb2b..0d0ac97 100644 --- a/chat_commands/zm/README.md +++ b/chat_commands/zm/README.md @@ -7,9 +7,12 @@ These scripts go in `scripts\zm` | Name | Description | Arguments expected | Example | Permission level | |---|---|---|---|---| | givepowerup | Makes the powerup drop on the player, which activates it | (1) the code name of the powerup | `!givepowerup full_ammo` | 2 | +| giveperk | Gives the chosen perk to the targeted player | (1) the name of the targeted player (2) the name of the perk (multiple aliases available, see the GetPerkInfos function in [chat_commands](../chat_commands.gsc)) | `!giveperk me jugg` | 2 | -You can use [chat_command_info.gsc](../README.md#chat_command_infogsc) to list available powerups. -Alternatively you can use [this](https://github.com/plutoniummod/t6-scripts/blob/main/ZM/Core/maps/mp/zombies/_zm_powerups.gsc#L95) to get powerup code names from your browser (first parameter of the `add_zombie_powerup` function calls). Note that this lists all powerups without taking into account whether they're available on the map you play on or not. +You can use [chat_command_info.gsc](../README.md#chat_command_infogsc) to list available powerups and perks. +Alternatively you can use [this](https://github.com/plutoniummod/t6-scripts/blob/main/ZM/Core/maps/mp/zombies/_zm_powerups.gsc#L95) to get powerup code names from your browser (first parameter of the `add_zombie_powerup` function calls). Note that this lists all powerups without taking into account whether they're available on the map you play on or not. + +You can disable the perk music and/or the bottle animation whenever you use `!giveperk` by changing the corresponding boolean(s) to false in the `GivePlayerPerk` function call. Note that like other scripts on this page this is a ZM only script, but this script also has a global version (works in both MP and ZM) that you can find [here](../chat_command_give.gsc) if you're looking for more give commands. You can have both installed at the same time as long as this script is in the `zm` folder and the global version is either in the `scripts` folder or the `mp` folder. @@ -18,6 +21,8 @@ You can have both installed at the same time as long as this script is in the `z |---| | `!givepowerup all` | | `!givepowerup all_no_nuke` | +| `!giveperk me all` | +| `!giveperk me quickrevive` | ## chat_command_no_target.gsc diff --git a/chat_commands/zm/chat_command_give.gsc b/chat_commands/zm/chat_command_give.gsc index 835e146..753a310 100644 --- a/chat_commands/zm/chat_command_give.gsc +++ b/chat_commands/zm/chat_command_give.gsc @@ -3,6 +3,7 @@ Init() { CreateCommand(level.chat_commands["ports"], "givepowerup", "function", ::GivePowerupCommand, 2, [], array("spawnpowerup", "powerup", "pu")); + CreateCommand(level.chat_commands["ports"], "giveperk", "function", ::GivePerkCommand, 2, [], array("perk")); } @@ -24,6 +25,21 @@ GivePowerupCommand(args) } } +GivePerkCommand(args) +{ + if (args.size < 2) + { + return NotEnoughArgsError(2); + } + + error = GivePlayerPerk(args[0], args[1], true, true); + + if (IsDefined(error)) + { + return error; + } +} + /* Logic section */ @@ -62,5 +78,45 @@ GivePlayerPowerup(powerupName) } } +GivePlayerPerk(playerName, perkName, enableMusic, enableAnimation) +{ + player = FindPlayerByName(playerName); + + if (!IsDefined(player)) + { + return PlayerDoesNotExistError(playerName); + } + + if (ToLower(perkName) == "all") + { + foreach (perk in GetAvailablePerks()) + { + player thread maps\mp\zombies\_zm_perks::give_perk(perk, 0); + } + } + else + { + perkInfos = GetPerkInfos(perkName); + + if (perkInfos.size > 0) + { + if (enableMusic) + { + player thread maps\mp\zombies\_zm_audio::play_jingle_or_stinger( perkInfos["music"]); + } + + if (enableAnimation) + { + player thread vending_trigger_post_think(player, perkInfos["perk_name"]); + } + else + { + player thread maps\mp\zombies\_zm_perks::give_perk(perkInfos["perk_name"], 0); + } + } + else + { + return PerkDoesNotExistError(perkName); + } } } \ No newline at end of file