hello everyone,I meet a problem.
there is my code
for i=1,#player.GetAll() do
local button = vgui.Create( "Button",Menu )
button:SetPos(0,100*i)
button:SetSize( 150, 30 )
button:SetVisible( true )
button:SetText(player.GetAll()[i]:Nick())
function button:OnMousePressed()
end
end
I Create serveral buttons Dynamicly, when i press a button i want to know which one i pressed,i don't know how to do this.sorry about my language ,i hope you can understand ,thank you.
Use DoClick
From phone
[lua]
button.DoClick = function( self )
print(player.GetAll()[i]:Nick())
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.