Gmod update broke stronghold pls help!

The new gmod update broke the stronghold gamemode that roaring cow made and i am hear to seek help after cow refused to fix it.

The error is

[ERROR] gamemodes/stronghold/gamemode/sh_compat.lua:15: attempt to call method ‘GetNetworkedVar’ (a nil value)

  1. GetOwnerEnt - gamemodes/stronghold/gamemode/sh_compat.lua:15
  2. GetPlayerColor - gamemodes/stronghold/gamemode/entity_extension.lua:31
    3. bind - lua/matproxy/player_color.lua:28
    4. unknown - lua/includes/modules/matproxy.lua:56

And this is the lua file which is the problem

FORCE_STRING, FORCE_NUMBER, FORCE_BOOL = 1, 2, 3
function AccessorFuncNW( tab, varname, name, varDefault, iForce )
tab[ “Get”…name ] = function( self ) return self:GetNetworkedVar( varname, varDefault ) end

if iForce == FORCE_STRING then
	tab[ "Set"..name ] = function( self, v ) self:SetNetworkedVar( varname, tostring(v) ) end
elseif iForce == FORCE_NUMBER then
	tab[ "Set"..name ] = function( self, v ) self:SetNetworkedVar( varname, tonumber(v) ) end
elseif iForce == FORCE_BOOL then
	tab[ "Set"..name ] = function( self, v ) self:SetNetworkedVar( varname, tobool(v) ) end
else
	tab[ "Set"..name ] = function( self, v ) self:SetNetworkedVar( varname, v ) end
end

end

I appreciate any help you guys can offer <3

Set/GetNetworkedVar were removed. You need to replace them with the type specific variants.

i know they were removed and i have tried setting them to the GetNWint and SetNWint with no success

But some aren’t ints. Some listed there are bools and strings.

so i should be changing the force_bool and the tobool etc. to NWBool??

ps. i’m still only learning lua so i need guidance

Yes, use the type related functions. You might need to change any GetNetworkedVar functions to GetNWWhatever as well.

I’ve tried but im still getting the same error except its GetNWint now :confused:

Here’s the code updated I guess

FORCE_NWSTRING, FORCE_NUMBER, FORCE_NWBOOL = 1, 2, 3
function AccessorFuncNW( tab, varname, name, varDefault, iForce )
tab[ “Get”…name ] = function( self ) return self:GetNWint( varname, varDefault ) end

if iForce == FORCE_NWSTRING then
	tab[ "Set"..name ] = function( self, v ) self:SetNWint( varname, toNWstring(v) ) end
elseif iForce == FORCE_NUMBER then
	tab[ "Set"..name ] = function( self, v ) self:SetNWint( varname, tonumber(v) ) end
elseif iForce == FORCE_NWBOOL then
	tab[ "Set"..name ] = function( self, v ) self:SetNWint( varname, toNWbool(v) ) end
else
	tab[ "Set"..name ] = function( self, v ) self:SetNWint( varname, v ) end
end

end

tostring, not toNWString



FORCE_NWSTRING, FORCE_NUMBER, FORCE_NWBOOL = 1, 2, 3
function AccessorFuncNW( tab, varname, name, varDefault, iForce )

    if iForce == FORCE_NWSTRING then
        tab[ "Set" .. name ] = function( self, v ) self:SetNWString( varname, tostring( v ) ) end
        tab[ "Get" .. name ] = function( self ) return self:GetNWString( varname, varDefault ) end
    elseif iForce == FORCE_NWBOOL then
        tab[ "Set" .. name ] = function( self, v ) self:SetNWBool( varname, tobool( v ) ) end
        tab[ "Get" .. name ] = function( self ) return self:GetNWBool( varname, varDefault ) end
    else // Fallback to number
        tab[ "Set" .. name ] = function( self, v ) self:SetNWFloat( varname, tonumber( v ) ) end
        tab[ "Get" .. name ] = function( self ) return self:GetNWFloat( varname, varDefault ) end
    end
end

Thanks robot that worked now its time for me to fix everything else that doesnt involve networking