Derma ban/kick submenu

I’m trying to make a ban menu (which works ofc) but its getting a bit ugly. I’m just wondering if I can make an array or something to make the values for each player. Since I’m not so good at LUA, I would appreciate the help.
cl_scoreboard.lua



                    if user:IsAdmin() or user:IsUserGroup("admin") or user:IsUserGroup("superadmin") then
                        local dmsub = dm:AddSubMenu("Ban")
                            
                            local reason = "" -- will be used as default value until it reads the actual command variable
                            local reason_time = "" -- will be used as default value until it reads the actual command variable
                            
                            local dmsubx = dmsub:AddSubMenu("10 min")
                            dmsubx:AddOption("Mic Spam",function()
                                reason = "Mic Spam"
                                reason_time = 10
                                LocalPlayer():ConCommand( 'ulx ban "' .. nick .. '" "' .. reason_time .. '" "' .. reason .. '"' )
                            end)
                            dmsubx:AddOption("Hacker",function()
                                reason = "Hacker"
                                reason_time = 10
                                LocalPlayer():ConCommand( 'ulx ban "' .. nick .. '" "' .. reason_time .. '" "' .. reason .. '"' )
                            end)
                            dmsubx:AddOption("Ignoring Admins",function()
                                reason = "Ignoring Admins"
                                reason_time = 10
                                LocalPlayer():ConCommand( 'ulx ban "' .. nick .. '" "' .. reason_time .. '" "' .. reason .. '"' )
                            end)
                            dmsubx:AddOption("Breaking the rules",function()
                                reason = "Breaking the server rules"
                                reason_time = 10
                                LocalPlayer():ConCommand( 'ulx ban "' .. nick .. '" "' .. reason_time .. '" "' .. reason .. '"' )
                            end)
                            dmsubx:AddOption("Exploiting",function()
                                reason = "Exploiting"
                                reason_time = 10
                                LocalPlayer():ConCommand( 'ulx ban "' .. nick .. '" "' .. reason_time .. '" "' .. reason .. '"' )
                            end)
                    end


As you can see, its getting a bit ugly if i just keep doing this for each min etc. And I’m also doing this trough scoreboard (right click to access the menu).

Note: The target is entity while the LocalPlayer() is user

You could just use a table and loop through it. Since you’re only using reasons and times you can just use keys for the reasons:
[lua]local options = {

["Hacker"] = 10,
["Ignoring Admins"] = 10

}

for reason, time in pairs( options ) do

dmsubx:AddOption( reason, function()
	LocalPlayer():ConCommand( string.format( "ulx ban %s %i %s", nick, time, reason ) )
end )

end[/lua]

Thank you, its what I needed :slight_smile: