chat_command_give 1.0.0

This commit is contained in:
Resxt 2023-06-13 12:53:44 +02:00
parent 45af4a60b0
commit 135a45f20b
2 changed files with 121 additions and 0 deletions

View File

@ -106,6 +106,32 @@ Note that this does not work during the prematch period.
|---|
| 3 |
## chat_command_give.gsc
<!-- 2 related commands in one file: -->
- Give weapon (with or without attachment(s) and camo in MP)
| Name | Description | Arguments expected | Example | Permission level |
|---|---|---|---|---|
| giveweapon | Gives the targeted player the specific weapon. Attachments and camo can be passed | (1) the name of the player (2) the weapon codename (3) optional, camo index from 0 to 45 | `!giveweapon me tar21_mp` | 2 |
You can use [chat_command_info.gsc](#chat_command_infogsc) to list available weapons and their attachments.
Alternatively you can use [this](https://forum.plutonium.pw/topic/1909/resource-stat-modification-checks-other-structures) to get weapon/attachment names from your browser.
| More examples (MP) |
|---|
| `!giveweapon me kard_mp` (give weapon by codename) |
| `!giveweapon me an94` (give weapon by codename without _mp at the end) |
| `!giveweapon me as50_mp+ir` (give weapon by codename with an attachment) |
| `!giveweapon me ballista_mp 15` (give weapon by codename with camo index 15, in this case gold camo) |
| `!giveweapon me dsr50_mp+silencer 16` (give weapon by codename with an attachment and camo index 16, in this case diamond camo) |
| More examples (ZM) |
|---|
| `!giveweapon me m14_zm` (give weapon by codename) |
| `!giveweapon me m1911_upgraded_zm` (give upgraded/PAPed weapon by codename) |
## chat_command_god_mode.gsc
Toggles whether the targeted player is in god mode (invincible) or not.

View File

@ -0,0 +1,95 @@
#include scripts\chat_commands;
Init()
{
CreateCommand(level.chat_commands["ports"], "giveweapon", "function", ::GiveWeaponCommand, 2);
}
/* Command section */
GiveWeaponCommand(args)
{
if (args.size < 2)
{
return NotEnoughArgsError(2);
}
error = GivePlayerWeapon(args[0], args[1], args[2], true, true);
if (IsDefined(error))
{
return error;
}
}
/* Logic section */
GivePlayerWeapon(targetedPlayerName, weaponName, camoIndex, takeCurrentWeapon, playSwitchAnimation)
{
player = FindPlayerByName(targetedPlayerName);
if (!IsDefined(player))
{
return PlayerDoesNotExistError(targetedPlayerName);
}
weaponName = ToLower(weaponName);
weaponSplitted = StrTok(weaponName, "+");
weaponName = weaponSplitted[0];
attachments = weaponSplitted[1];
if (IsMultiplayerMode())
{
if (GetSubStr(weaponName, weaponName.size - 3, weaponName.size) != "_mp")
{
weaponName += "_mp";
}
}
if (!IsValidWeapon(weaponName))
{
return WeaponDoesNotExistError(weaponName);
}
finalCamoIndex = 0;
if (IsDefined(camoIndex))
{
finalCamoIndex = int(camoIndex);
}
if (IsDefined(takeCurrentWeapon) && takeCurrentWeapon)
{
player TakeWeapon(player GetCurrentWeapon());
}
DoGiveWeapon(weaponName, attachments, finalCamoIndex);
if (IsDefined(playSwitchAnimation) && playSwitchAnimation)
{
player SwitchToWeapon(weaponName);
}
else
{
player SetSpawnWeapon(weaponName);
}
}
DoGiveWeapon(weaponCodeName, attachments, camoIndex)
{
if (IsDefined(attachments) && attachments != "")
{
weaponCodeName = weaponCodeName+ "+" + attachments;
}
if (!IsDefined(camoIndex))
{
camoIndex = 0;
}
self GiveWeapon(weaponCodeName, 0, camoIndex);
}