mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
Added request am41375 (animation toggling on silenced weapons)
This commit is contained in:
parent
f5414ff8de
commit
4fe8c71d62
@ -218,41 +218,59 @@ static cell AMX_NATIVE_CALL cs_set_weapon_silenced(AMX *amx, cell *params) // cs
|
|||||||
// Make into edict pointer
|
// Make into edict pointer
|
||||||
edict_t *pWeapon = INDEXENT(params[1]);
|
edict_t *pWeapon = INDEXENT(params[1]);
|
||||||
|
|
||||||
|
bool draw_animation = true;
|
||||||
|
|
||||||
|
if ((params[0] / sizeof(cell)) >= 3)
|
||||||
|
{
|
||||||
|
draw_animation = params[3] ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
|
int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
|
||||||
int *silencemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
|
int *silencemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
|
||||||
|
|
||||||
switch (weapontype) {
|
switch (weapontype)
|
||||||
|
{
|
||||||
case CSW_M4A1:
|
case CSW_M4A1:
|
||||||
if (params[2] == 1) {
|
if (params[2] == 1)
|
||||||
if (!(*silencemode & M4A1_SILENCED)) { // want to silence - can't already be silenced
|
{
|
||||||
|
if (!(*silencemode & M4A1_SILENCED))
|
||||||
|
{ // want to silence - can't already be silenced
|
||||||
*silencemode |= M4A1_SILENCED;
|
*silencemode |= M4A1_SILENCED;
|
||||||
// If this weapon has an owner that is a player, play animation for that player.
|
// If this weapon has an owner that is a player, play animation for that player.
|
||||||
if (UTIL_IsPlayer(amx, pWeapon->v.owner))
|
if (draw_animation && UTIL_IsPlayer(amx, pWeapon->v.owner))
|
||||||
|
{
|
||||||
pWeapon->v.owner->v.weaponanim = M4A1_ATTACHSILENCEANIM;
|
pWeapon->v.owner->v.weaponanim = M4A1_ATTACHSILENCEANIM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*silencemode & M4A1_SILENCED) { // want to unsilence - can't already be unsilenced
|
} else if (*silencemode & M4A1_SILENCED) { // want to unsilence - can't already be unsilenced
|
||||||
*silencemode &= ~M4A1_SILENCED;
|
*silencemode &= ~M4A1_SILENCED;
|
||||||
// If this weapon has an owner that is a player, play animation for that player.
|
// If this weapon has an owner that is a player, play animation for that player.
|
||||||
if (UTIL_IsPlayer(amx, pWeapon->v.owner))
|
if (draw_animation && UTIL_IsPlayer(amx, pWeapon->v.owner))
|
||||||
|
{
|
||||||
pWeapon->v.owner->v.weaponanim = M4A1_DETACHSILENCEANIM;
|
pWeapon->v.owner->v.weaponanim = M4A1_DETACHSILENCEANIM;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CSW_USP:
|
case CSW_USP:
|
||||||
if (params[2] == 1) {
|
if (params[2] == 1)
|
||||||
if (!(*silencemode & USP_SILENCED)) { // want to silence - can't already be silenced
|
{
|
||||||
|
if (!(*silencemode & USP_SILENCED))
|
||||||
|
{ // want to silence - can't already be silenced
|
||||||
*silencemode |= USP_SILENCED;
|
*silencemode |= USP_SILENCED;
|
||||||
// If this weapon has an owner that is a player, play animation for that player.
|
// If this weapon has an owner that is a player, play animation for that player.
|
||||||
if (UTIL_IsPlayer(amx, pWeapon->v.owner))
|
if (draw_animation && UTIL_IsPlayer(amx, pWeapon->v.owner))
|
||||||
|
{
|
||||||
pWeapon->v.owner->v.weaponanim = USP_ATTACHSILENCEANIM;
|
pWeapon->v.owner->v.weaponanim = USP_ATTACHSILENCEANIM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*silencemode & USP_SILENCED) { // want to unsilence - can't already be unsilenced
|
} else if (*silencemode & USP_SILENCED) { // want to unsilence - can't already be unsilenced
|
||||||
*silencemode &= ~USP_SILENCED;
|
*silencemode &= ~USP_SILENCED;
|
||||||
// If this weapon has an owner that is a player, play animation for that player.
|
// If this weapon has an owner that is a player, play animation for that player.
|
||||||
if (UTIL_IsPlayer(amx, pWeapon->v.owner))
|
if (draw_animation && UTIL_IsPlayer(amx, pWeapon->v.owner))
|
||||||
|
{
|
||||||
pWeapon->v.owner->v.weaponanim = USP_DETACHSILENCEANIM;
|
pWeapon->v.owner->v.weaponanim = USP_DETACHSILENCEANIM;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -222,7 +222,7 @@ native cs_get_weapon_silen(index);
|
|||||||
|
|
||||||
/* If silence = 1, weapon will be silenced, 0 and silencer will be removed. Only USP and M4A1 can be silenced.
|
/* If silence = 1, weapon will be silenced, 0 and silencer will be removed. Only USP and M4A1 can be silenced.
|
||||||
*/
|
*/
|
||||||
native cs_set_weapon_silen(index, silence = 1);
|
native cs_set_weapon_silen(index, silence = 1, draw_animation = 1);
|
||||||
|
|
||||||
/* Returns amount of ammo in weapon's clip.
|
/* Returns amount of ammo in weapon's clip.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user