Hello! i had a working NPC in TFS 0.2.3 and i changed into a TFS 0.2.8 with a newer client and updated npc lib. All of my NPC's work apart from a couple, one of them is a custom made npc and when a player say "hi" or "hello" the NPC doesn't respond at all. I get this error:
Here is my function in the script of this NPC: (starting at line 33)
Can anyone fix it for me? thank you!
Code:
[02/06/2016 12:23:22] Lua Script Error: [Npc interface]
[02/06/2016 12:23:22] data/npc/scripts/physical.lua:onCreatureSay
[02/06/2016 12:23:22] data/npc/lib/npc.lua:46: attempt to perform arithmetic on global 'sx' (a table value)
[02/06/2016 12:23:22] stack traceback:
[02/06/2016 12:23:22] data/npc/lib/npc.lua:46: in function 'getDistanceToCreature'
[02/06/2016 12:23:22] data/npc/scripts/physical.lua:43: in function <data/npc/scripts/physical.lua:33>
Here is my function in the script of this NPC: (starting at line 33)
Code:
function onCreatureSay(cid, type, msg)
local player_gold = getPlayerItemCount(cid,2148)
local player_plat = getPlayerItemCount(cid,2152)*100
local player_crys = getPlayerItemCount(cid,2160)*10000
local player_money = player_gold + player_plat + player_crys
local playerCap = getPlayerFreeCap(cid)
local item = 7697 --Ring
local itemweight = getItemWeight(item, 1)
msg = string.lower(msg)
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Hi. I will refill your physical ring for 50k! Say ring to refill.')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('You will have to wait, ' .. getPlayerName(cid) .. '.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'ring') then
if getPlayerItemCount(cid,2258) == 1 and player_money >= 100000 then
doPlayerTakeItem(cid,2258,1)
doPlayerRemoveMoney(cid,50000)
doPlayerAddItem(cid,item,1)
else
selfSay('Please bring with you a physical ring!')
end
end
end
if msgcontains(msg, 'ihhihohohihiohoi') then
if getPlayerStorageValue(cid,21545) == 1 then
selfSay('Good job, you defeated the Demon Oak! Now search for the secret grave!')
setPlayerStorageValue(cid,21545,2)
else
selfSay('Go defeat the demon oak.')
end
end
if msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
focus = 0
end
end
Can anyone fix it for me? thank you!