How to open the Derma menu when clicking on the object
16 replies, posted
How to open the Derma menu when clicking on the object?
object.DoClick = function()
local frame = vgui.Create( "DFrame" )
frame:SetSize( ScrW() * 0.9, ScrH() * 0.9 )
frame:Center()
frame:MakePopup()
end
I'm making a money printer and I want to make a setup menu
Ok, sorry, one more question. What do you mean by clicking? Left clicking? Right clicking? Clicking in the context menu? Pressing E on the object?
ENTITY/Use
Entity/SetUseType
Use button "E"
Two threads about one issue? How to make a button on 2D3D? (read the last post)
No..
Net Library Usage
And how can I use Player: GetEyeTrace () to open exactly the printer that I'm looking at?
You dont need it.
Every SENT has fucntion SENT:Use().
Use net.Send inside it
I already tried, but if there is a printer in the field of view that I opened, then it opens up in the field of view ((
If your printers are too closer to each other, put this:
if caller:GetEyeTrace().Entity != self then return end
function ENT:Use( ply, caller )
if caller:GetEyeTrace().Entity != self then return end
util.AddNetworkString( "myMessage" )
net.Start( "myMessage" )
net.Send(ply)
end
net.Receive( "MyMessage", function( len, ply )
local Frame = vgui.Create( "DFrame" )
Frame:SetTitle( "Принтер "..owner.."'а" )
Frame:SetSize( 500, 500 )
Frame:Center()
Frame:MakePopup()
Frame.Paint = function( self, w, h ) -- 'function Frame:Paint( w, h )' works too
draw.RoundedBox( 0, 0, 0, w, h, Color( 60, 60, 60 ) ) -- Draw a red box instead of the frame
draw.RoundedBox( 0, 0, 0, w, 25, Color( 80, 80, 80 ) ) -- Draw a red box instead of the frame
draw.RoundedBox(0,15,45,100*4.67,1,Color(255, 255, 255))
draw.RoundedBox(0,15,85,100*4.67,1,Color(255, 255, 255))
draw.RoundedBox(0,15,45,1,40,Color(255, 255, 255))
draw.RoundedBox(0,482,45,1,40,Color(255, 255, 255))
draw.RoundedBox(0,20,50,progress*4.6,30,Color(168, 2*progress, 0))
draw.DrawText( "Прогресс: "..progress.."/100%", "MoneyFont32", 250, 52, Color( 255, 255, 255, 255 ),1) -- Работа
draw.RoundedBox(0,15,45+50,100*4.67,1,Color(255, 255, 255))
draw.RoundedBox(0,15,85+50,100*4.67,1,Color(255, 255, 255))
draw.RoundedBox(0,15,45+50,1,40,Color(255, 255, 255))
draw.RoundedBox(0,482,45+50,1,40,Color(255, 255, 255))
if Catrig != 0 then
draw.RoundedBox(0,20,100,Catrig*46,30,Color(0, 162, 199)) -- Полоска хранилища
draw.SimpleText("Картридж: "..Catrig.."/10","MoneyFont32" , 250, 52+50,Color( 255, 255, 255, 255 ), 1 )
else
draw.RoundedBox(0,20,100,460,30,Color(200/cin, 100, 100))
draw.SimpleText("Картридж: "..Catrig.."/10","MoneyFont32" , 250, 52+50,Color( 255, 255, 255 ), 1 )
end
end
local Button = vgui.Create( "DButton", Frame )
Button:SetText( "Улучшить" )
Button:SetTextColor( Color( 255, 255, 255 ) )
Button:SetPos( 100, 200 )
Button:SetSize( 100, 30 )
Button.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue button
end
Button.DoClick = function( self )
buton = "clk"
end
end )
Does not work
ENT:Use( Entity activator, Entity caller, number useType, number value )
ply is not first argument.
Caller is. Check wiki
function ENT:Use( caller, ply )
if caller:GetEyeTrace().Entity != self then return end
util.AddNetworkString( "myMessage" )
net.Start( "myMessage" )
net.Send(ply)
end
So does not work either
Again.
Please find error by yourself
util.AddNetworkString( "myMessage" )
function ENT:Use( activator, caller )
if caller:GetEyeTrace().Entity != self then return end
net.Start( "myMessage" )
net.Send(caller)
end
Sorry, you need to Log In to post a reply to this thread.