• Dev chat to all players
    8 replies, posted
I have this client side script i made and i want to be able to add it to my server, What it does is allow me to type a message in the box and send it to all players chat box in red text with a alert of a update or something else to do with the server being edited this is what i have: [CODE] concommand.Add("DevNoteMenu", function() local Frame = vgui.Create("DFrame") Frame:SetPos(ScrW()/2-200, ScrH()/2-50) Frame:SetSize(400, 100) Frame:SetTitle("Dev Chat Window") Frame:ShowCloseButton(true) Frame:SetDraggable(false) Frame:MakePopup() local TextBox = vgui.Create("DTextEntry", Frame) TextBox:SetPos(2, Frame:GetTall()/2-10) TextBox:SetSize(Frame:GetWide()-4, 20) TextBox:SetText("") local SendButton = vgui.Create("DButton", Frame) SendButton:SetPos(2, Frame:GetTall()-40) SendButton:SetSize(Frame:GetWide()-4, 20) SendButton:SetText("Send Dev Note") SendButton.DoClick = function() DevNote = TextBox:GetValue() DevChat() end end) function DevChat() chat.AddText(Color(255,0,0), DevNote) end [/CODE] Im not sure how to make the string from the textbox send from my client to the server and back to all clients.
[URL="http://wiki.garrysmod.com/page/Net_Library_Usage"]Net Messages[/URL]
or you could try use like: [url]http://wiki.garrysmod.com/page/GM/OnPlayerChat[/url] clientside only, and check if message start with for example § character and your steam id is the poster, then make message red
[QUOTE=Lolcats;47847387][URL="http://wiki.garrysmod.com/page/Net_Library_Usage"]Net Messages[/URL][/QUOTE] Please remember to use a SteamID or IsSuperAdmin or something check serverside to prevent random players from sending notifications.
What am i doing wrong here? the file wont load autorun.lua [CODE]util.AddNetworkString("DevChatMsg") AddCSLuaFile("devmsg.lua") include("devmsg.lua")[/CODE] devmsg.lua [CODE]concommand.Add("DevNoteMenu", function() if LocalPlayer():SteamID64() == "76561198085352917" then DevMenu() else print("You are not on the npc whitelist") end end) function DevMenu() local Frame = vgui.Create("DFrame") Frame:SetPos(ScrW()/2-200, ScrH()/2-50) Frame:SetSize(400, 100) Frame:SetTitle("Dev Chat Window") Frame:ShowCloseButton(true) Frame:SetDraggable(false) Frame:MakePopup() local TextBox = vgui.Create("DTextEntry", Frame) TextBox:SetPos(2, Frame:GetTall()/2-10) TextBox:SetSize(Frame:GetWide()-4, 20) TextBox:SetText("") local SendButton = vgui.Create("DButton", Frame) SendButton:SetPos(2, Frame:GetTall()-40) SendButton:SetSize(Frame:GetWide()-4, 20) SendButton:SetText("Send Dev Note") SendButton.DoClick = function() net.Start("DevChatMsg") net.WriteString(TextBox:Value()) net.Send( ply ) end end net.Receive("DevChatMsg", function() local DevNote = TextBox:Value() chat.AddText(Color(255,0,0), "Devloper: ".. DevNote) end)[/CODE]
[QUOTE=zippy36jr;47848468]What am i doing wrong here? the file wont load autorun.lua [CODE]util.AddNetworkString("DevChatMsg") AddCSLuaFile("devmsg.lua") include("devmsg.lua")[/CODE] devmsg.lua [CODE]concommand.Add("DevNoteMenu", function() if LocalPlayer():SteamID64() == "76561198085352917" then DevMenu() else print("You are not on the npc whitelist") end end) function DevMenu() local Frame = vgui.Create("DFrame") Frame:SetPos(ScrW()/2-200, ScrH()/2-50) Frame:SetSize(400, 100) Frame:SetTitle("Dev Chat Window") Frame:ShowCloseButton(true) Frame:SetDraggable(false) Frame:MakePopup() local TextBox = vgui.Create("DTextEntry", Frame) TextBox:SetPos(2, Frame:GetTall()/2-10) TextBox:SetSize(Frame:GetWide()-4, 20) TextBox:SetText("") local SendButton = vgui.Create("DButton", Frame) SendButton:SetPos(2, Frame:GetTall()-40) SendButton:SetSize(Frame:GetWide()-4, 20) SendButton:SetText("Send Dev Note") SendButton.DoClick = function() net.Start("DevChatMsg") net.WriteString(TextBox:Value()) net.Send( ply ) end end net.Receive("DevChatMsg", function() local DevNote = TextBox:Value() chat.AddText(Color(255,0,0), "Devloper: ".. DevNote) end)[/CODE][/QUOTE] Where are your files placed? Also, check if the player can send the dev message serverside, not clientside. And why are you including devmsg.lua serverside?
The concommand is not working in console and they are placed in a folder with autorun.lua being in the autorun folder (pic) [url]http://gyazo.com/c34fab790678b05a06f3393b1969de03[/url]
You're sending the net message to a non existent ply when it should go to the server, then a server Broadcast()'s the message after authorization.
[code] if (SERVER) then util.AddNetworkString("DevNote") net.Receive("DevNote", function(len, ply) if (ply:SteamID64() != "76561198085352917") then return end local message = net.ReadString() net.Start("DevNote") net.WriteString(message) net.Broadcast() end) end if (CLIENT) then net.Receive("DevNote", function() local message = net.ReadString() chat.AddText(Color(255, 255, 255), message) end) local function DevMenu() if (LocalPlayer():SteamID64() != "76561198085352917") then return end local Frame = vgui.Create("DFrame") Frame:SetPos(ScrW()/2-200, ScrH()/2-50) Frame:SetSize(400, 100) Frame:SetTitle("Dev Chat Window") Frame:ShowCloseButton(true) Frame:SetDraggable(false) Frame:MakePopup() local TextBox = vgui.Create("DTextEntry", Frame) TextBox:SetPos(2, Frame:GetTall()/2-10) TextBox:SetSize(Frame:GetWide()-4, 20) TextBox:SetText("") local SendButton = vgui.Create("DButton", Frame) SendButton:SetPos(2, Frame:GetTall()-40) SendButton:SetSize(Frame:GetWide()-4, 20) SendButton:SetText("Send Dev Note") SendButton.DoClick = function() net.Start("DevNote") net.WriteString(TextBox:GetValue()) net.SendToServer() end end concommand.Add("DevNoteMenu", DevMenu) end [/code] All of it goes in one file. Put it in lua/autorun. If you need further clarification, feel free to add me on Steam.
Sorry, you need to Log In to post a reply to this thread.