• Question about opening a derma panel with networking
    10 replies, posted
Good evening, I tried to create it myself after watching the tutorial from codeblue but its not working. Client: function openFrame() local frame1 = vgui.Create("DFrame") frame1:SetSize(500,300) frame1:Center() frame1:SetVisible(true) frame1:MakePopup() frame1:ShowCloseButton(false) frame1:SetTitle("") frame1.Paint = function(self,w,h) draw.RoundedBox(0,0,0,w ,h,Color(40,40,40))  draw.RoundedBox(0,0,0,w,25,Color(176,23,31)) end Server: util.AddNetworkString("Test1") hook.Add("OnPlayerSay",Open,function(ply,text,public) command = string.lower if (command == "/test") then net.Start("open1") net.Send(ply) end end) Can you help me out? kind regards.
Not adding a net.Receive on the client. Using the wrong net message with net.Start. `command` will always be `function: 0x??????`. Creating a hook without a name using an event that doesn't exist.
Here's an example of what you should be doing. Serverside: util.AddNetworkString("Test_NetMessage") // Register the network string hook.Add("PlayerSay", "Creative_Hook_Name", function(ply, txt) // Hook Start   local lower = string.lower(txt) // Get the text and make it lowercase. Makes it not case-sensitive if(string.Sub(lower, 1, 5) == "/test") then // If the string STARTS with /test net.Start("Test_NetMessage") // Start and send the net message net.Send("Test_NetMessage") end  end) Clientside: net.Receive("Test_NetMessage", function() // Get the net message local frame = vgui.Create("DFrame") // Create the frame frame:SetSize(500, 500) frame:Center() frame:MakePopup() end) Hopefully that gives you a better understanding
That really helped me a lot, but its still not working. I get this error msg: https://files.facepunch.com/forum/upload/309258/de7585c0-5aed-4e6a-8e08-d067c653cd59/Screenshot_69.png Thats my code so far: Server: util.AddNetworkString("openframe") hook.Add("PlayerSay", "openframe", function(ply, txt)   lower = string.lower(txt) if(string.Sub(lower, 1, 5) == "/test") then net.Start("openframe") net.Send("openframe") end end) Client: net.Receive("openframe", function()   frame = vgui.Create("DFrame") frame:MakePopup() frame:SetSize(500, 300) frame:Center() end) Thank you in advance
You're trying to send the net message to a string and not a client. You're also trying to call the function `string.Sub` which doesn't exist, check the gmod wiki if you want to know which function you should use.
Yeah just noticed. Sorry. I'l quickly edit it rn.
Ok guys, so I fixed it all and tried to add something by my own but there is a little issue I can't solve... Code so far: Server: util.AddNetworkString("openuser") util.AddNetworkString("notadmin") hook.Add("PlayerSay", "openframe", function(ply, txt)     local lower = string.lower(txt)     if(string.sub(lower,1,5)=="/test" or "!test") then     if ply:IsAdmin() then     net.Start("openuser")     net.Send(ply)     else     net.Start("notadmin")     net.Send(ply)     return ""     end     end end) Client: net.Receive("openuser", function()   local frame1 = vgui.Create("DFrame") frame1:SetSize(500,300) frame1:Center() frame1:SetVisible(true) frame1:MakePopup() frame1:ShowCloseButton(1) frame1:SetTitle("") frame1.Paint = function(self,w,h) draw.RoundedBox(0,0,0,w ,h,Color(40,40,40))  draw.RoundedBox(0,0,0,w,25,Color(176,23,31)) end buttonsend=vgui.Create("DButton",frame1) buttonsend:SetPos(370,275) buttonsend:SetSize(125,20) buttonsend:SetText("") buttonsend.Paint=function(self,w,h) draw.RoundedBox(0,0,0,w,h,Color(176,23,31)) end local label=vgui.Create("DLabel",buttonsend) label:SetText("send ticket") label:SetFont("LabelFont1") label:SizeToContents(5)  label:Center() label:SetTextColor(Color(255,255,255)) end) net.Receive("notadmin", function() chat.AddText( Color(30,144,255),"You don't have permission for that!") end) If I'm an operator there is no matter if I write "!dfgdfhfgnfghnfg", "nmhj,lklj" or "!test" it still says I dont't have permission for that but I want it to say that just when I write "!test". The same as an admin. When I write gdfg as an admin its opening... I just tried to figure it out for like 2 hours now... I'm sorry for annoy you guys but you're my only solution. Kind regards, lvxye
Because `or` doesn't work like that.What you're basically doing is `if (bool or string) then` which will always pass. You'd have to compare each string individually or do `string.sub(2, 5) == "command"` or use a pattern like in my example.
@SneakySquid , I mostly understand your way but what is the OpenAdminMenu() for? Is there any other way to fix the issue to not use your way?
`OpenAdminMenu` is pretty self-explanatory - that would be where you open your admin menu! And I've already told you how to fix your issue and how to improve your code, if you can't understand what I've told you then you should go learn the basics of Lua (Programming in Lua).
@SneakySquid I just watched a few of videos from this series (https://www.youtube.com/watch?v=qkPjxGsDYPw&list=PLLAN7OC4G99RNqy_RY8s5-V-nA8RBh1cn) and now I could fix it my self. I'm sorry for just asking how to fix it and don't fix it myself. Thank very much!
Sorry, you need to Log In to post a reply to this thread.