I keep on getting this errors.
[code]
[ERROR] A runtime error has occurred in "gamemodes/darkrp/gamemode/modules/base/sv_entityvars.lua" on line 57.
The best help I can give you is this:
Warning! DarkRPVar 'Energy' wasn't registered!
Please contact the author of the DarkRP Addon to fix this.
Until this is fixed you don't need to worry about anything. Everything will keep working.
It's just that registering DarkRPVars would make DarkRP faster.
Hints:
- No hints, sorry.
The responsibility for this error lies with (the authors of) one (or more) of these files:
1. gamemodes/darkrp/gamemode/modules/base/sv_entityvars.lua on line 57
2. gamemodes/darkrp/entities/entities/food/init.lua on line 33
------- End of Simplerr error -------
[ERROR] A runtime error has occurred in "gamemodes/darkrp/gamemode/libraries/fn.lua" on line 80.
The best help I can give you is this:
Attempt to call Name/Nick/GetName on a non-existing player!
Hints:
- No hints, sorry.
The responsibility for this error lies with (the authors of) one (or more) of these files:
1. gamemodes/darkrp/gamemode/libraries/fn.lua on line 80
2. gamemodes/darkrp/gamemode/modules/base/sh_entityvars.lua on line 105
3. addons/enforcer/lua/autorun/server/enforcer.lua on line 561
------- End of Simplerr error -------
[/code]
Show us fn.lua and sv_entityvars.lua
sv_entityvars.lua
[code]
local maxId = 0
local DarkRPVars = {}
local DarkRPVarById = {}
-- the amount of bits assigned to the value that determines which DarkRPVar we're sending/receiving
local DARKRP_ID_BITS = 8
local UNKNOWN_DARKRPVAR = 255 -- Should be equal to 2^DARKRP_ID_BITS - 1
DarkRP.DARKRP_ID_BITS = DARKRP_ID_BITS
function DarkRP.registerDarkRPVar(name, writeFn, readFn)
maxId = maxId + 1
-- UNKNOWN_DARKRPVAR is reserved for unknown values
if maxId >= UNKNOWN_DARKRPVAR then DarkRP.error(string.format("Too many DarkRPVar registrations! DarkRPVar '%s' triggered this error", name), 2) end
DarkRPVars[name] = {id = maxId, name = name, writeFn = writeFn, readFn = readFn}
DarkRPVarById[maxId] = DarkRPVars[name]
end
-- Unknown values have unknown types and unknown identifiers, so this is sent inefficiently
local function writeUnknown(name, value)
net.WriteUInt(UNKNOWN_DARKRPVAR, 8)
net.WriteString(name)
net.WriteType(value)
end
-- Read the value of a DarkRPVar that was not registered
local function readUnknown()
return net.ReadString(), net.ReadType(net.ReadUInt(8))
end
local warningsShown = {}
local function warnRegistration(name)
if warningsShown[name] then return end
warningsShown[name] = true
DarkRP.errorNoHalt(string.format([[Warning! DarkRPVar '%s' wasn't registered!
Please contact the author of the DarkRP Addon to fix this.
Until this is fixed you don't need to worry about anything. Everything will keep working.
It's just that registering DarkRPVars would make DarkRP faster.]], name), 4)
end
function DarkRP.writeNetDarkRPVar(name, value)
local DarkRPVar = DarkRPVars[name]
if not DarkRPVar then
warnRegistration(name)
return writeUnknown(name, value)
end
net.WriteUInt(DarkRPVar.id, DARKRP_ID_BITS)
return DarkRPVar.writeFn(value)
end
function DarkRP.writeNetDarkRPVarRemoval(name)
local DarkRPVar = DarkRPVars[name]
if not DarkRPVar then
warnRegistration(name)
net.WriteUInt(UNKNOWN_DARKRPVAR, 8)
net.WriteString(name)
return
end
net.WriteUInt(DarkRPVar.id, DARKRP_ID_BITS)
end
function DarkRP.readNetDarkRPVar()
local DarkRPVarId = net.ReadUInt(DARKRP_ID_BITS)
local DarkRPVar = DarkRPVarById[DarkRPVarId]
if DarkRPVarId == UNKNOWN_DARKRPVAR then
local name, value = readUnknown()
return name, value
end
local val = DarkRPVar.readFn(value)
return DarkRPVar.name, val
end
function DarkRP.readNetDarkRPVarRemoval()
local id = net.ReadUInt(DARKRP_ID_BITS)
return id == 255 and net.ReadString() or DarkRPVarById[id].name
end
-- The money is a double because it accepts higher values than Int and UInt, which are undefined for >32 bits
DarkRP.registerDarkRPVar("money", net.WriteDouble, net.ReadDouble)
DarkRP.registerDarkRPVar("salary", fp{fn.Flip(net.WriteInt), 32}, fp{net.ReadInt, 32})
DarkRP.registerDarkRPVar("rpname", net.WriteString, net.ReadString)
DarkRP.registerDarkRPVar("job", net.WriteString, net.ReadString)
DarkRP.registerDarkRPVar("HasGunlicense", net.WriteBit, fc{tobool, net.ReadBit})
DarkRP.registerDarkRPVar("Arrested", net.WriteBit, fc{tobool, net.ReadBit})
DarkRP.registerDarkRPVar("wanted", net.WriteBit, fc{tobool, net.ReadBit})
DarkRP.registerDarkRPVar("wantedReason", net.WriteString, net.ReadString)
DarkRP.registerDarkRPVar("agenda", net.WriteString, net.ReadString)
/*---------------------------------------------------------------------------
RP name override
---------------------------------------------------------------------------*/
local pmeta = FindMetaTable("Player")
pmeta.SteamName = pmeta.SteamName or pmeta.Name
function pmeta:Name()
if not self:IsValid() then DarkRP.error("Attempt to call Name/Nick/GetName on a non-existing player!", SERVER and 1 or 2) end
return GAMEMODE.Config.allowrpnames and self:getDarkRPVar("rpname")
or self:SteamName()
end
pmeta.GetName = pmeta.Name
pmeta.Nick = pmeta.Name
[/code]
fn.lua
[code]
/*---------------------------------------------------------------------------
Functional library
by FPtje Atheos
---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
Function currying
Take a function with n parameters.
Currying is the procedure of storing k < n parameters "in the function"
in such a way that the remaining function can be called with n - k parameters
Example:
DebugPrint = fp{print, "[DEBUG]"}
DebugPrint("TEST")
> [DEBUG] TEST
---------------------------------------------------------------------------*/
function fp(tbl)
local func = tbl[1]
return function(...)
local fnArgs = {}
local arg = {...}
local tblN = table.maxn(tbl)
for i = 2, tblN do fnArgs[i - 1] = tbl[i] end
for i = 1, table.maxn(arg) do fnArgs[tblN + i - 1] = arg[i] end
return func(unpack(fnArgs, 1, table.maxn(fnArgs)))
end
end
local unpack = unpack
local table = table
local pairs = pairs
local ipairs = ipairs
local error = error
local math = math
local select = select
local _G = _G
local fp = fp
module("fn")
/*---------------------------------------------------------------------------
Parameter manipulation
---------------------------------------------------------------------------*/
Id = function(...) return ... end
Flip = function(f)
if not f then error("not a function") end
return function(b, a, ...)
return f(a, b, ...)
end
end
-- Definition from http://lua-users.org/wiki/CurriedLua
ReverseArgs = function(...)
--reverse args by building a function to do it, similar to the unpack() example
local function reverse_h(acc, v, ...)
if select('#', ...) == 0 then
return v, acc()
else
return reverse_h(function () return v, acc() end, ...)
end
end
-- initial acc is the end of the list
return reverse_h(function () return end, ...)
end
/*---------------------------------------------------------------------------
Misc functions
---------------------------------------------------------------------------*/
-- function composition
Compose = function(funcs)
return function(...)
local res = {...}
for i = #funcs, 1, -1 do
res = {funcs[i](unpack(res))}
end
return unpack(res)
end
end
_G.fc = Compose
-- Definition from http://lua-users.org/wiki/CurriedLua
Curry = function(func, num_args)
if not num_args then error("Missing argument #2: num_args") end
if not func then error("Function does not exist!", 2) end
-- helper
local function curry_h(argtrace, n)
if n == 0 then
-- reverse argument list and call function
return func(ReverseArgs(argtrace()))
else
-- "push" argument (by building a wrapper function) and decrement n
return function(x)
return curry_h(function() return x, argtrace() end, n - 1)
end
end
end
-- no sense currying for 1 arg or less
if num_args > 1 then
return curry_h(function() return end, num_args)
else
return func
end
end
-- Thanks Lexic!
Partial = function(func, ...)
local args = {...}
return function(...)
return func(unpack(table.Add( args, {...})))
end
end
Apply = function(f, ...) return f(...) end
Const = function(a, b) return a end
Until = function(cmp, fn, val)
if cmp(val) then
return val
end
return Until(cmp, fn, fn(val))
end
Seq = function(f, x) f(x) return x end
GetGlobalVar = function(key) return _G[key] end
/*---------------------------------------------------------------------------
Mathematical operators and functions
------------------------------------------------------
Sorry, you need to Log In to post a reply to this thread.