Error:
[ERROR] gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua:185: attempt to index a string value with bad key ('function: 0x31e1ad80' is not part of the string library)
1. checkValid - gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua:185
2. createCategory - gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua:999
[B]Pastebin of my sh_createitems folder:[/B] [url]http://pastebin.com/5daXSUvh[/url]
[CODE]local plyMeta = FindMetaTable("Player")
-- automatically block players from doing certain things with their DarkRP entities
local blockTypes = {"Physgun1", "Spawning1", "Toolgun1"}
-- Assert function, asserts a property and returns the error if false.
-- Allows f to override err and hints by simply returning them
local ass = function(f, err, hints) return function(...)
local res = {f(...)}
table.insert(res, err)
table.insert(res, hints)
return unpack(res)
end end
-- Returns whether a value is nil
local isnil = fn.Curry(fn.Eq, 2)(nil)
-- Optional value, when filled in it must meet the conditions
local optional = function(...) return fn.FOr{isnil, ...} end
-- Check the correctness of a model
local checkModel = isstring
-- A table of which each element must meet condition f
local tableOf = function(f) return function(tbl)
if not istable(tbl) then return false end
for k,v in pairs(tbl) do if not f(v) then return false end end
return true
end end
-- Any of the given elements
local oneOf = function(f) return fp{table.HasValue, f} end
-- A table that is nonempty, wrap around tableOf
local nonempty = function(f) return function(tbl) return istable(tbl) and #tbl > 0 and f(tbl) end end
-- A value must be unique amongst all `kind`. Uses optional `hash` function to create custom hashes in the internal table
local uniqueEntity = function(cmd, tbl)
for k, v in pairs(DarkRPEntities) do
if v.cmd ~= cmd then continue end
return false, "This entity does not have a unique command.", {"There must be some other end that has the same thing for 'cmd'.", "Fix this by changing the 'cmd' field of your entity to something else."}
end
return true
end
local uniqueJob = function(v, tbl)
local job = DarkRP.getJobByCommand(v)
if job then return false, "This job does not have a unique command.", {"There must be some other job that has the same command.", "Fix this by changing the 'command' of your job to something else."} end
return true
end
-- Template for a correct job
local requiredTeamItems = {
color = ass(tableOf(isnumber), "The color must be a Color value.", {"Color values look like this: Color(r, g, b, a), where r, g, b and a are numbers between 0 and 255."}),
model = ass(fn.FOr{checkModel, nonempty(tableOf(checkModel))}, "The model must either be a table of correct model strings or a single correct model string.", {"This error could happens when the model does not exist on the server.", "Are you sure the model path is right?", "Is the model from an addon that is not properly installed?"}),
description = ass(isstring, "The description must be a string."),
weapons = ass(optional(tableOf(isstring)), "The weapons must be a valid table of strings.", {"Example: weapons = {\"med_kit\", \"weapon_bugbait\"},"}),
command = ass(fn.FAnd{isstring, uniqueJob}, "The command must be a string."),
max = ass(fn.FAnd{isnumber, fp{fn.Lte, 0}}, "The max must be a number greater than or equal to zero.", {"Zero means infinite.", "A decimal between 0 and 1 is seen as a percentage."}),
salary = ass(fn.FAnd{isnumber, fp{fn.Lte, 0}}, "The salary must be a number greater than zero."),
admin = ass(fn.FAnd{isnumber, fp{fn.Lte, 0}, fp{fn.Gte, 2}}, "The admin value must be a number greater than or equal to zero and smaller than three."),
vote = ass(optional(isbool), "The vote must be either true or false."),
-- Optional advanced stuff
category = ass(optional(isstring), "The category must be the name of an existing category!"),
sortOrder = ass(optional(isnumber), "The sortOrder must be a number."),
buttonColor = ass(optional(tableOf(isnumber)), "The buttonColor must be a Color value."),
label = ass(optional(isstring), "The label must be a valid string."),
ammo = ass(optional(tableOf(isnumber)), "The ammo must be a table containing numbers.", {"See example on http://wiki.darkrp.com/index.php/DarkRP:CustomJobFields"}),
hasLicense = ass(optional(isbool), "The hasLicense must be either true or false."),
NeedToChangeFrom = ass(optional(tableOf(isnumber), isnumber), "The NeedToChangeFrom must be either an existing team or a table of existing teams", {"Is there a job here that doesn't exist (anymore)?"}),
customCheck = ass(optional(isfunction), "The customCheck must be a function."),
CustomCheckFailMsg = ass(optional(isstring, isfunction), "The CustomCheckFailMsg must be either a string or a function."),
modelScale = ass(optional(isnumber), "The modelScale must be a number."),
maxpocket = ass(optional(isnumber), "The maxPocket must be a number."),
maps = ass(optional(tableOf(isstring)), "The maps value must be a table of valid map names."),
candemote = ass(optional(isbool), "The candemote value must be either true or false."),
mayor = ass(optional(isbool), "The mayor value must be either true or false."),
chief = ass(optional(isbool), "The chief value must be either true or false."),
medic = ass(optional(isbool), "The medic value must be either true or false."),
cook = ass(optional(isbool), "The cook value must be either true or false."),
hobo = ass(optional(isbool), "The hobo value must be either true or false."),
CanPlayerSuicide = ass(optional(isfunction), "The CanPlayerSuicide must be a function."),
PlayerCanPickupWeapon = ass(optional(isfunction), "The PlayerCanPickupWeapon must be a function."),
PlayerDeath = ass(optional(isfunction), "The PlayerDeath must be a function."),
PlayerLoadout = ass(optional(isfunction), "The PlayerLoadout must be a function."),
PlayerSelectSpawn = ass(optional(isfunction), "The PlayerSelectSpawn must be a function."),
PlayerSetModel = ass(optional(isfunction), "The PlayerSetModel must be a function."),
PlayerSpawn = ass(optional(isfunction), "The PlayerSpawn must be a function."),
PlayerSpawnProp = ass(optional(isfunction), "The PlayerSpawnProp must be a function."),
RequiresVote = ass(optional(isfunction), "The RequiresVote must be a function."),
ShowSpare1 = ass(optional(isfunction), "The ShowSpare1 must be a function."),
ShowSpare2 = ass(optional(isfunction), "The ShowSpare2 must be a function."),
canStartVote = ass(optional(isfunction), "The canStartVote must be a function."),
canStartVoteReason = ass(optional(isstring, isfunction), "The canStartVoteReason must be either a string or a function."),
}
-- Template for correct shipment
local validShipment = {
model = ass(checkModel, "The model of the shipment must be a valid model.", {"This error could happens when the model does not exist on the server.", "Are you sure the model path is right?", "Is the model from an addon that is not properly installed?"}),
entity = ass(isstring, "The entity of the shipment must be a string."),
price = ass(function(v, tbl) return isnumber(v) or isfunction(tbl.getPrice) end, "The price must be an existing number or (for advanced users) the getPrice field must be a function