Having this error when I run my gamemode.
[ERROR]
gamemodes/rp/gamemode/cl_init.lua:910: attempt to index field 'Config' (a nil value)
1. unknown - gamemodes/rp/gamemode/cl_init.lua:910
config
is a table, with index's such as config["Run Speed"]
and the entire table is set globally equal to GM.Config in the sh_config.lua file. Why is config not being registered as a value? Must I include the config file into the cl_init file? and if so, how? Using the include()?
function GM:Think()
if ( self.Config["Local Voice"] ) then **--Referred line(910)**
for k, v in pairs( player.GetAll() ) do
if ( hook.Call("PlayerCanVoice",GAMEMODE, v) ) then
if ( v:IsMuted() ) then v:SetMuted(); end
else
if ( !v:IsMuted() ) then v:SetMuted(); end
end
end
end
-- Call the base class function.
return self.BaseClass:Think();
end
Edit -- config table in sh_config.lua.
local config = {};
-- Command
config["Command Prefix"] = "/"; -- The prefix that is used for chat commands.
config["Maximum Notes"] = 2; -- Maximum notes per player
config["Advert Cost"] = 60; -- The money that it costs to advertise.
config["Advert Timeout"] = 150 -- How many seconds between adverts
config["OOC Timeout"] = 60 -- How many seconds between OOC messages
config["Item Timer"] = 7 -- How many seconds between item uses
config["Item Timer (S)"] = 20 -- How many seconds between specific item uses
config["Note Fade Speed"] = 12 -- How many minutes before nots disappear
-- Voice
config["Local Voice"] = true; -- Players can only hear a player's voice if they are near them. This is the index being called which is creating an error.
config["Talk Radius"] = 256; -- The radius of each player that
--other players have to be in to hear them talk (units).
-- Player Stuff
config["Walk Speed"] = 150; -- The speed that players walk at.
config["Run Speed"] = 275; -- The speed that players run at.
GM.Config = config;
I have includecs("sh_config.lua");
in sh_init.lua. include("sh_config.lua")
and AddCSLuaFile("sh_config.lua")
in init.lua. and include("sh_config.lua");
in cl_init.lua.
Im still getting this stupid error though. Can someone explain what the difference between including and Addcs'ing a file does. How do I make sh_config's variables global in other files? Or in other words how do I make the desired file(cl_init) read through the code in sh_config.lua and I can use code from it in the client side init?