From 384b32f33a0b46cad5b12dd9f36e0875abb71bd1 Mon Sep 17 00:00:00 2001 From: Resxt <55228336+Resxt@users.noreply.github.com> Date: Fri, 16 Jun 2023 20:00:20 +0200 Subject: [PATCH] chat_command_give 1.0.1 Fixed weapon not given to the proper player in some scenarios Fixed player not switching to the weapon automatically in some scenarios Fixed multiple attachments not working --- chat_commands/chat_command_give.gsc | 36 +++++++++++++++-------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/chat_commands/chat_command_give.gsc b/chat_commands/chat_command_give.gsc index c97600a..e77b5ad 100644 --- a/chat_commands/chat_command_give.gsc +++ b/chat_commands/chat_command_give.gsc @@ -40,7 +40,19 @@ GivePlayerWeapon(targetedPlayerName, weaponName, camoIndex, takeCurrentWeapon, p weaponName = ToLower(weaponName); weaponSplitted = StrTok(weaponName, "+"); weaponName = weaponSplitted[0]; - attachments = weaponSplitted[1]; + attachments = ""; + + for (i = 1; i < weaponSplitted.size; i++) + { + if (i == 1) + { + attachments += weaponSplitted[i]; + } + else + { + attachments += "+" + weaponSplitted[i]; + } + } if (IsMultiplayerMode()) { @@ -66,8 +78,13 @@ GivePlayerWeapon(targetedPlayerName, weaponName, camoIndex, takeCurrentWeapon, p { player TakeWeapon(player GetCurrentWeapon()); } + + if (IsDefined(attachments)) + { + weaponName = weaponName + "+" + attachments; + } - DoGiveWeapon(weaponName, attachments, finalCamoIndex); + player GiveWeapon(weaponName, 0, finalCamoIndex); if (IsDefined(playSwitchAnimation) && playSwitchAnimation) { @@ -77,19 +94,4 @@ GivePlayerWeapon(targetedPlayerName, weaponName, camoIndex, takeCurrentWeapon, p { player SetSpawnWeapon(weaponName); } -} - -DoGiveWeapon(weaponCodeName, attachments, camoIndex) -{ - if (IsDefined(attachments) && attachments != "") - { - weaponCodeName = weaponCodeName+ "+" + attachments; - } - - if (!IsDefined(camoIndex)) - { - camoIndex = 0; - } - - self GiveWeapon(weaponCodeName, 0, camoIndex); } \ No newline at end of file