LUA ERROR: sys/lua/cs2dtibia/npcs.lua:324: attempt to index field '?' (a nil value) .
Sorry I forgot it .
NPCs = { [1] = {"Jonat", pos={1169, 1105}, rot=180, image="npc1"}, [2] = {"Thomas [Gate]", pos={354, 1939}, rot=180, image="npc9"}, [3] = {"Devil", pos={974, 193}, rot=270, image="npc3", trade={{370,500},{371,600},{372,800},{373,1000},{390,5000},{374,1500}}}, [4] = {"Crazy Man", pos={979, 477}, rot=270, image="npc3", trade={{375,5000},{376,6500},{377,8000},{378,9500},{389,7000},{990,15000},{993,25000}}}, [5] = {"Dragon Rz", pos={940, 766}, rot=270, image="npc3", trade={{380,16000},{381,16000},{995,19000},{388,20000},{383,30000}}}, [6] = {"Hat ", pos={240, 476}, rot=90, image="npc1", trade={{310,500},{311,500},{312,500},{313,500}}}, [7] = {"Medic Seller", pos={1680, 1356}, rot=180, image="npc4", trade={{1,200},{3,100}}}, [8] = {"Needle Cars", pos={120, 1487}, rot=90, image="npc4", trade={{400,50000},{401,50000},{402,50000},{403,50000}}}, [9] = {"Teleport Seller", pos={4910, 436}, rot=270, image="npc5", trade={{100,2000},{101,2000},{-100,1000},{-101,1000}}}, [10] = {"Ammo seller", pos={1516, 864}, rot=270, image="npc5", trade={{18,200},{19,100},{-18,100},{-19,50}}}, [11] = {"Collecter", pos={1153, 1323}, rot=0, image="npc5", trade={{-1000,1000},{-2000,2000},{-5000,5000},{-3000,3000},{-50000,50000},{-80000,80000},{100000,100000}}}, [12] = {"Food's Seller", pos={1680, 1584}, rot=0, image="npc4", trade={{2,150},{997,100},{4,200},{985,250}}}, [13] = {"Armor Seller", pos={1749, 1805}, rot=270, image="npc6", trade={{320,1500},{321,1500},{322,1500},{323,1500},{-320,750},{-321,750},{-322,750},{-323,750}}}, [14] = {"Kalis Man", pos={4322, 243}, rot=180, image="npc4", trade={{382,65000},{386,115000},{994,700000},{992,15000000},{387,165000},{999,15000000},{989,250000}}}, [15] = {"Hat Sourvenir Seller", pos={4882, 764}, rot=270, image="npc1", trade={{314,600},{315,600},{316,600},{317,600},{318,600},{319,600},{899,600}}}, [16] = {"Bed Seller", pos={1024, 4384}, rot=0, image="npc2", trade={{200,500},{201,500},{202,500},{203,500},{-200,250},{-201,250},{-202,250},{-203,250}}}, [17] = {"Chair Seller", pos={1036, 3955}, rot=180, image="npc2", trade={{204,500},{205,500},{206,500},{207,500},{-204,250},{-205,250},{-206,250},{-207,250}}}, [18] = {"Table Seller", pos={1389, 3951}, rot=180, image="npc2", trade={{208,500},{209,500},{210,500},{211,500},{-208,250},{-209,250},{-210,250},{-211,250}}}, [19] = {"Hat Sourvenir Buyer", pos={4878, 1009}, rot=270, image="npc1", trade={{-314,300},{-315,300},{-316,300},{-317,300},{-318,300},{-319,300},{-899,300}}}, [20] = {"Wings Seller", pos={1539, 688}, rot=0, image="npc1", trade={{404,150000},{405,150000},{406,150000},{407,150000},{-404,72500},{-405,72500},{-406,72500},{-407,72500}}}, [21] = {"Konat", pos={4287, 797}, rot=0, image="npc1"}, [22] = {"Crash Yatamo", pos={4832, 162}, rot=0, image="npc4", trade={{-324,10000},{-325,10000},{-326,13000},{-327,15000},{-324,10}}}, [23] = {"Danny Deth", pos={2834, 2604}, rot=0, image="npc8", trade={{103,1000},{-103,500}}}, [24] = {"Black Market", pos={834, 1329}, rot=0, image="npc8", trade={{-991,3500},{-384,29000},{-385,34000},{-956,30000}}}, [25] = {"Sniper Market", pos={831, 1181}, rot=180, image="npc8", trade={{991,35000},{384,60000},{385,70000},{956,85000}}}, [26] = {"Bow Market", pos={584, 1067}, rot=270, image="npc8", trade={{988,30000},{-988,7000},{986,20000},{-986,7000},{987,10000},{-987,2500}}}, [27] = {"Jason Man", pos={411, 94}, rot=180, image="npc3", trade={{-370,150},{-371,175},{-372,300},{-373,450},{-390,1500},{-374,700}}}, [28] = {"Rick", pos={603, 93}, rot=180, image="npc8", trade={{-375,2000},{-376,3200},{-377,3900},{-378,4500},{-389,3900},{-990,7000},{-993,15000}}}, [29] = {"Jonson", pos={739, 849}, rot=270, image="npc2", trade={{-380,7500},{-381,7500},{-995,8000},{-388,9500},{-383,13000}}}, [30] = {"Michael", pos={4462, 1073}, rot=0, image="npc8", trade={{-382,30000},{-386,54000},{-994,390000},{-992,350000},{-387,70000},{-999,500000},{-989,95000}}}, [31] = {"Arnold", pos={8085, 6451}, rot=180, image="npc1"}, [32] = {"Rick Joson", pos={1107, 9811}, rot=180, image="npc1"}, [33] = {"Food's Seller", pos={7507, 6092}, rot=90, image="npc4", trade={{2,150},{997,100},{4,200},{985,250}}}, [34] = {"Rick Reck", pos={7595, 5612}, rot=0, image="npc1"}, [35] = {"Rick Reck", pos={8690, 5740}, rot=0, image="npc1"}, [36] = {"Dragon Set Makert", pos={1107, 10111}, rot=90, image="npc4", trade={{968,80000},{969,150000},{970,80000},{971,50000},{-968,36000},{-969,70000},{-970,36000},{-971,15000}}}, [37] = {"Food's Seller", pos={595, 9775}, rot=90, image="npc4", trade={{2,150},{997,100},{4,200},{985,250}}}, [38] = {"Medic Seller", pos={531, 9843}, rot=180, image="npc4", trade={{1,200},{3,100}}}, [39] = {"Ice Set Seller", pos={1107, 9980}, rot=90, image="npc4", trade={{962,250000},{963,100000},{964,200000},{965,100000},{966,950000}}}, [40] = {"Weapons +50 lvl Seller", pos={499, 10289}, rot=90, image="npc1", trade={{958,450000},{954,400000},{961,350000},{955,900000},{953,650000},{960,500000},{959,750000},{957,800000}}}, [41] = {"Tunnel [Gate]", pos={10553, 5523}, rot=180, image="npc9"}, [42] = {"Zombie City [Gate]", pos={7827, 8168}, rot=90, image="npc9"}, [43] = {"Dani", pos={7519, 10348}, rot=0, image="npc5", trade={{997,500},{1,300},{2,250}}}, [44] = {"Dane", pos={9869, 10604}, rot=0, image="npc5", trade={{212,15000},{20,15000},{21,5000},{22,3500},{-21,3500},{-22,1500},{-212,5000}}}, [45] = {"Barmen", pos={9810, 10335}, rot=90, image="npc5", trade={{997,500},{1,300},{2,250}}}, [46] = {"IIII City Teleport Seller", pos={636, 10417}, rot=0, image="npc5", trade={{2223,5000},{-2223,1500}}}, [47] = {"III City Teleport Seller", pos={7566, 10669}, rot=0, image="npc5", trade={{2222,5000},{-2222,1500}}}, [48] = {"Chainsaw Seller", pos={6995, 10533}, rot=90, image="npc5", trade={{24,50000},{-24,20000}}}, [49] = {"Diego", pos={6991, 10767}, rot=90, image="npc5", trade={{23,50000},{-23,20000},{27,150000},{-27,40000}}}, [50] = {"Hotel Seller 1", pos={11596, 556}, rot=0, image="npc5", trade={{29,1000000},{-29,150000}}}, [51] = {"Hotel Seller 2", pos={11827, 556}, rot=0, image="npc5", trade={{30,600000},{-30,250000}}}, [52] = {"Hotel Seller 3", pos={11596, 1075}, rot=180, image="npc5", trade={{31,1000000},{-31,150000}}}, [53] = {"Hotel Seller 4", pos={11596, 1075}, rot=180, image="npc5", trade={{25,150000},{-25,45000},{26,300000},{-26,125000}}}, [54] = {"Hotel Seller 5", pos={11827, 836}, rot=90, image="npc5", trade={{32,7500},{-32,2500}}}, [55] = {"Arnold", pos={11728, 836}, rot=180, image="npc1"}, [56] = {"PorT [Gate]", pos={10830, 1971}, rot=180, image="npc9"} } NPCs[1].func = function(npc, id, words, state) if words == "hi" then NPCspeak(npc, "Hi do you want rest it's cost only $50 ?") PLAYERS[id].tmp.npcstate = {npc, 1} elseif state == 1 then if words == "yes" then if addmoney(id,-50) then NPCspeak(npc, "Have good rest !") parse('setpos '..id..' 896 1057') PLAYERS[id].Spawn[1] = 877 PLAYERS[id].Spawn[2] = 1053 PLAYERS[id].tmp.npcstate = {npc, 0} else NPCspeak(npc, "You don't have enought money bye !") PLAYERS[id].tmp.npcstate = {npc, 0} end elseif words == "no" then NPCspeak(npc, "Bye then.") PLAYERS[id].tmp.npcstate = {npc, 0} end end end NPCs[2].func = function(npc, id, words, state) if words == "hi" then NPCspeak(npc, "The toll is $100. Do you want return to city?") PLAYERS[id].tmp.npcstate = {npc, 1} elseif contains(words, "bye") then NPCspeak(npc, "Not returning?") PLAYERS[id].tmp.npcstate = nil elseif state == 1 then if contains(words, "yes") then if addmoney(id, -100) then message(id, "You have lost $100.", "255255255") parse("setpos " .. id .. " 505 1871") else NPCspeak(npc, "No money, no returning.") end elseif contains(words, "no") then NPCspeak(npc, "Not returning?") end PLAYERS[id].tmp.npcstate = nil end end NPCs[21].func = function(npc, id, words, state) if words == "hi" then NPCspeak(npc, "Hi do you want rest it's cost only $50 ?") PLAYERS[id].tmp.npcstate = {npc, 1} elseif state == 1 then if words == "yes" then if addmoney(id,-50) then NPCspeak(npc, "Have good rest !") parse('setpos '..id..' 4168, 681') PLAYERS[id].Spawn[1] = 4168 PLAYERS[id].Spawn[2] = 681 PLAYERS[id].tmp.npcstate = {npc, 0} else NPCspeak(npc, "You don't have enought money bye !") PLAYERS[id].tmp.npcstate = {npc, 0} end elseif words == "no" then NPCspeak(npc, "Bye then.") PLAYERS[id].tmp.npcstate = {npc, 0} end end end NPCs[31].func = function(npc, id, words, state) if words == "hi" then NPCspeak(npc, "Hi do you want rest it's cost only $50 ?") PLAYERS[id].tmp.npcstate = {npc, 1} elseif state == 1 then if words == "yes" then if addmoney(id,-50) then NPCspeak(npc, "Have good rest !") parse('setpos '..id..' 8247 6534') PLAYERS[id].Spawn[1] = 8247 PLAYERS[id].Spawn[2] = 6533 PLAYERS[id].tmp.npcstate = {npc, 0} else NPCspeak(npc, "You don't have enought money bye !") PLAYERS[id].tmp.npcstate = {npc, 0} end elseif words == "no" then NPCspeak(npc, "Bye then.") PLAYERS[id].tmp.npcstate = {npc, 0} end end end NPCs[32].func = function(npc, id, words, state) if words == "hi" then NPCspeak(npc, "Hi do you want rest it's cost only $50 ?") PLAYERS[id].tmp.npcstate = {npc, 1} elseif state == 1 then if words == "yes" then if addmoney(id,-50) then NPCspeak(npc, "Have good rest !") parse('setpos '..id..' 1210 9753') PLAYERS[id].Spawn[1] = 1210 PLAYERS[id].Spawn[2] = 9752 PLAYERS[id].tmp.npcstate = {npc, 0} else NPCspeak(npc, "You don't have enought money bye !") PLAYERS[id].tmp.npcstate = {npc, 0} end elseif words == "no" then NPCspeak(npc, "Bye then.") PLAYERS[id].tmp.npcstate = {npc, 0} end end end NPCs[34].func = function(npc, id, words, state) if words == "hi" then NPCspeak(npc, "The toll is $100. Do you want return to city?") PLAYERS[id].tmp.npcstate = {npc, 1} elseif contains(words, "bye") then NPCspeak(npc, "Not returning?") PLAYERS[id].tmp.npcstate = nil elseif state == 1 then if contains(words, "yes") then if addmoney(id, -100) then message(id, "You have lost $100.", "255255255") parse("setpos " .. id .. " 7892 5691") else NPCspeak(npc, "No money, no returning.") end elseif contains(words, "no") then NPCspeak(npc, "Not returning?") end PLAYERS[id].tmp.npcstate = nil end end NPCs[35].func = function(npc, id, words, state) if words == "hi" then NPCspeak(npc, "The toll is $100. Do you want return to city?") PLAYERS[id].tmp.npcstate = {npc, 1} elseif contains(words, "bye") then NPCspeak(npc, "Not returning?") PLAYERS[id].tmp.npcstate = nil elseif state == 1 then if contains(words, "yes") then if addmoney(id, -100) then message(id, "You have lost $100.", "255255255") parse("setpos " .. id .. " 8975 5768") else NPCspeak(npc, "No money, no returning.") end elseif contains(words, "no") then NPCspeak(npc, "Not returning?") end PLAYERS[id].tmp.npcstate = nil end end NPCs[41].func = function(npc, id, words, state) if words == "hi" then NPCspeak(npc, "The toll is $1500 go Tunnel?") PLAYERS[id].tmp.npcstate = {npc, 1} elseif contains(words, "bye") then NPCspeak(npc, "Not returning?") PLAYERS[id].tmp.npcstate = nil elseif state == 1 then if contains(words, "yes") then if addmoney(id, -1500) then message(id, "You have lost $1500.", "255255255") parse("setpos " .. id .. " 10653 5574") else NPCspeak(npc, "No money, no returning.") end elseif contains(words, "no") then NPCspeak(npc, "Not returning?") end PLAYERS[id].tmp.npcstate = nil end end NPCs[42].func = function(npc, id, words, state) if words == "hi" then NPCspeak(npc, "Go The City") PLAYERS[id].tmp.npcstate = {npc, 1} elseif contains(words, "bye") then NPCspeak(npc, "Not returning?") PLAYERS[id].tmp.npcstate = nil elseif state == 1 then if contains(words, "yes") then if addmoney(id, -0) then message(id, "Ok Go go go.", "255255255") parse("setpos " .. id .. " 7884 8436") else NPCspeak(npc, "No money, no returning.") end elseif contains(words, "no") then NPCspeak(npc, "Not returning?") end PLAYERS[id].tmp.npcstate = nil end end NPCs[55].func = function(npc, id, words, state) if words == "hi" then NPCspeak(npc, "Hi do you want rest it's cost only $50 ?") PLAYERS[id].tmp.npcstate = {npc, 1} elseif state == 1 then if words == "yes" then if addmoney(id,-50) then NPCspeak(npc, "Have good rest !") parse('setpos '..id..' 11644 836') PLAYERS[id].Spawn[1] = 11644 PLAYERS[id].Spawn[2] = 837 PLAYERS[id].tmp.npcstate = {npc, 0} else NPCspeak(npc, "You don't have enought money bye !") PLAYERS[id].tmp.npcstate = {npc, 0} end elseif words == "no" then NPCspeak(npc, "Bye then.") PLAYERS[id].tmp.npcstate = {npc, 0} end end end NPCs[56].func = function(npc, id, words, state) if words == "hi" then NPCspeak(npc, "The toll is $150 go ?") PLAYERS[id].tmp.npcstate = {npc, 1} elseif contains(words, "bye") then NPCspeak(npc, "Not returning?") PLAYERS[id].tmp.npcstate = nil elseif state == 1 then if contains(words, "yes") then if addmoney(id, -150) then message(id, "You have lost $150.", "255255255") parse("setpos " .. id .. " 10978 1939") else NPCspeak(npc, "No money, no go.") end elseif contains(words, "no") then NPCspeak(npc, "Not go?") end PLAYERS[id].tmp.npcstate = nil end end for i, j in ipairs(NPCs) do j.image = image("gfx/weiwen/" .. (j.image or "npc1") .. ".png", 0, 0, 0) imagepos(j.image, j.pos[1], j.pos[2], j.rot) if j.trade then local text = j[1] .. "," for k, l in ipairs(j.trade) do local itemid if l[1] < 0 then itemid = -l[1] text = text .. "sell " else itemid = l[1] text = text .. "buy " end text = text " .. ITEMS[itemid].name .. "|" .. l[2] .. "," end j.menu = text end end function contains(words, text) words = words:lower(); return words == text or words:find(text .. " ") or words:find(" " .. text) end function NPCspeak(npcid, words) return radiusmsg(string.format("©255255100%s %s says : %s", os.date'%X', NPCs[npcid][1], words), NPCs[npcid].pos[1], NPCs[npcid].pos[2]) end function setNPCpos(npcid, x, y, rot) NPCs[npcid].rot = rot or NPCs[npcid].rot NPCs[npcid].pos = (x and y) and {x*32+16, y*32+16} or NPCs[npcid].pos imagepos(NPCs[npcid].image, NPCs[npcid].pos[1], NPCs[npcid].pos[2], NPCs[npcid].rot) end addhook("say", "NPCsay") function NPCsay(id, words) words = words:lower() if PLAYERS[id].tmp.npcstate then local v = NPCs[PLAYERS[id].tmp.npcstate[1]] if inarea(player(id, "x"), player(id, "y"), v.pos[1]-96, v.pos[2]-96, v.pos[1]+96, v.pos[2]+96) then NPCs[PLAYERS[id].tmp.npcstate[1]].func(PLAYERS[id].tmp.npcstate[1], id, words, PLAYERS[id].tmp.npcstate[2]) return else PLAYERS[id].tmp.npcstate = nil end end if contains(words, "hi") or contains(words, "hello") or contains(words, "yo") or contains(words, "hey") then for k, v in ipairs(NPCs) do if inarea(player(id, "x"), player(id, "y"), v.pos[1]-96, v.pos[2]-96, v.pos[1]+96, v.pos[2]+96) then if v.func then v.func(k, id, "hi") elseif v.menu then menu(id, v.menu) else NPCspeak(k, "Hello, I'm busy right now, speak to me later.") break end if v.greet then NPCspeak(k, string.format(v.greet, player(id, "name"))) end break end end end end addhook("menu", "NPCmenu") function NPCmenu(id, title, button) for i, v in ipairs(NPCs) do if title == v[1] then if button == 0 then if v.bye then NPCspeak(i, v.bye) end return end local itemid = math.abs(v.trade[button][1]) if itemid then print(itemid) radiusmsg(string.format("©255255100%s %s says : %s %s", os.date'%X', player(id, 'name'), v.trade[button][2] > 0 and "buy" or "sell", ITEMS[itemid].name), player(id, 'x'), player(id, 'y')) if v.trade[button][1] < 0 then if removeitem(id, itemid, 1, true) then addmoney(id, v.trade[button][2]) message(id, "You have recieved $" .. v.trade[button][2] .. ".", "255255255") msg2(id, "You have sold " .. ITEMS[itemid].article .. " " .. ITEMS[itemid].name .. " for $" .. v.trade[button][2] .. ".") return menu(id, NPCs[i].menu) end msg2(id, "You do not have " .. ITEMS[itemid].article .. " " .. ITEMS[itemid].name .. " to sell.") return elseif addmoney(id, -v.trade[button][2]) then if additem(id, itemid, 1, true) then message(id, "You have lost $" .. v.trade[button][2] .. ".", "255255255") msg2(id, "You have bought " .. ITEMS[itemid].article .. " " .. ITEMS[itemid].name .. " for $" .. v.trade[button][2] .. ".") return menu(id, NPCs[i].menu) end msg2(id, "You do not have enough capacity.") return end msg2(id, "You do not have enough money.") end return end end end