Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable random weapons when player choose weapon from menu #93

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading