So is there any way to make DFrame popup when i press attack button on player?
From the PrimaryAttack function serverside, network to the client to open the frame.
I tried to make it but it doesn't work.(Also it doesn't seem working(can't shoot))
function SWEP:PrimaryAttack()
local trace = self.Owner:GetEyeTrace()
local showto = trace.Entity
if IsValid(showto) and showto:IsPlayer() then
net.Start("OpenPassportFrame")
net.Send(showto)
end
ChatPrint("Gotcha fat boy")
passportframe()
end
if SERVER then
util.AddNetworkString("OpenPassportFrame")
end
if CLIENT then
local function drawpassport()
local passportframe = vgui.Create("DFrame")
passportframe:Center()
passportframe:SetSize(300,400)
passportframe:SetTitle("Testing")
passportframe.Paint = function(s, w, h)
draw.SimpleText("Hello there", "DermaDefault", w/2, h/2, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
end
end
net.Receive("OpenPassportFrame", drawpassport)
end
1. Add a SERVER inside your PrimaryAttack function - you don't want the net code to run clientside.
2. ChatPrint isn't a function, perhaps you meant Player/ChatPrint.
3. drawpassport() isn't defined in your code.
4. Store "passwortframe" outside of your drawpassport callback and check if it exists before creating a new frame. Otherwise, the frame could be created infinitely by shooting the same player.
Now everything is working. Thank!
Sorry, you need to Log In to post a reply to this thread.