• tblInfo a nil Value ?!
    9 replies, posted
Hello Guys I have scripting this I become here Errors [ERROR] gamemodes/underdone/gamemode/core/serverfiles/sv_ai.lua:152: attempt to index global 'tblInfo' (a nil value)   1. unknown - gamemodes/underdone/gamemode/core/serverfiles/sv_ai.lua:152    2. FireBullets - [C]:-1     3. WeaponAttack - gamemodes/underdone/entities/weapons/weapon_primaryweapon/shared.lua:257      4. unknown - gamemodes/underdone/entities/weapons/weapon_primaryweapon/shared.lua:97 My Script local tbl_foods = {         ["item_bananaseed"] = true,         ["item_orangeseed"] = true,     }             print( "pairs:" )     if entKiller:GetInfoNum( "ud_fruitautoloot", 0 ) == 1  then         for strItem, tblInfo in pairs(tbl_foods) do             print (tbl_foods,tblInfo)         end             local tblItemTable = ItemTable(tbl_foods)             if npcTarget:GetLevel() >= (tblInfo.MinLevel or 0) then                 if !tblItemTable.QuestItem or (entKiller:GetQuest(tblItemTable.QuestItem) && !entKiller:HasCompletedQuest(tblItemTable.QuestItem)) then                     tbl_foods, tblInfo = entKiller:CallSkillHook("drop_mod", tbl_foods, tblInfo)                     local intChance = (tblInfo.Chance or 0) * (1 + (entKiller:GetStat("stat_luck") / 45))                     local ItemChance = 60 / math.Clamp(intChance, 0, 100)                     if math.random(1, (ItemChance or 60)) == 1 then                         local intAmount = math.random(tblInfo.Min or 1, tblInfo.Max or tblInfo.Min or 1)                         entKiller:AddItem(tbl_foods, intAmount, GetMaxWeight,npcTarget:GetPos() + Vector(0, 0, 30))                         entKiller:CreateNotification(" You get the item in the inventory " .. tostring(intAmount) .. " " .. tblItemTable.PrintName)                     end                 end             end // This is for my Scared Underdone RPG Server And Standalone is this on the Script Original under ) for strItem, tblInfo in pairs(tblNPCTable.Drops or {}) do             local tblItemTable = ItemTable(strItem)             -- 244132089             if npcTarget:GetLevel() >= (tblInfo.MinLevel or 0) then                 if !tblItemTable.QuestItem or (entKiller:GetQuest(tblItemTable.QuestItem) && !entKiller:HasCompletedQuest(tblItemTable.QuestItem)) then                     strItem, tblInfo = entKiller:CallSkillHook("drop_mod", strItem, tblInfo)                     local intChance = (tblInfo.Chance or 0) * (1 + (entKiller:GetStat("stat_luck") / 45))                     local ItemChance = 100 / math.Clamp(intChance, 0, 100)                     if math.random(1, (ItemChance or 100)) == 1 then                         local intAmount = math.random(tblInfo.Min or 1, tblInfo.Max or tblInfo.Min or 1)                         local entLoot = CreateWorldItem(strItem, intAmount, npcTarget:GetPos() + Vector(0, 0, 30))                         entLoot:SetOwner(entKiller)                         local phyLootPhys = entLoot:GetPhysicsObject()                         if !IsValid(phyLootPhys) && IsValid(entLoot.Grip) then phyLootPhys = entLoot.Grip:GetPhysicsObject() end                         phyLootPhys:Wake()                         phyLootPhys:ApplyForceCenter(Vector(math.random(-100, 100), math.random(-100, 100), math.random(350, 400)))                     end                 end             end         end
Can you atleast show us which line causes the error?
Hi @Gonzo my Script! New and Edited Erros: tblNPCTable.Drops if entKiller:GetInfoNum( "ud_fruitautoloot", 0 ) == 1  then         for tbl_foods, tblInfo in pairs(tblNPCTable.Drops or {}) do             local tblItemTable = ItemTable(tbl_foods)             if npcTarget:GetLevel() >= (tblInfo.MinLevel or 0) then                 if !tblItemTable.QuestItem or (entKiller:GetQuest(tblItemTable.QuestItem) && !entKiller:HasCompletedQuest(tblItemTable.QuestItem)) then                     tbl_foods, tblInfo = entKiller:CallSkillHook("drop_mod", tbl_foods, tblInfo)                     local intChance = (tblInfo.Chance or 0) * (1 + (entKiller:GetStat("stat_luck") / 45))                     local ItemChance = 60 / math.Clamp(intChance, 0, 100)                     if math.random(1, (ItemChance or 60)) == 1 then                         local intAmount = math.random(tblInfo.Min or 1, tblInfo.Max or tblInfo.Min or 1)                         entKiller:AddItem(tbl_foods, intAmount, GetMaxWeight,npcTarget:GetPos() + Vector(0, 0, 30))                         entKiller:CreateNotification(" You get the item in the inventory " .. tostring(intAmount) .. " " .. tblItemTable.PrintName)                     end                 end             end --the Table is not Works -- I want Custom Drop System you know this why you have me other Help https://gmod.facepunch.com/f/gmoddev/owkr/table-HasValue-not-Works/1/ this is ever Underdone i hope you can me Help // I create This local tbl_foods = {         ["item_bananaseed"] = true,         ["item_orangeseed"] = true,     }        //and this if entKiller:GetInfoNum( "ud_fruitautoloot", 0 ) == 1  then         for tbl_foods, tblInfo in pairs(tblNPCTable.Drops or {}) do             local tblItemTable = ItemTable(tbl_foods)             if npcTarget:GetLevel() >= (tblInfo.MinLevel or 0) then                 if !tblItemTable.QuestItem or (entKiller:GetQuest(tblItemTable.QuestItem) && !entKiller:HasCompletedQuest(tblItemTable.QuestItem)) then                     tbl_foods, tblInfo = entKiller:CallSkillHook("drop_mod", tbl_foods, tblInfo)                     local intChance = (tblInfo.Chance or 0) * (1 + (entKiller:GetStat("stat_luck") / 45))                     local ItemChance = 60 / math.Clamp(intChance, 0, 100)                     if math.random(1, (ItemChance or 60)) == 1 then                         local intAmount = math.random(tblInfo.Min or 1, tblInfo.Max or tblInfo.Min or 1)                         entKiller:AddItem(tbl_foods, intAmount, GetMaxWeight,npcTarget:GetPos() + Vector(0, 0, 30))                         entKiller:CreateNotification(" You get the item in the inventory " .. tostring(intAmount) .. " " .. tblItemTable.PrintName)                     end                 end             end // by tblNPCTable.Drops is shit i want my tbl_foods for Custom Drop Items here is Original Script for strItem, tblInfo in pairs(tblNPCTable.Drops or {}) do             local tblItemTable = ItemTable(strItem)             -- 244132089             if npcTarget:GetLevel() >= (tblInfo.MinLevel or 0) then                 if !tblItemTable.QuestItem or (entKiller:GetQuest(tblItemTable.QuestItem) && !entKiller:HasCompletedQuest(tblItemTable.QuestItem)) then                     strItem, tblInfo = entKiller:CallSkillHook("drop_mod", strItem, tblInfo)                     local intChance = (tblInfo.Chance or 0) * (1 + (entKiller:GetStat("stat_luck") / 45))                     local ItemChance = 100 / math.Clamp(intChance, 0, 100)                     if math.random(1, (ItemChance or 100)) == 1 then                         local intAmount = math.random(tblInfo.Min or 1, tblInfo.Max or tblInfo.Min or 1)                         local entLoot = CreateWorldItem(strItem, intAmount, npcTarget:GetPos() + Vector(0, 0, 30))                         entLoot:SetOwner(entKiller)                         local phyLootPhys = entLoot:GetPhysicsObject()                         if !IsValid(phyLootPhys) && IsValid(entLoot.Grip) then phyLootPhys = entLoot.Grip:GetPhysicsObject() end                         phyLootPhys:Wake()                         phyLootPhys:ApplyForceCenter(Vector(math.random(-100, 100), math.random(-100, 100), math.random(350, 400)))                     end                 end             end         end
You gonna be completly crazy if you think anyone here would take the time to debug all that code
@Gonzo the Line is for tbl_foods, tblInfo in pairs(tblNPCTable.Drops or {}) do tblNPCTable.Drops cant i chance to my local tbl_foods = { "", }
You're trying to use tbl_food when you named the table tbl_foods
@Invule thanks i know i have other Problems I want to drop banana seeds but nothing happens I do not want to have any items in the inventory other than this banana seed and all my Script Functions is not works -.- And almost no one here helps because everyone has no idea
Nobody is going to help you because nobody can understand what you are trying to say, and it looks like you do not even understand what that code is doing. Not trying to sound like an asshole, but you are not going to get much help here, sorry.
@Gmod4phun i want a Function for Custom OnKillNPC Items
Then make one yourself. Seriously, this is a help forum for stuff that YOU make, not taking a script from somewhere and asking people 'do this for me, do that for me'.
Sorry, you need to Log In to post a reply to this thread.