DMenu Problem

I get this spamming my console when the following is ran, why do DMenu’s do this?


Type: ban
 Parameter: Perm Ban
 Time: 0
Type: ban
 Parameter: Random Deathmatch
 Time: 5
Type: ban
 Parameter: Exploting
 Time: 5
Type: ban
 Parameter: Flaming
 Time: 5
Type: ban
 Parameter: Spamming
 Time: 5
Type: ban
 Parameter: Abusing Tools
 Time: 5
Type: ban
 Parameter: Abusing Props
 Time: 5
Type: ban
 Parameter: Random Deathmatch
 Time: 10
Type: ban
 Parameter: Exploting
 Time: 10
Type: ban
 Parameter: Flaming
 Time: 10
Type: ban
 Parameter: Spamming
 Time: 10
Type: ban
 Parameter: Abusing Tools
 Time: 10
Type: ban
 Parameter: Abusing Props
 Time: 10
Type: ban
 Parameter: Random Deathmatch
 Time: 30
Type: ban
 Parameter: Exploting
 Time: 30
Type: ban
 Parameter: Flaming
 Time: 30
Type: ban
 Parameter: Spamming
 Time: 30
Type: ban
 Parameter: Abusing Tools
 Time: 30
Type: ban
 Parameter: Abusing Props
 Time: 30
Type: ban
 Parameter: Random Deathmatch
 Time: 60
Type: ban
 Parameter: Exploting
 Time: 60
Type: ban
 Parameter: Flaming
 Time: 60
Type: ban
 Parameter: Spamming
 Time: 60
Type: ban
 Parameter: Abusing Tools
 Time: 60
Type: ban
 Parameter: Abusing Props
 Time: 60
Type: ban
 Parameter: Random Deathmatch
 Time: 120
Type: ban
 Parameter: Exploting
 Time: 120
Type: ban
 Parameter: Flaming
 Time: 120
Type: ban
 Parameter: Spamming
 Time: 120
Type: ban
 Parameter: Abusing Tools
 Time: 120
Type: ban
 Parameter: Abusing Props
 Time: 120
Type: ban
 Parameter: Random Deathmatch
 Time: 1440
Type: ban
 Parameter: Exploting
 Time: 1440
Type: ban
 Parameter: Flaming
 Time: 1440
Type: ban
 Parameter: Spamming
 Time: 1440
Type: ban
 Parameter: Abusing Tools
 Time: 1440
Type: ban
 Parameter: Abusing Props
 Time: 1440
Type: ban
 Parameter: Random Deathmatch
 Time: 10080
Type: ban
 Parameter: Exploting
 Time: 10080
Type: ban
 Parameter: Flaming
 Time: 10080
Type: ban
 Parameter: Spamming
 Time: 10080
Type: ban
 Parameter: Abusing Tools
 Time: 10080
Type: ban
 Parameter: Abusing Props
 Time: 10080
Type: ban
 Parameter: Random Deathmatch
 Time: Perm
Type: ban
 Parameter: Exploting
 Time: Perm
Type: ban
 Parameter: Flaming
 Time: Perm
Type: ban
 Parameter: Spamming
 Time: Perm
Type: ban
 Parameter: Abusing Tools
 Time: Perm
Type: ban
 Parameter: Abusing Props
 Time: Perm


Snippits that make up the failing code
[lua]
function AdminRun(type, par, time)
print("Type: “…type…”
Parameter: “…par…”
Time: "…tostring(time))
end

local Reasons = {“Random Deathmatch”, “Exploting”, “Flaming”, “Spamming”, “Abusing Tools”, “Abusing Props”}
local BanTime = {“5”, “10”, “30”, “60”, “120”, “1440”, “10080”, “Perm”}

BanB.DoClick = function()
local MBB = DermaMenu()
local SubB = MBB:AddSubMenu(“Time”)
MBB:AddOption(“No Reason - Perm”, AdminRun(“ban”,“Perm Ban”, 0))

for _,v in pairs (BanTime) do
	local TimeS = SubB:AddSubMenu(v)
	for _,k in pairs (Reasons) do
		TimeS:AddOption(k, AdminRun("ban",k,v))
	end
end

MBB:Open()

end
[/lua]

Anyone got a clue why it runs the command before i even push the option?

[Lua]
function AdminRun(type, par, time)
print("Type: “…type…”
Parameter: “…par…”
Time: "…tostring(time))
end

local Reasons = {“Random Deathmatch”, “Exploting”, “Flaming”, “Spamming”, “Abusing Tools”, “Abusing Props”}
local BanTime = {“5”, “10”, “30”, “60”, “120”, “1440”, “10080”, “Perm”}

BanB.DoClick = function()
local MBB = DermaMenu()
local SubB = MBB:AddSubMenu(“Time”)
MBB:AddOption(“No Reason - Perm”, function() AdminRun(“ban”,“Perm Ban”, 0) end)

for _,v in pairs (BanTime) do
    local TimeS = SubB:AddSubMenu(v) 
    for _,k in pairs (Reasons) do
        TimeS:AddOption(k, function() AdminRun("ban",k,v) end) 
    end
end

MBB:Open() 

end
[/Lua]

You have to do AddOption(“bleh”, function( self ) functionname( args ) end) or else it runs the function as the menu is created, not when you click it.