Console Variables not editable by clients on dedicated servers
4 replies, posted
Hello, I've been trying to patch a strange bug I found a while ago in one of my addons, however I simply cannot figure out what im doing wrong so here I am.
The bug only occurs in dedicated servers, the bug itself is that server side convars can not be edited outside of the servers console, which is problematic as the addon uses a derma menu for admins to change what they need to.
Heres the code which creates the convars, located in lua/autorun/server:
[CODE]if GetConVar("scp_infect_range") == nil then
CreateConVar("scp_infect_range", "100", { FCVAR_REPLICATED, FCVAR_ARCHIVE } )
end
if GetConVar("scp_infect_time") == nil then
CreateConVar("scp_infect_time", "15", { FCVAR_REPLICATED, FCVAR_ARCHIVE } )
end[/CODE]
If code for the client menu is needed, I can provide it, but it is rather lengthy.
Cheers in advance to anyone who can lend a hand <3
Why would clients be able to edit server variables? Create the commands on the client with CreateClientConVar.
[del]1. Your code snippet is about creating nonexistent convars, not about changing existing convars.[/del] Edit: reading the OP again, you know that already. Whoops.
2. If you want a client to be able to change server variables, you'll have to do it like this:
[lua]-- on the server
net.Receive("Change ConVar", function(len, ply)
if not ply:IsAdmin() then return end
local convar = net.ReadString()
local value = net.ReadString()
RunConsoleCommand(convar, value)
end[/lua]
Untested. The other parts are left as an exercise for the reader.
[QUOTE=Sean Bean;52264185]Why would clients be able to edit server variables? Create the commands on the client with CreateClientConVar.[/QUOTE]
Unless you want some clients to edit serverside variables, in which case you will need to use the [URL="http://wiki.garrysmod.com/page/Category:net"]net library[/URL]
Ninja'd :v:
Alrighty, cheers for the help guys, the menu's all fixed now ^_^
Sorry, you need to Log In to post a reply to this thread.