Skip to content

Commit

Permalink
fix: disable random weapons when player choose weapon from menu (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
wopox1337 committed Feb 15, 2024
1 parent f78fa74 commit 7f5e772
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public ClCmd_cl_autobuy(const player) {
if (!IsActive())
return PLUGIN_CONTINUE

Player_SwitchRandomWeapons(player)
Player_SwitchRandomWeapons(player, .newState = !g_playerRandomWeapons[player])

return PLUGIN_HANDLED
}
Expand Down Expand Up @@ -205,13 +205,13 @@ public ClCmd_Guns(const player) {
*
* @return Returns true if random weapons mode is enabled after toggling, false otherwise.
*/
static bool: Player_SwitchRandomWeapons(const player) {
static bool: Player_SwitchRandomWeapons(const player, const bool: newState) {
if (!IsActive())
return false

SetGlobalTransTarget(player)

g_playerRandomWeapons[player] = !g_playerRandomWeapons[player]
g_playerRandomWeapons[player] = newState

if (!g_playerRandomWeapons[player]) {
EquipManager_Reset(player)
Expand Down Expand Up @@ -341,6 +341,9 @@ public MenuHandler_ChooseEquip(const player, const menu, const item) {
new EquipType_e: section = EquipType_e: strtol(info)
g_playerWeapons[player][section] = item

if (g_playerRandomWeapons[player])
Player_SwitchRandomWeapons(player, .newState = false)

Player_GiveWeapon(player, section)

UTIL_PlaySoundEffect(player, "fvox/blip.wav", .pitch = 80)
Expand Down

0 comments on commit 7f5e772

Please sign in to comment.