So im trying to make a VGUI on a swep to open when left click but nothing will happend when i left click. Help thanks
and yes i have looked at tutorials and videos but still wont work i cant figure it out there are no script errors when i left click
Code:
[code]
function SWEP:window()
if CLIENT then
local Form = vgui.Create( "DFrame" )
Form:SetPos( 200, 200 ) -- Position form on your monitor
Form:SetSize( 300, 150 ) -- Size form
Form:SetTitle( "Name window" ) -- Form set name
Form:SetVisible( true ) -- Form rendered ( true or false )
Form:SetDraggable( false ) -- Form draggable
Form:ShowCloseButton( true ) -- Show buttons panel
Form:MakePopup()
chat.AddText(Color(255,0,0), "test" )
end
end
function SWEP:PrimaryAttack()
self:window()
end
[/code]
[QUOTE=OMGOMG132;42342515]So im trying to make a VGUI on a swep to open when left click but nothing will happend when i left click. Help thanks
and yes i have looked at tutorials and videos but still wont work i cant figure it out there are no script errors when i left click
Code:
[code]
function SWEP:window()
if CLIENT then
local Form = vgui.Create( "DFrame" )
Form:SetPos( 200, 200 ) -- Position form on your monitor
Form:SetSize( 300, 150 ) -- Size form
Form:SetTitle( "Name window" ) -- Form set name
Form:SetVisible( true ) -- Form rendered ( true or false )
Form:SetDraggable( false ) -- Form draggable
Form:ShowCloseButton( true ) -- Show buttons panel
Form:MakePopup()
chat.AddText(Color(255,0,0), "test" )
end
end
function SWEP:PrimaryAttack()
self:window()
end
[/code][/QUOTE]
As far as I remember, PrimaryAttack is a shared function, but never gets called clientside. Try making a net messageto the SWEP owner, and then linking the window function to that message.
[QUOTE=Ghost_Sailor;42342563]As far as I remember, PrimaryAttack is a shared function, but never gets called clientside. Try making a net messageto the SWEP owner, and then linking the window function to that message.[/QUOTE]
can you help me with the net message? im confused
[URL=http://facepunch.com/showthread.php?t=1310145&p=42299335#post42299335]You can adapt what I wrote here to your needs[/URL], [URL=wiki.garrysmod.com]or use the one on the wiki[/URL]
[QUOTE=rejax;42342613][URL=http://facepunch.com/showthread.php?t=1310145&p=42299335#post42299335]You can adapt what I wrote here to your needs[/URL], [URL=wiki.garrysmod.com]or use the one on the wiki[/URL][/QUOTE]
many thanks
[QUOTE=OMGOMG132;42342583]can you help me with the net message? im confused[/QUOTE]
Send the message from the server.
Add
[lua]util.AddNetworkString("vguishow")[/lua]
to the beginning of your init file on the SWEP.
Add
[lua]net.Start("vguishow")
net.Send(self.Owner)[/lua]
to the PrimaryAttack function.
Change the window to
[lua]function window()
local Form = vgui.Create( "DFrame" )
Form:SetPos( 200, 200 ) -- Position form on your monitor
Form:SetSize( 300, 150 ) -- Size form
Form:SetTitle( "Name window" ) -- Form set name
Form:SetVisible( true ) -- Form rendered ( true or false )
Form:SetDraggable( false ) -- Form draggable
Form:ShowCloseButton( true ) -- Show buttons panel
Form:MakePopup()
chat.AddText(Color(255,0,0), "test" )
end
net.Receive( "vguishow", window)[/lua]
[QUOTE=Ghost_Sailor;42342636]Send the message from the server.
Add
[lua]util.AddNetworkString("vguishow")[/lua]
to the beginning of your init file on the SWEP.
Add
[lua]net.Start("vguishow")
net.Send(self.Owner)[/lua]
to the PrimaryAttack function.
Change the window to
[lua]function window()
local Form = vgui.Create( "DFrame" )
Form:SetPos( 200, 200 ) -- Position form on your monitor
Form:SetSize( 300, 150 ) -- Size form
Form:SetTitle( "Name window" ) -- Form set name
Form:SetVisible( true ) -- Form rendered ( true or false )
Form:SetDraggable( false ) -- Form draggable
Form:ShowCloseButton( true ) -- Show buttons panel
Form:MakePopup()
chat.AddText(Color(255,0,0), "test" )
end
net.Receive( "vguishow", window)[/lua][/QUOTE]
still not working now with an error! :(
[code]
function window()
if CLIENT then
local Form = vgui.Create( "DFrame" )
Form:SetPos( 200, 200 ) -- Position form on your monitor
Form:SetSize( 300, 150 ) -- Size form
Form:SetTitle( "Name window" ) -- Form set name
Form:SetVisible( true ) -- Form rendered ( true or false )
Form:SetDraggable( false ) -- Form draggable
Form:ShowCloseButton( true ) -- Show buttons panel
Form:MakePopup()
chat.AddText(Color(255,0,0), "test" )
end
end
net.Receive( "vguishow", window)
function SWEP:PrimaryAttack( ply )
window()
net.Start("vguishow")
net.Send(self.Owner)
end
[/code]
here is the cl_init file code:
[code]
AddCSLuaFile("cl_init.lua");
AddCSLuaFile("shared.lua");
include("shared.lua");
util.AddNetworkString("vguishow")
SWEP.Weight=5;
SWEP.AutoSwitchTo=false;
SWEP.AutoSwitchFrom=false;
[/code]
The error is
[code]
[ERROR] addons/swep_maker/lua/weapons/main_maker/shared.lua:55: Calling net.Start with unpooled message name [http://goo.gl/qcx0y]
1. Start - [C]:-1
2. unknown - addons/swep_maker/lua/weapons/main_maker/shared.lua:55
[/code]
directory of cl_init is:
lua\weapons\main_maker\cl_init.lua
[QUOTE=OMGOMG132;42342712]still not working now with an error! :(
[code]
function window()
if CLIENT then
local Form = vgui.Create( "DFrame" )
Form:SetPos( 200, 200 ) -- Position form on your monitor
Form:SetSize( 300, 150 ) -- Size form
Form:SetTitle( "Name window" ) -- Form set name
Form:SetVisible( true ) -- Form rendered ( true or false )
Form:SetDraggable( false ) -- Form draggable
Form:ShowCloseButton( true ) -- Show buttons panel
Form:MakePopup()
chat.AddText(Color(255,0,0), "test" )
end
end
net.Receive( "vguishow", window)
function SWEP:PrimaryAttack( ply )
window()
net.Start("vguishow")
net.Send(self.Owner)
end
[/code]
here is the cl_init file code:
[code]
AddCSLuaFile("cl_init.lua");
AddCSLuaFile("shared.lua");
include("shared.lua");
util.AddNetworkString("vguishow")
SWEP.Weight=5;
SWEP.AutoSwitchTo=false;
SWEP.AutoSwitchFrom=false;
[/code]
The error is
[code]
[ERROR] addons/swep_maker/lua/weapons/main_maker/shared.lua:55: Calling net.Start with unpooled message name [http://goo.gl/qcx0y]
1. Start - [C]:-1
2. unknown - addons/swep_maker/lua/weapons/main_maker/shared.lua:55
[/code]
directory of cl_init is:
lua\weapons\main_maker\cl_init.lua[/QUOTE]
addNetworkString has to be in the init file, not the cl_init. It's a serverside function.
[QUOTE=Ghost_Sailor;42342826]addNetworkString has to be in the init file, not the cl_init. It's a serverside function.[/QUOTE]
Thanks for your paitence :) i got it all working now :D
Sorry, you need to Log In to post a reply to this thread.