Serverside:
[code]
util.AddNetworkString("Whatever")
hook.Add("PlayerSay", "asd", function(ply, text, teamonly)
if text == whatever then
net.Start("Whatever")
net.Send(ply)
end
end)
[/code]
Clientside:
[code]
net.Receive("Whatever", function()
--your menu code here
end)
[/code]
Thanks, It worked! but i need to know how to load lua file to server and client in same time
[QUOTE=NiandraLades;47664855]Serverside:
[code]snip[/code][/QUOTE]
Or use OnPlayerChat to avoid using a net message.
[code]
if SERVER then
hook.Add("PlayerSay", "DermaCommands", function(ply)
if(string.sub(text, 1, 6) == "/models")then
net.Start("derma_panel_modelsmenu")
net.Send(ply)
end
end)
elseif CLIENT then
function Panel()
local Frame = vgui.Create( "DFrame" )
Frame:SetTitle( "SELECT MODEL" )
Frame:SetSize( 600, 300 )
Frame:SetPos(200,100)
Frame:MakePopup()
Frame:SetDraggable( true )
Frame:ShowCloseButton( true )
Frame.Paint = function( self)
draw.RoundedBox( 0, 0, 0, 600, 300, Color( 0, 0, 0, 200 ) )
local SpawnI = vgui.Create("SpawnIcon")
SpawnI:SetPos(200,100)
SpawnI:SetParent(Frame)
SpawnI:SetModel("models/weapons/w_knife_ct.mdl")
SpawnI.DoClick = function()
SpawnI:Close()
RunConsoleCommand("playermodel_set","models/weapons/w_knife_ct.mdl")
Frame:Close()
end
end
end
net.Receive("derma_panel_modelsmenu", Panel)
end
[/code]
Thats you're full and ending code for that, hope you learn something from it!
The last user's example didn't end the Paint() function and didn't define 'text' and attempted to Close() a spawnicon that should've been Remove()'d, even though it would be automatically if it's parent panel was closed?
[CODE]
if SERVER then
hook.Add("PlayerSay", "DermaCommands", function(ply, text)
if(string.sub(text, 1, 6) == "/models")then
net.Start("derma_panel_modelsmenu")
net.Send(ply)
end
end)
elseif CLIENT then
function Panel()
local Frame = vgui.Create( "DFrame" )
Frame:SetTitle( "SELECT MODEL" )
Frame:SetSize( 600, 300 )
Frame:SetPos(200,100)
Frame:MakePopup()
Frame:SetDraggable( true )
Frame:ShowCloseButton( true )
Frame.Paint = function( self )
draw.RoundedBox( 0, 0, 0, 600, 300, Color( 0, 0, 0, 200 ) )
end
local SpawnI = vgui.Create("SpawnIcon")
SpawnI:SetPos(200,100)
SpawnI:SetParent(Frame)
SpawnI:SetModel("models/weapons/w_knife_ct.mdl")
SpawnI.DoClick = function()
RunConsoleCommand("playermodel_set","models/weapons/w_knife_ct.mdl")
Frame:Close()
end
end
end
net.Receive("derma_panel_modelsmenu", Panel)
[/CODE]
As long as playermodel_set is an existing console command..
By the way, this was adapted from the previous post, but considering it got 3 'dumb' ratings, there's probably some other problem with this which I overlooked.
Thanks alot, its working well!
Sorry, you need to Log In to post a reply to this thread.