when one player opens the menu all players get a menu (help)
6 replies, posted
ok so what i want to happen is when a player on team 1 opens a menu only he gets it
my error is every player gets it
is there a way i can make it so only the one player gets the menu
inlt.lua
[code]
function GM:PlayerButtonDown( ply, key )
if (ply:Team() == 2 and key == 13) then
umsg.Start( "Openplz" )
umsg.End()
end
end
[/code]
cl_inlt.lua
[code]
function dermaShop()
local ply = LocalPlayer()
local butt = vgui.Create( "DButton", Frame )
local but = vgui.Create( "DButton", Frame )
local Frame = vgui.Create( "DFrame" )
Frame:SetTitle( "Test panel" )
Frame:SetSize( ScrW() * 0.208, ScrH() * 0.277 )
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( 231, 76, 60, 150 ) ) -- Draw a red box instead of the frame
end
butt:SetParent( Frame )
butt:SetText( "FlameThrower" )
butt:SetTextColor( Color( 255, 255, 255 ) )
butt:SetPos( 100, 25 )
butt:SetSize( 100, 30 )
butt.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue button
end
function butt:DoClick()
RunConsoleCommand("flamethrower")
end
but:SetParent( Frame )
but:SetText( "Nothing for now" )
but:SetTextColor( Color( 255, 255, 255 ) )
but:SetPos( 12, 25 )
but:SetSize( 90, 30 )
but.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue button
end
function but:DoClick()
RunConsoleCommand("test")
end
end
usermessage.Hook( "Openplz", dermaShop )
[/code]
Use the net library. It's SO much easier: [url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url]
[QUOTE=Exploderguy;47863748]Use the net library. It's SO much easier: [url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url][/QUOTE]
how would i use that to fix my problem
i cant really figure net libray it out
Net library is just like usermessages but newer and can send longer messages. I dont know the usermessage system syntax but I assume your issue is serverside that you are not sending "Openplz" to a player but all of the players in the server
[QUOTE=Exho;47864171]Net library is just like usermessages but newer and can send longer messages. I dont know the usermessage system syntax but I assume your issue is serverside that you are not sending "Openplz" to a player but all of the players in the server[/QUOTE]
well yes what it does is when one person opens the menu every players menu on the server opens
do you know how to fix this with net library or usermessage
init.lua
[code]
util.AddNetworkString("openplz")
function GM:PlayerButtonDown( ply, key )
if (ply:Team() == 2 and key == 13) then
net.Start("openplz")
net.Send(ply)
end
end
[/code]
cl_init.lua
[code]
local function dermaShop() -- LOCALIZE YOUR FUNCTIONS >:(
local ply = LocalPlayer()
local butt = vgui.Create( "DButton", Frame )
local but = vgui.Create( "DButton", Frame )
local Frame = vgui.Create( "DFrame" )
Frame:SetTitle( "Test panel" )
Frame:SetSize( ScrW() * 0.208, ScrH() * 0.277 )
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( 231, 76, 60, 150 ) ) -- Draw a red box instead of the frame
end
butt:SetParent( Frame )
butt:SetText( "FlameThrower" )
butt:SetTextColor( Color( 255, 255, 255 ) )
butt:SetPos( 100, 25 )
butt:SetSize( 100, 30 )
butt.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue button
end
function butt:DoClick()
RunConsoleCommand("flamethrower")
end
but:SetParent( Frame )
but:SetText( "Nothing for now" )
but:SetTextColor( Color( 255, 255, 255 ) )
but:SetPos( 12, 25 )
but:SetSize( 90, 30 )
but.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue button
end
function but:DoClick()
RunConsoleCommand("test")
end
end
net.Receive( "openplz", dermaShop )
[/code]
[QUOTE=Lolcats;47864470]init.lua
[code]
util.AddNetworkString("openplz")
function GM:PlayerButtonDown( ply, key )
if (ply:Team() == 2 and key == 13) then
net.Start("openplz")
net.Send(ply)
end
end
[/code]
cl_init.lua
[code]
local function dermaShop() -- LOCALIZE YOUR FUNCTIONS >:(
local ply = LocalPlayer()
local butt = vgui.Create( "DButton", Frame )
local but = vgui.Create( "DButton", Frame )
local Frame = vgui.Create( "DFrame" )
Frame:SetTitle( "Test panel" )
Frame:SetSize( ScrW() * 0.208, ScrH() * 0.277 )
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( 231, 76, 60, 150 ) ) -- Draw a red box instead of the frame
end
butt:SetParent( Frame )
butt:SetText( "FlameThrower" )
butt:SetTextColor( Color( 255, 255, 255 ) )
butt:SetPos( 100, 25 )
butt:SetSize( 100, 30 )
butt.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue button
end
function butt:DoClick()
RunConsoleCommand("flamethrower")
end
but:SetParent( Frame )
but:SetText( "Nothing for now" )
but:SetTextColor( Color( 255, 255, 255 ) )
but:SetPos( 12, 25 )
but:SetSize( 90, 30 )
but.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue button
end
function but:DoClick()
RunConsoleCommand("test")
end
end
net.Receive( "openplz", dermaShop )
[/code][/QUOTE]
thanks man and i am sorry i shall localize my functions
Sorry, you need to Log In to post a reply to this thread.