I am working on a white list for an armory add-on; however, I have run into a road block. My issue is that it is expecting a number and it's getting nil.
for k, v in pairs(CustomShipments) do
if v.ArmoryWhiteList then
table.CopyFromTo(CustomShipments, WhiteList)
print("Adding "..v.entity.." to the Armory WhiteList")
else
print(v.entity.." was BlackListed from the Armory")
end
end
The code above is ran during PostGamemodeLoaded and the shipments that have ArmoryWhiteList set to true are correctly printing out in console, as is the "BlackListed" items. I have set every v.ArmoryWhiteList to a value of true or false. One example is below.
AddCustomShipment("[Assault Rifle] AK-47", {
model = "models/weapons/w_ak47_m9k.mdl",
entity = "m9k_ak47",
price = 25000,
amount = 10,
separate = true,
pricesep = 2500,
ArmoryWhiteList = true,
noship = false,
allowed = {TEAM_GUN},
})
Add-on list check:
if table.Empty(WhiteList) then
for k,v in pairs(CustomShipments) do
foundKey = math.random(table.Count(CustomShipments))
end
else
for k,v in pairs(WhiteList) do
foundKey = math.random(table.Count(WhiteList))
end
end
I have been working on this all night, I am not simply looking for a "This is how you fix it." I am looking for an explanation of why my code does not function. I feel like I will make this mistake again if I am left uninformed. Thank you for your time.
Are you getting a script error anywhere?
Also, when you do table.CopyFromTo that copies the entire table, not just that one value.
Badger, it's throwing a fit because of something else; however, I am actually just looking for a way to add each list instead of everything inside of the list.
To begin with, table.Empty empties the table and it always returns no value.
Also, you're not telling us what is nil where it's not supposed to and on what line it happens.
Sorry, you need to Log In to post a reply to this thread.