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

View File

@ -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())
{
@ -67,7 +79,12 @@ GivePlayerWeapon(targetedPlayerName, weaponName, camoIndex, takeCurrentWeapon, p
player TakeWeapon(player GetCurrentWeapon());
}
DoGiveWeapon(weaponName, attachments, finalCamoIndex);
if (IsDefined(attachments))
{
weaponName = weaponName + "+" + attachments;
}
player GiveWeapon(weaponName, 0, finalCamoIndex);
if (IsDefined(playSwitchAnimation) && playSwitchAnimation)
{
@ -78,18 +95,3 @@ 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);
}