mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-20 19:23:08 +00:00
Fix closure issues in menus and update dependencies
Captured player and duration variables in menu callbacks to prevent closure-related bugs. Updated package versions in project files and bumped plugin version to 1.7.8-beta-5. Improved player validation and message localization logic.
This commit is contained in:
@@ -41,11 +41,12 @@ public static class PlayersMenu
|
||||
continue;
|
||||
|
||||
var enabled = admin.CanTarget(player);
|
||||
var capturedPlayer = player; // Capture in local variable to avoid closure issues
|
||||
|
||||
if (optionName != null)
|
||||
menu?.AddMenuOption(optionName, (_, _) =>
|
||||
menu?.AddMenuOption(optionName, (controller, option) =>
|
||||
{
|
||||
if (player != null) onSelectAction.Invoke(admin, player);
|
||||
if (capturedPlayer != null) onSelectAction.Invoke(admin, capturedPlayer);
|
||||
},
|
||||
!enabled);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user